WIN32 lesson1

#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;

}

#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;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值