|
我是新手,下面这段窗口代码调试不出来!有三个warning并且无法显示窗口,但是运行的话确实在进程中能看到这个!
大家帮我看看咋回事,谢谢!
#include <windows.h>
#include <stdlib.h>
#include <string.h>
long WINAPI WndProc(HWND hwnd,
UINT iMessage,
UINT wParam,
LONG lParam);
BOOL InitWindowsClass(HINSTANCE hInstance, WNDCLASS wc);
BOOL InitWindows(HINSTANCE hInstance, int nCmdShow, HWND hw);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
HWND hwnd;
WNDCLASS wndclass;
MSG Message;
InitWindowsClass(hInstance, wndclass);
InitWindows(hInstance, nCmdShow, hwnd);
while(GetMessage(&Message, 0, 0, 0))
{
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return Message.wParam;
}
LONG WINAPI WndProc(HWND hWnd,
UINT iMessage,
UINT wParam,
LONG lParam)
{
HDC hDC;
HBRUSH hBrush;
HPEN hPen;
PAINTSTRUCT PtStr;
switch(iMessage)
{
case WM_PAINT:
hDC = BeginPaint(hWnd, & tStr);
SetMapMode(hDC, MM_ANISOTROPIC);
hPen = (HPEN)GetStockObject(BLACK_PEN);
hBrush = (HBRUSH)GetStockObject(DKGRAY_BRUSH);
SelectObject(hDC, hBrush);
SelectObject(hDC, hPen);
RoundRect(hDC, 50, 120, 100, 200, 15, 15);
hBrush = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
SelectObject(hDC, hBrush);
Ellipse(hDC, 150, 50, 200, 150);
hBrush = (HBRUSH)GetStockObject(HOLLOW_BRUSH);
SelectObject(hDC, hBrush);
Pie(hDC, 250, 50, 300, 100, 250, 50, 300, 50);
EndPaint(hWnd, &PtStr);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return(DefWindowProc(hWnd, iMessage, wParam, lParam));
}
}
BOOL InitWindows(HINSTANCE hInstance, int nCmdShow, HWND hw)
{
HWND hWnd;
hWnd = hw;
hWnd = CreateWindow("trywindow",
"example",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
0,
CW_USEDEFAULT,
0,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}
BOOL InitWindowsClass(HINSTANCE hInstance, WNDCLASS wc)
{
WNDCLASS wndclass;
wndclass = wc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hbrBackground = (HBRUSH)(GetStockObject(WHITE_BRUSH));
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hIcon = LoadIcon(NULL, "END");
wndclass.hInstance = hInstance;
wndclass.lpfnWndProc = WndProc;
wndclass.lpszClassName = "winfill";
wndclass.lpszMenuName = NULL;
wndclass.style = CS_HREDRAW|CS_VREDRAW;
if(! RegisterClass(&wndclass))
{
MessageBeep(0);
return FALSE;
}
} [em6] [em6] [em6] |
|