I am trying to create a win32 application with a menu bar on the main window. This menu bar has an option to open a dialog box with list boxes. I am trying to fill these list boxes by usuing the "LB_ADDSTRING" message. However when I click on the list box to drop down the list, none of the items are listed.
My main menu bar has three options; "About", "Settings" and "Exit". The WM_COMMAND for the main window is listed below.
case WM_COMMAND:
WORD idControl = LOWORD(wParam);
HWND hwndCtl = (HWND) lParam;
switch(idControl) {
case IDD_FILE:
DialogBox(g_hInst,
MAKEINTRESOURCE(IDD_ABOUT), hwnd,
(DLGPROC)extradlg);
break;
case IDD_SET:
g_hwndODlg = CreateDialog(g_hInst,
MAKEINTRESOURCE(IDD_SETTINGS), hwnd,
(DLGPROC)optdlg);
ShowWindow(g_hwndODlg, SW_SHOW);
break;
case ID_EXIT:
break;
}
return(0);
All these options appear to be working fine. When the Settings option (IDD_SETTINGS) is chosen a new dialog window is display with the combo boxes I am trying to fill. The procedure I am using to fill these boxes is:
BOOL CALLBACK optdlg(HWND hwndDlg, UINT uMsg,
WPARAM wParam, LPARAM lParam )
{
int retstat;
HWND hListWnd;
switch(uMsg) {
case WM_INITDIALOG:
hListWnd = GetDlgItem(hwndDlg,IDC_LISTBOX);
SendMessage(hListWnd, LB_ADDSTRING, 0,
(LPARAM)"Item 1");
SendMessage(hListWnd, LB_ADDSTRING, 0,
(LPARAM)"Item 2");
SendMessage(hListWnd, LB_ADDSTRING, 0,
(LPARAM)"Item 3");
SetFocus(GetDlgItem(hwndDlg, IDC_LISTBOX));
return(false);
case WM_COMMAND:
WORD idControl = LOWORD(wParam);
HWND hwndCtl = (HWND) lParam;
switch(idControl) {
case IDOK:
EndDialog(hwndDlg, IDOK);
return(true);
case IDCANCEL:
DestroyWindow(g_hwndODlg);
g_hwndODlg = NULL;
return(true);
}
return (false);
}
return(false);
}
Thanks for any help you can provide.
My main menu bar has three options; "About", "Settings" and "Exit". The WM_COMMAND for the main window is listed below.
case WM_COMMAND:
WORD idControl = LOWORD(wParam);
HWND hwndCtl = (HWND) lParam;
switch(idControl) {
case IDD_FILE:
DialogBox(g_hInst,
MAKEINTRESOURCE(IDD_ABOUT), hwnd,
(DLGPROC)extradlg);
break;
case IDD_SET:
g_hwndODlg = CreateDialog(g_hInst,
MAKEINTRESOURCE(IDD_SETTINGS), hwnd,
(DLGPROC)optdlg);
ShowWindow(g_hwndODlg, SW_SHOW);
break;
case ID_EXIT:
break;
}
return(0);
All these options appear to be working fine. When the Settings option (IDD_SETTINGS) is chosen a new dialog window is display with the combo boxes I am trying to fill. The procedure I am using to fill these boxes is:
BOOL CALLBACK optdlg(HWND hwndDlg, UINT uMsg,
WPARAM wParam, LPARAM lParam )
{
int retstat;
HWND hListWnd;
switch(uMsg) {
case WM_INITDIALOG:
hListWnd = GetDlgItem(hwndDlg,IDC_LISTBOX);
SendMessage(hListWnd, LB_ADDSTRING, 0,
(LPARAM)"Item 1");
SendMessage(hListWnd, LB_ADDSTRING, 0,
(LPARAM)"Item 2");
SendMessage(hListWnd, LB_ADDSTRING, 0,
(LPARAM)"Item 3");
SetFocus(GetDlgItem(hwndDlg, IDC_LISTBOX));
return(false);
case WM_COMMAND:
WORD idControl = LOWORD(wParam);
HWND hwndCtl = (HWND) lParam;
switch(idControl) {
case IDOK:
EndDialog(hwndDlg, IDOK);
return(true);
case IDCANCEL:
DestroyWindow(g_hwndODlg);
g_hwndODlg = NULL;
return(true);
}
return (false);
}
return(false);
}
Thanks for any help you can provide.