listcontrol 问题
我在winmain中用 CreateDialog 创建了一个对话框。如果对话框模板中没有包含listcontrol 控件的话,很顺利的,对话框显示出来。否则,对话框不显示, 返回的 hwnd=NULL , 用GetLastError 得到的代码是 0, 0一般不是代表成功了吗?请问各位怎么才能将包含listrol的对话框显示出来,麻烦指教一下,谢谢。
我的代码如下:
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = DLGWINDOWEXTRA ; // Note!
wndclass.hInstance = hInstance ;
wndclass.hIcon = NULL; //LoadIcon (hInstance, szAppName) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ;
if (!RegisterClass (&wndclass))
{
MessageBox ( NULL, TEXT ("This program requires Windows NT!"), szAppName, MB_ICONERROR) ;
return 0 ;
}
hwnd = CreateDialog (hInstance, MAKEINTRESOURCE(IDD_DIALOG1), 0, NULL) ;
if(!hwnd)
{
wsprintf( buf, "create dlg fail %d ", GetLastError());
MessageBox(NULL, buf, " err", 0);
return 0;
}
ShowWindow (hwnd, iCmdShow) ;
rc文件:
// Generated from the TEXTINCLUDE 2 resource.
//
#include "resource.h"
#include "afxres.h"
//
// Dialog
//
HEXCALC DIALOG DISCARDABLE 0, 0, 413, 248
STYLE WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU
CAPTION "Dialog"
CLASS "HexCalc"
FONT 10, "System"
BEGIN
CONTROL "List3",IDC_LIST,"SysListView32",LVS_NOSCROLL |
WS_BORDER | WS_TABSTOP,7,7,403,238
END