小弟没学过VC,哪位大哥能解释一下这个简单程序是什么意思,最好注释一下谢谢了越详细越好
#include "stdafx.h"MSG Msg;
char lpszClassName[]="WXNWINDOWS";
char lpszTitle[]="自定义窗口";LRESULT CALLBACK WinProc(HWND hwnd,
UINT message,
WPARAM wParam,
LPARAM lParam)
{
switch(message)
{
case WM_DESTROY:
PostQuitMessage(0); break;
case WM_LBUTTONDOWN:
MessageBox(
NULL, // handle of owner window
"点击鼠标左键", // address of text in message box
"自定义窗口", // address of title of message box
MB_OK // style of message box
);
default:
return DefWindowProc(hwnd,message,wParam,lParam); }
return (0);}int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
WNDCLASS wndclass;
//窗口类的定义
wndclass.style=0;
wndclass.lpfnWndProc=WinProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon(NULL,IDI_ASTERISK);
//wndclass.hIcon=LoadIcon(xxx,"d:\\wxntest\\AUDIO.ICO"); //xxx为资源文件的句柄
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW); //wndclass.hbrBackground=(HBRUSH)(COLOR_GRAYTEXT);
wndclass.hbrBackground=CreateSolidBrush(RGB(255,0,0));
//wndclass.hbrBackground=GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName=lpszClassName; if(!RegisterClass(&wndclass))
{
MessageBox(
NULL, // handle of owner window
"失败!", // address of text in message box
"自定义窗口", // address of title of message box
MB_OK // style of message box
);
return false; }
//注册两次会失败!
/*
if(!RegisterClass(&wndclass))
{
MessageBox(
NULL, // handle of owner window
"失败!", // address of text in message box
"自定义窗口", // address of title of message box
MB_OK // style of message box
); // return false;
}
//创建一个窗口
HWND hwnd=CreateWindow(lpszClassName,
lpszTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd,SW_SHOW );
UpdateWindow(hwnd);
//可以创建两次以上!
HWND hwnd1=CreateWindow(lpszClassName,
lpszTitle,
WS_OVERLAPPEDWINDOW,
0,
0,
300,
200,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd1,SW_SHOW );
UpdateWindow(hwnd1); while(GetMessage(&Msg,NULL,0,0))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam; return 0;
}
#include "stdafx.h"MSG Msg;
char lpszClassName[]="WXNWINDOWS";
char lpszTitle[]="自定义窗口";LRESULT CALLBACK WinProc(HWND hwnd,
UINT message,
WPARAM wParam,
LPARAM lParam)
{
switch(message)
{
case WM_DESTROY:
PostQuitMessage(0); break;
case WM_LBUTTONDOWN:
MessageBox(
NULL, // handle of owner window
"点击鼠标左键", // address of text in message box
"自定义窗口", // address of title of message box
MB_OK // style of message box
);
default:
return DefWindowProc(hwnd,message,wParam,lParam); }
return (0);}int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
WNDCLASS wndclass;
//窗口类的定义
wndclass.style=0;
wndclass.lpfnWndProc=WinProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon(NULL,IDI_ASTERISK);
//wndclass.hIcon=LoadIcon(xxx,"d:\\wxntest\\AUDIO.ICO"); //xxx为资源文件的句柄
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW); //wndclass.hbrBackground=(HBRUSH)(COLOR_GRAYTEXT);
wndclass.hbrBackground=CreateSolidBrush(RGB(255,0,0));
//wndclass.hbrBackground=GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName=lpszClassName; if(!RegisterClass(&wndclass))
{
MessageBox(
NULL, // handle of owner window
"失败!", // address of text in message box
"自定义窗口", // address of title of message box
MB_OK // style of message box
);
return false; }
//注册两次会失败!
/*
if(!RegisterClass(&wndclass))
{
MessageBox(
NULL, // handle of owner window
"失败!", // address of text in message box
"自定义窗口", // address of title of message box
MB_OK // style of message box
); // return false;
}
//创建一个窗口
HWND hwnd=CreateWindow(lpszClassName,
lpszTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd,SW_SHOW );
UpdateWindow(hwnd);
//可以创建两次以上!
HWND hwnd1=CreateWindow(lpszClassName,
lpszTitle,
WS_OVERLAPPEDWINDOW,
0,
0,
300,
200,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd1,SW_SHOW );
UpdateWindow(hwnd1); while(GetMessage(&Msg,NULL,0,0))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam; return 0;
}
解决方案 »
- 能否include cpp?
- 怎么查看编写的程序有无内存泄露?需要专门的软件吗?
- 小弟私下做了一个容器评测,做的大量对象的插入操作,具体情况如下,请众高手指点,结果是不是正确的,谢谢!
- IE的滚动条是怎么回事?
- 各位高手:如何在知道一台主机的IP地址的情况下,知道它正在使用的操作系统,悬赏100分
- 谁有CListCtrl控件可以把其中的数据库打印出来的功能!
- 怎么会出现这样的错误"unexpected end of file found"
- VC6.0难道不支持ACCESS 2000?
- 四舍五入问题
- 对话框中有一个edit,输入字母时,我如何改变默认的输入字体和大小?
- VC中如何获取以下信息
- 字符串处理的怪现象,请高手帮忙!
MessageBox(NULL,"点击鼠标左键","自定义窗口",MB_OK);