能力值:
( LV2,RANK:10 )
|
-
-
2 楼
LB_XXXX消息是LISTBOX的.
CB_XXXX消息才是COMBOBOX的,你用LISTBOX的消息想初始化COMBOBOX?
.386
.model flat,stdcall
option casemap:none
include windows.inc
include user32.inc
include kernel32.inc
includelib user32.lib
includelib kernel32.lib
IDD_MAIN equ 1000
IDC_CBO1 equ 1001
.data
hInstance dd ?
hCbo dd ?
szString db 'hello world',0
.code
_dialogproc proc uses ebx edi esi,_hwnd,_umsg,_wparam,_lparam
mov eax,_umsg
.if eax == WM_CLOSE
invoke EndDialog,_hwnd,0
.elseif eax == WM_INITDIALOG
invoke GetDlgItem,_hwnd,IDC_CBO1
mov hCbo,eax
invoke SendMessage,hCbo,CB_ADDSTRING,0,addr szString
.endif
xor eax,eax
ret
_dialogproc endp
start:
invoke GetModuleHandle,0
mov hInstance,eax
invoke DialogBoxParam,hInstance,IDD_MAIN,NULL,offset _dialogproc,NULL
invoke ExitProcess,0
end start
|
能力值:
( LV2,RANK:10 )
|
-
-
3 楼
不是,,CB一样的,好像是不能显示的问题,,,,,里面好像有项目,,,只是不能显示出来,因为程序可以发送CBN_SELCHANGE给对话框函数,,,,,,
|
能力值:
( LV2,RANK:10 )
|
-
-
4 楼
确定,是里面有数据,但是却不能显示,,,,,救救命啊
#include<windows.h>
#include<F:\Listbox\resource.h>
TCHAR Test[3][10]={"A","B","C"};
BOOL CALLBACK DialogProc(
HWND hwndDlg, // handle to dialog box
UINT uMsg, // message
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd )
{
TCHAR szDialogName[]=TEXT("MyDialog");
DialogBox(hInstance,szDialogName,NULL,DialogProc);
return 0;
}
BOOL CALLBACK DialogProc(
HWND hwndDlg, // handle to dialog box
UINT uMsg, // message
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
HWND HwndList;
int i=0;
int nItem=0;
switch(uMsg)
{
case WM_INITDIALOG:
HwndList=GetDlgItem(hwndDlg,ID_LIST);
SendMessage(HwndList,CB_SETCURSEL,1,0);
for(i=0;i<3;i++)
{
SendMessage(HwndList,CB_ADDSTRING,0,(LPARAM)Test[i]);
SendMessage(HwndList, CB_SETITEMDATA, i, (LPARAM)i);
}
return TRUE;
case WM_COMMAND:
if(LOWORD(wParam)==ID_LIST)
{
if(HIWORD(wParam)==CBN_SELCHANGE)
{
HwndList=GetDlgItem(hwndDlg,ID_LIST);
nItem=SendMessage(hwndDlg, CB_GETCURSEL,0,0);
SetDlgItemText(hwndDlg,ID_LIST,Test[nItem]);
}
}
return TRUE;
case WM_CLOSE:
EndDialog(hwndDlg,0);
return TRUE;
}
return FALSE;
}
|
能力值:
( LV2,RANK:10 )
|
-
-
5 楼
已经解决了,把owner draw设置成No就行,不过还有一个问题,combobox的Type我设置成Drop list,这样控件就不能编辑了,,,,可以省去很多的麻烦,,,,但是初始化显示的时候三个项目之中,,一个都没选中,,,假如我想让控件初始化显示的时候就显示A,B,C三个当中的一个,,,应该怎么做????
|