To this point I have filled the list in my combo box by passing the handle through the parameter list. But shouldn't I be able to use GetDlgItem
to get a handle to the combobox? If so, what do I pass to GetDlgItem
as the handle to the parent window if the parent window is the main window?
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
.
.
.
switch (message)
{
case WM_CREATE:
{
HWND hWndCB3;
hWndCB3 = CreateWindow(WC_COMBOBOX, TEXT(""),
CBS_DROPDOWN | CBS_HASSTRINGS | WS_CHILD | WS_OVERLAPPED | WS_VISIBLE | WS_VSCROLL,
40, 40, 400, 200, hWnd, (HMENU)IDC_COMBO3, hInst, NULL);
SQL_FillLessonInfo(hWndCB3);
}
break;
.
.
.
}
BOOL SQL_FillLessonInfo(HWND hWndCB)
{
.
.
.
SendMessage(hWndCB, CB_ADDSTRING, 0, (LPARAM)message.c_str());
.
.
.
}
Wanting something like...
HWND hWndCB = GetDlgItem(????, IDC_COMBO3);
...inside of SQL_FillLessonInfo()
.
CodePudding user response:
You'll need to pass hWnd (the parent window) as a parameter instead, so it's not going to save you much :) - Jonathan Potter
The window exists in a list maintained by the system, but if you want to refer to it in your code you need to store its handle somewhere (either by passing it around to functions, or in global data). (Its handle can also be found using FindWindow etc at any time, of course). – Jonathan Potter