Combo Box

Hi,
Please reply for this mail.I am having a combo box its parent is toolbar.But i want to access that combo box list other than parent window.Kindly give a solution for this problem

Regard

Manju T
How did you create the combo box ? you can save the hwnd of the window.

In case its a resource, may be you can find it with the id ?
Created combo box with function CreateWindowEx() inside Main window & setting its parent window as Toolbar.so if i am clicking on combobox from that main window it will open (Combo box list)without any problem,But i want to open that combo box list inside a child window what i have to do for that?

code in breif

#define IDC_FBDs_COMBO 104
HWND hToolBar,hWndCombo1,New_chld=NULL;
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static TCHAR *pFbds[6]={_T("DADD"),_T("CBCD"),_T("CBIN"),_T("CDBCD"),_T("CDBIN"),_T("ADD")};

case WM_CREATE:
hWndCombo1 = CreateWindowEx(0, _T("COMBOBOX"), _T(""), WS_CHILD | CBS_DROPDOWN| CBS_SORT| WS_OVERLAPPED|WS_VISIBLE | CBS_HASSTRINGS,354, 29, 90, 300,hToolBar, (HMENU)IDC_FBDs_COMBO,GetModuleHandle(NULL), 0 );

for(int i=0;i<6;i++)
SendMessage(hWndCombo1,CB_ADDSTRING ,0 , (LPARAM)pFbds[i]);


case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_FBDs_COMBO:
//sending message to LadderWndProc child window

SendMessage(New_chld, WM_COMMAND, wParam, lParam);
break;
}
}

//Procedure for LadderWndProc child window
LRESULT CALLBACK LadderWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
case WM_COMMAND:

switch(LOWORD(wParam))
{

case IDC_FBDs_COMBO:
{

SendMessage(hWndCombo1, CB_SHOWDROPDOWN ,0 , 0);

}
break;
}
Last edited on
You have the HWND of the combo box, can't you use that and send a message to the combo box ?
Eventhough the HWND of Combo box ie hWndCombo1 global,i canot send message from childwindow to show the list when user clicking on combo box arrow.I don't know why that is not possible.Same toolbar i have somany buttons also these buttons i am handling from child window without any problem.
Last edited on
What exactly you are trying to achieve ?

Are you trying to imitate a click on combo box or if something wrong happens when the user clicks the combo box ?
a click on combo box arrow should display the items on combox
Last edited on
For this, you don't have to know the HWND of the combo. Just check if you are adding items to the combo box or not. Its possible that the combo box is empty and thats why you are not seeing anything.
No my combo box is not empty i am adding strings on combo box with CB_ADDSTRING message
Did you check if they are actually added ?

You can post your full code which can be compiled. Remove the not related parts and i can have a look.
I posted a part of the code.in brief i have a main window, from main window procedure i am creating toolbar inside toolbar buttons(Using Resource)& combo box, a mdi client window.From Mdi Client window Proc creating MDI Child window.From this child window i want to open the combo box dropdown list,but i canot.I can open that combo box from MDI Client window but i don't want that.Please help me

#define IDC_FBDs_COMBO 104

HWND hToolBar,hWndCombo1,New_chld,g_hMDIClient =NULL;

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static TCHAR *pFbds[6]={_T("DADD"),_T("CBCD"),_T("CBIN"),_T("CDBCD"),_T("CDBIN"),_T("ADD")};

case WM_CREATE:
CLIENTCREATESTRUCT ccs;

// Create MDI Client

// Find window menu where children will be listed
ccs.hWindowMenu = GetSubMenu(GetMenu(hWnd), 2);
ccs.idFirstChild = ID_MDI_FIRSTCHILD;

g_hMDIClient = CreateWindowEx(WS_EX_CLIENTEDGE, _T("mdiclient"), NULL,
WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL | WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
hWnd, (HMENU)IDC_MAIN_MDI, GetModuleHandle(NULL), (LPVOID)&ccs);

hToolBar= CreateWindowEx(WS_EX_TOOLWINDOW, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE|TBSTYLE_TOOLTIPS|TBSTYLE_WRAPABLE , 0, 0, 0,0,hWnd, (HMENU)IDC_MAIN_TOOL, GetModuleHandle(NULL), NULL);
if(hToolBar== NULL)
MessageBox(hWnd,_T( "Could not create main tool bar."), _T("Error"), MB_OK | MB_ICONERROR);

hWndCombo1 = CreateWindowEx(0, _T("COMBOBOX"), _T(""), WS_CHILD | CBS_DROPDOWN| CBS_SORT| WS_OVERLAPPED|WS_VISIBLE | CBS_HASSTRINGS,354, 29, 90, 300,hToolBar, (HMENU)IDC_FBDs_COMBO,GetModuleHandle(NULL), 0 );

for(int i=0;i<6;i++)
SendMessage(hWndCombo1,CB_ADDSTRING ,0 , (LPARAM)pFbds[i]);


case WM_COMMAND:
switch(LOWORD(wParam))
{


case ID_FILE_NEW40001://'New 'toolbar button
{

hChild=CreateNewMDIChild(g_hMDIClient);
}
break;
case IDC_FBDs_COMBO:
//sending message to LadderWndProc child window

SendMessage(New_chld, WM_COMMAND, wParam, lParam);
break;
}
}
HWND CreateNewMDIChild(HWND hMDIClient)
{
MDICREATESTRUCT mcs;
mcs.szTitle = g_PrjctName;
mcs.szClass = g_szChildClassName;
mcs.hOwner = GetModuleHandle(NULL);
mcs.x = mcs.cx = CW_USEDEFAULT;
mcs.y = mcs.cy = CW_USEDEFAULT;
mcs.style = MDIS_ALLCHILDSTYLES |WS_MAXIMIZE;

hChild = (HWND)SendMessage(hMDIClient, WM_MDICREATE, 0, (LONG)&mcs);
}

LRESULT CALLBACK MDIChildWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
WNDCLASSEX wcex1;
switch(msg)
{

case WM_CREATE:
{

wcex1.cbSize = sizeof(WNDCLASSEX);
wcex1.style = CS_DBLCLKS ;
wcex1.lpfnWndProc = LadderWndProc;
wcex1.cbClsExtra = 0;
wcex1.cbWndExtra = 0;
wcex1.hInstance = GetModuleHandle(NULL);
wcex1.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_APP1));
wcex1.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex1.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex1.lpszMenuName = NULL;
wcex1.lpszClassName = szchildClass;
wcex1.hIconSm = LoadIcon(wcex1.hInstance, MAKEINTRESOURCE(IDR_APP1));

RegisterClassEx(&wcex1);
New_chld=CreateWindowEx(WS_EX_CLIENTEDGE,szchildClass,szchildTitle,
WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL , 0, 0, 100,100,
hwnd,(HMENU)IDC_CHILD_EDIT,GetModuleHandle(NULL),NULL);
}
//Procedure for LadderWndProc child window
LRESULT CALLBACK LadderWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
case WM_COMMAND:

switch(LOWORD(wParam))
{

case IDC_FBDs_COMBO:
{

SendMessage(hWndCombo1, CB_SHOWDROPDOWN ,0 , 0);

}
break;
}
Last edited on
check you code which you have posted. It has errors.
like, invalid switch:

case WM_CREATE:
CLIENTCREATESTRUCT ccs;

post all your #defines, globals etc. I can help if I get a code which is already compiling.

Also, always post in code tags.
code here
Sorry ,I cannot post the full code ,Because that is very lengthy code. can you please tell me, if iam creating a combo box from child window procedure Under WM_CREAT on toolbar(parent window of combo box setting as toolbar),can i open that combo box from that child window.For me that is the problem it is not opening from that chil window.If i am creating that same combo box from main window procedure i can open that combo box without any problem.But my application demanding to open the combo box from child window.Please help me i am fresher in coding field
After looking at the specific part of code where you are creating the combo and adding strings, it looks correct.

Why I am asking for code is, because only looking at specific part, problem cannot be known. Sometimes, the problem in one part effects other parts.
What exactly is going on, what exactly you are trying is not clear.
In case the code is big and you have no issues of making your code public, you can upload it somewhere and post the link. I can have a look.
Thanks alot for your responds.i found out the problem.problem was, i was setting keyboard focus from child window to some other window in one condition, so only toolbar loosing its focus.But SetFocus function actually for keyboard right,why it is effecting Mouse events??
Last edited on
Topic archived. No new replies allowed.