主题:win32问题
#include<stdio.h>
#include<windows.h>
long _stdcall wndproc(HWND hwnd,UINT message,unsigned int wparam,long lparam)
{
switch(message)
{case WM_CHAR:
break;
case WM_PAINT:
PAINTSTRUCT ps;
BeginPaint(hwnd,&ps);break;
case WM_CLOSE:
ExitProcess(0);
break;
default:
return DefWindowProc (hwnd, message, wparam, lparam) ;
}
return 654;
}
int _stdcall WinMain(HINSTANCE wer,HINSTANCE,char*,int)
{
WNDCLASS wndclass;
memset(&wndclass,0,sizeof wndclass);
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.hInstance=wer;
wndclass.lpfnWndProc=wndproc;
wndclass.lpszClassName="ok";
wndclass.style=CS_HREDRAW|CS_VREDRAW;
wndclass.hCursor=LoadCursor(0,IDC_ARROW);
if(!RegisterClass(&wndclass))MessageBox(0,0,0,0);
HWND
hwnd = CreateWindow( "ok", // window class name
TEXT ("The Hello Program"), // window caption
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT, // initial x position
CW_USEDEFAULT, // initial y position
CW_USEDEFAULT, // initial x size
CW_USEDEFAULT, // initial y size
NULL, // parent window handle
NULL, // window menu handle
wer, // program instance handle
NULL) ; // creation parameters
ShowWindow (hwnd, SW_MAXIMIZE) ;
UpdateWindow (hwnd) ;
MSG msg;
while (GetMessage (&msg, 0, 0, 0))
{char s[199];
wsprintf(s,"%x",msg.message);
MessageBox(0,s,0,0);
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
}
这个程序getmessage后msg结构被填,那msg.message应该是各消息的编号(应该不同才是啊)怎么输出的messagebox显示结果相同呢?请指教
#include<windows.h>
long _stdcall wndproc(HWND hwnd,UINT message,unsigned int wparam,long lparam)
{
switch(message)
{case WM_CHAR:
break;
case WM_PAINT:
PAINTSTRUCT ps;
BeginPaint(hwnd,&ps);break;
case WM_CLOSE:
ExitProcess(0);
break;
default:
return DefWindowProc (hwnd, message, wparam, lparam) ;
}
return 654;
}
int _stdcall WinMain(HINSTANCE wer,HINSTANCE,char*,int)
{
WNDCLASS wndclass;
memset(&wndclass,0,sizeof wndclass);
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.hInstance=wer;
wndclass.lpfnWndProc=wndproc;
wndclass.lpszClassName="ok";
wndclass.style=CS_HREDRAW|CS_VREDRAW;
wndclass.hCursor=LoadCursor(0,IDC_ARROW);
if(!RegisterClass(&wndclass))MessageBox(0,0,0,0);
HWND
hwnd = CreateWindow( "ok", // window class name
TEXT ("The Hello Program"), // window caption
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT, // initial x position
CW_USEDEFAULT, // initial y position
CW_USEDEFAULT, // initial x size
CW_USEDEFAULT, // initial y size
NULL, // parent window handle
NULL, // window menu handle
wer, // program instance handle
NULL) ; // creation parameters
ShowWindow (hwnd, SW_MAXIMIZE) ;
UpdateWindow (hwnd) ;
MSG msg;
while (GetMessage (&msg, 0, 0, 0))
{char s[199];
wsprintf(s,"%x",msg.message);
MessageBox(0,s,0,0);
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
}
这个程序getmessage后msg结构被填,那msg.message应该是各消息的编号(应该不同才是啊)怎么输出的messagebox显示结果相同呢?请指教