#include <windows.h>
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// MessageBox(NULL,"Hello world","this is demo",0);
int res;
res = MessageBox(NULL,"Hello world","this is demo",MB_YESNO | MB_ICONWARNING);
if(res == IDYES)
MessageBox(NULL,"is YES","msg",0);
else
MessageBox(NULL,"is NO","msg",0);
return 0;
#define WM_MYMSG WM_USER+1
LRESULT CALLBACK MyWndProc(HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
TCHAR str[100];
switch(uMsg) {
case WM_MYMSG:
sprintf(str,"wparam is %d,lparam is %d",wParam,lParam);
MessageBox(NULL,str,"msgxx",0);
return 0;
case WM_LBUTTONDOWN:
PostMessage(hwnd,WM_MYMSG,100,200);
return 0;
case WM_CREATE:
MessageBox(NULL,"Create window","msg",0);
break;
// return 0;
case WM_SIZE:
sprintf(str,"w:%d h:%d",LOWORD(lParam),HIWORD(lParam));
MessageBox(NULL,str,"msg",0);
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
WNDCLASS wnd;
HWND hwin;
MSG msg;
wnd.style = CS_HREDRAW | CS_VREDRAW;
wnd.lpfnWndProc = MyWndProc;
wnd.cbClsExtra = 0;
wnd.cbWndExtra = 0;
wnd.hIcon = LoadIcon(NULL,IDI_APPLICATION);
wnd.hCursor = LoadCursor(NULL,IDC_ARROW);
// wnd.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wnd.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wnd.lpszMenuName = NULL;
wnd.lpszClassName = TEXT("窗口DEMO");
wnd.hInstance = hInstance;
if(!RegisterClass(&wnd))
{
MessageBox(NULL,"register fail","this is demo",0);
}
hwin = CreateWindow(TEXT("窗口DEMO"),
TEXT("我的窗口"),
WS_OVERLAPPEDWINDOW,
0,0,400,300,NULL,NULL,hInstance,NULL);
ShowWindow(hwin,nCmdShow);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.lParam;
}
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// MessageBox(NULL,"Hello world","this is demo",0);
int res;
res = MessageBox(NULL,"Hello world","this is demo",MB_YESNO | MB_ICONWARNING);
if(res == IDYES)
MessageBox(NULL,"is YES","msg",0);
else
MessageBox(NULL,"is NO","msg",0);
return 0;
}
#include <windows.h>#define WM_MYMSG WM_USER+1
LRESULT CALLBACK MyWndProc(HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
TCHAR str[100];
switch(uMsg) {
case WM_MYMSG:
sprintf(str,"wparam is %d,lparam is %d",wParam,lParam);
MessageBox(NULL,str,"msgxx",0);
return 0;
case WM_LBUTTONDOWN:
PostMessage(hwnd,WM_MYMSG,100,200);
return 0;
case WM_CREATE:
MessageBox(NULL,"Create window","msg",0);
break;
// return 0;
case WM_SIZE:
sprintf(str,"w:%d h:%d",LOWORD(lParam),HIWORD(lParam));
MessageBox(NULL,str,"msg",0);
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
WNDCLASS wnd;
HWND hwin;
MSG msg;
wnd.style = CS_HREDRAW | CS_VREDRAW;
wnd.lpfnWndProc = MyWndProc;
wnd.cbClsExtra = 0;
wnd.cbWndExtra = 0;
wnd.hIcon = LoadIcon(NULL,IDI_APPLICATION);
wnd.hCursor = LoadCursor(NULL,IDC_ARROW);
// wnd.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wnd.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wnd.lpszMenuName = NULL;
wnd.lpszClassName = TEXT("窗口DEMO");
wnd.hInstance = hInstance;
if(!RegisterClass(&wnd))
{
MessageBox(NULL,"register fail","this is demo",0);
}
hwin = CreateWindow(TEXT("窗口DEMO"),
TEXT("我的窗口"),
WS_OVERLAPPEDWINDOW,
0,0,400,300,NULL,NULL,hInstance,NULL);
ShowWindow(hwin,nCmdShow);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.lParam;
}