Click to See Complete Forum and Search --> : Clicking the combo box
mrRee
October 27th, 2004, 01:33 AM
I had a drop-list combo box. But when i run the program, the program doesn't select the item when i click the item. I don't know where it went wrong.
What i mean is, the item in the list box of the combo box cannot be selected by using mouse. But it only can be selected by using keyboard.
Bond
October 27th, 2004, 04:44 PM
Are you clicking the combo button to make the drop-down list appear? What I'm getting at is, does the mouse work on the combo box at all?
mrRee
October 27th, 2004, 09:06 PM
The dropdown list appear but i can't select the item in the list by clicking on it. I only can select the item by using the keyboard (up and down arrow)....
The dropdown list will appear when i click on the combo box or the arrow button of the combo box..
Is there something to do with the BN_CLICKED,? As long as i know it is nothing to do with it.
p/s: I use CB_INSERTSTRING to add item and initialize it with CBN_SELECTSTRING.
Last time i use CB_ADDSTRING and CBN_SETCURSEL but the behaviour is just
the same..Combo box style-> Owner draw=no. Not design in run time(created
in the dialog template)
kirants
October 27th, 2004, 10:23 PM
Are you sure you are doing nothing in code at all ? Make sure you comment out everything to do with the combo box , just leave it in the template and see ..
mrRee
October 27th, 2004, 10:46 PM
Are you sure you are doing nothing in code at all ?
Yes.. I had something like this:
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_STUFF:
switch(HIWORD(wParam))
{
case CBN_SELENDOK: //if the selection is confirm
GetDlgItemText(mainWnd,IDC_STUFF, task,20);//get the stuff name
setWork(task);break}
break;
............//another code for handle another event
void setWork(TCHAR *selection)
{
TCHAR item[40];
lstrcpy(item,"Work : ");
lstrcat(item,selection);
SendDlgItemMessage(mainWnd,IDC_WORK,LB_RESETCONTENT,0,0);// the list box content
for( int i=1;i<=2;i++)
{
//insert the string into list box(IDC_WORK is a List box)
SendDlgItemMessage(mainWnd,IDC_WORK,LB_ADDSTRING,-1,(LPARAM)item);
}
}
//this is the initialize part of the combo box:
void taskControl()
{
TCHAR task[4][20];
lstrcpy(task[1],"Task 1");
lstrcpy(task[2],"Task 2");
lstrcpy(task[3],"Task 3");
for(int i=1;i<=3;i++)
{ //Add the string into list box of the combo box at the end of list(-1)
SendDlgItemMessage(mainWnd,IDC_STUFF,CB_INSERTSTRING,-1,(LPARAM)task[i]);
}
//set current selection to first item list
SendDlgItemMessage(mainWnd,IDC_STUFF,CB_SELECTSTRING,-1,(LPARAM)task[1]);
setWork(task[1]);
}
is there something wrong with that?...
thanx
kirants
October 27th, 2004, 10:50 PM
Diffi to say.. is it possibile to zip up ur project and post it ?
mrRee
October 27th, 2004, 11:03 PM
Here is my code:
kirants
October 27th, 2004, 11:25 PM
Change this line as below:
while (GetMessage(&msg, NULL, 0, 0))
You were using mainWnd instead of NULL, so windows will pull only messages for the mainWnd and none else ;)
mrRee
October 27th, 2004, 11:29 PM
O my God..
So that's the reason...Thanx a lot for your help...I'am the newbie in this programming stuff...sorry for the silly question..
kirants
October 27th, 2004, 11:35 PM
You r welcome.. Take it easy.. All normal people do silly mistakes initially :D
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.