question
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static HINSTANCE hInstance ;
switch (message)
{
case WM_CREATE :
hInstance = ((LPCREATESTRUCT) lParam)->hInstance ;
return 0 ;
…………………
}
}
请问每次return 0有何作用?如果改为return 1又将如何?
问题点数:0、回复次数:5Top
1 楼kingcom_xu(冷羽)回复于 2003-02-03 01:50:58 得分 0
Return Values
If an application processes this message, it should return zero to continue creation of the window. If the application returns –1, the window is destroyed and the CreateWindowEx or CreateWindow function returns a NULL handle.
>>如果改为return 1又将如何?
那你就试试呗:)
Top
2 楼showmetheway(雪儿甜心)回复于 2003-02-03 02:13:42 得分 0
好,既然这样我就找了下面这个例子式了一下。
BOOL CALLBACK AboutDlgProc (HWND hDlg, UINT message,
WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG :
return TRUE ;
case WM_COMMAND :
switch (LOWORD (wParam))
{
case IDOK :
case IDCANCEL :
EndDialog (hDlg, 0) ;
return TRUE ;
}
break ;
}
return FALSE ;
}
AboutDlgProc是一个对话框过程,每次case之后都要return TRUE;
我试着把它改成return FALSE; 运行结果一样,难道这里他们就没有区别?
Top
3 楼everandforever(Forever)回复于 2003-02-03 02:40:18 得分 0
DEAR, 你求知欲不该这么强的。 处理一个消息你可以任意返回值,但是如果MSDN 告诉你了返回各种值有什么区别,你最好照它的做;否则你可以随意。例如:
WM_CREATE
If an application processes this message, it should return zero to continue creation of the window. If the application returns –1, the window is destroyed and the CreateWindowEx or CreateWindow function returns a NULL handle.Top
4 楼kingcom_xu(冷羽)回复于 2003-02-03 13:49:43 得分 0
对话框跟普通窗口有不同的...Top
5 楼showmetheway(雪儿甜心)回复于 2003-02-03 21:36:14 得分 0
谢谢 ,学到东西了;)Top




