#include
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
WNDCLASS wndclass;
HWND hWnd;
MSG msg;
wndclass.style=CS_HREDRAW|CS_VREDRAW;
wndclass.lpfnWndProc=WndProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName="window窗口創建";
if(!RegisterClass(&wndclass))
return FALSE;
hWnd=CreateWindowExW(WS_OVERLAPPEDWINDOW,"window窗口創建","window窗口創建",WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,NULL);
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message)
{
case WM_PAINT:HDC hdc;
PAINTSTRUCT ps;
hdc=BeginPaint(hWnd,&ps);
TextOutW(hdc,10,20,"哈哈,windows編程創建的窗口!",28);
EndPaint(hWnd,&ps);
return 0;
case WM_DESTROY:PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd,message,wParam,lParam);
}
這代碼報如下錯誤:
------ 已啟動生成: 項目: 應用編程, 配置: Debug Win32 ------
1> hellomfc.cpp
1>c:\documents and settings\administrator\my documents\visual studio 2010\projects\應用編程\應用編程\hellomfc.cpp(17): error C2440: “=”: 無法從“const char [15]”轉換為“LPCWSTR”
1> 與指向的類型無關;轉換要求 reinterpret_cast、C 樣式轉換或函數樣式轉換
1>c:\documents and settings\administrator\my documents\visual studio 2010\projects\應用編程\應用編程\hellomfc.cpp(21): error C2664: “CreateWindowExW”: 不能將參數 2 從“const char [15]”轉換為“LPCWSTR”
1> 與指向的類型無關;轉換要求 reinterpret_cast、C 樣式轉換或函數樣式轉換
1>c:\documents and settings\administrator\my documents\visual studio 2010\projects\應用編程\應用編程\hellomfc.cpp(38): error C2664: “TextOutW”: 不能將參數 4 從“const char [28]”轉換為“LPCWSTR”
1> 與指向的類型無關;轉換要求 reinterpret_cast、C 樣式轉換或函數樣式轉換
========== 生成: 成功 0 個,失敗 1 個,最新 0 個,跳過 0 個 ==========
http://www.cnblogs.com/dongsheng/p/3586418.html
你的項目是VC6.0的,需要修改