VC的Bug? ComboBox为什么不显示内容?
我在编写界面时碰到一个很奇怪的问题,ComboBox明明给了它显示的字符串,可是一旦编译运行就不行了,下面是我的程序代码,请大家帮我找找原因。
/*-----------------------------------------------------------
Scan Utility.cpp -- A simple Scanner Application
Soft Zealot (R) Robin Hood, 2001
-----------------------------------------------------------*/
// system header
#include <windows.h>
#include "resource.h"
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
HWND hwndScan ;
static TCHAR szAppName[] = TEXT ("Simple_Scan") ;
MSG msg ;
WNDCLASS wndclass ;
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = DLGWINDOWEXTRA ; // Note !!!
wndclass.hInstance = hInstance ;
// Load my favorite icon as app's icon
wndclass.hIcon = LoadIcon (hInstance, "App_Icon") ;
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 ;
}
hwndScan = CreateDialog (hInstance, szAppName, 0, NULL) ;
ShowWindow (hwndScan, iCmdShow) ;
//UpdateWindow (hwndScan) ;
// message WM_QUIT cause function GetMessage return 0
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static int cxClient, cyClient, cxScreen, cyScreen ;
HDC hdc ;
PAINTSTRUCT ps ;
RECT rect ;
HBRUSH hBrush ;
switch (message)
{
case WM_INITDIALOG:
return 0 ;
case WM_COMMAND:
switch (LOWORD (wParam))
{
case ID_BTN_EXIT:
SendMessage (hwnd, WM_CLOSE, 0, 0) ;
return 0;
}
break;
case WM_PAINT:
hdc = BeginPaint (hwnd, &ps) ;
GetClientRect (hwnd, &rect) ;
EndPaint (hwnd, &ps) ;
return 0 ;
case WM_DESTROY:
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}
/*-----------------------------------------------------------
Scan Utility.rc -- A simple Scanner Application
Soft Zealot (R) Robin Hood, 2001
-----------------------------------------------------------*/
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// Chinese (P.R.C.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
#ifdef _WIN32
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
#pragma code_page(936)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
APP_ICON ICON DISCARDABLE "App Icon.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
IDB_DPI BITMAP DISCARDABLE "Dpi.bmp"
IDB_SOURCE BITMAP DISCARDABLE "source.bmp"
IDB_STYLE BITMAP DISCARDABLE "Style.bmp"
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
SIMPLE_SCAN DIALOG DISCARDABLE 0, 0, 187, 98
STYLE DS_3DLOOK | DS_CENTER | WS_MINIMIZEBOX | WS_VISIBLE | WS_CAPTION |
WS_SYSMENU
CAPTION "Simple Scan Utility"
CLASS "Simple_Scan"
FONT 9, "Courier New"
BEGIN
DEFPUSHBUTTON "OK",ID_BTN_EXIT,130,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,130,24,50,14
COMBOBOX IDC_COMBO1,20,11,48,47,CBS_DROPDOWNLIST | WS_VSCROLL |
WS_TABSTOP
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
"SIMPLE_SCAN", DIALOG
BEGIN
LEFTMARGIN, 5
RIGHTMARGIN, 180
TOPMARGIN, 7
BOTTOMMARGIN, 91
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Dialog Info
//
SIMPLE_SCAN DLGINIT
BEGIN
IDC_COMBO1, 0x403, 5, 0
0x6554, 0x7478, "\000"
IDC_COMBO1, 0x403, 22, 0
0x6c42, 0x6361, 0x206b, 0x6e61, 0x2064, 0x6857, 0x7469, 0x2065, 0x6850,
0x746f, 0x006f,
IDC_COMBO1, 0x403, 17, 0
0x7247, 0x7961, 0x4320, 0x6c6f, 0x726f, 0x5020, 0x6f68, 0x6f74, "\000"
IDC_COMBO1, 0x403, 19, 0
0x3834, 0x422d, 0x7469, 0x4320, 0x6c6f, 0x726f, 0x5020, 0x6f68, 0x6f74,
"\000"
0
END
#endif // Chinese (P.R.C.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
程序使用SDK编程,加入对话框资源,然后加入combobox,开始正常,后来由于需要使用
对话框作为主窗口,所以必须用文本编辑器在对话框资源描述处加入CLASS "Simple_Scan"
语句,后来可能是在文本编辑器中调整了控件坐标,就不行了。我又重新打开一个新的工程,还是不行。
大家帮我找找原因,哪位能够解答,140分送上。
可是140分啊。我能给的最大分了。