-
Populating a combobox
Hi everyone,
I am trying to populate a combobox IDD_OFFSET_CBO that I have created in the .rc file with the following code:
Code:
#include <windows.h>
#include <string>
#include <math.h>
#include <conio.h>
#include <cmath>
#include <cstdio>
#include "resource.h"
BOOL CALLBACK ToolDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
HWND cboOffset;
const char *Offsets[] = { "+12", "+11", "+10", "+9", "+8", "+7", "+6", "+5", "+4", "+3", "+2", "+1", "0", "-1", "-2", "-3", "-4", "-5", "-6", "-7", "-8", "-9", "-10", "-11", "-12", };
switch(Message)
{
case WM_INITDIALOG:
cboOffset = GetDlgItem(hwnd, IDD_OFFSET_CBO);
for(int Count = 0; Count < 25; Count++)
{
SendMessage(cboOffset, CB_ADDSTRING, 0, (LPARAM)Offsets[Count]);
}
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_EXIT:
EndDialog(hwnd, 0);
break;
}
break;
case WM_CLOSE:
EndDialog(hwnd, 0);
break;
default:
return FALSE;
}
return TRUE;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
return DialogBox(hInstance, MAKEINTRESOURCE(IDD_WINDOW), NULL, ToolDlgProc);
}
However, when the window opens, the combobox always remains empty. Can anyone tell me where I'm going wrong please?
Thanks!
-
I've got it - the dimensions in the .rc file were too small - it seems fixed now.