Hi triola, welcome to forum.
I'm pretty sure it's a problem with your IDs.
Overwrite main.c, main.h, main.rc with this:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
#include <tchar.h>
#include "main.h"
static INT_PTR CALLBACK MainDlgProc(HWND, UINT, WPARAM, LPARAM);
static HANDLE ghInstance;
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
{
INITCOMMONCONTROLSEX icc;
WNDCLASSEX wcx;
ghInstance = hInstance;
icc.dwSize = sizeof(icc);
icc.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&icc);
wcx.cbSize = sizeof(wcx);
if (!GetClassInfoEx(NULL, MAKEINTRESOURCE(32770), &wcx))
return 0;
wcx.hInstance = hInstance;
wcx.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDR_ICO_MAIN));
wcx.lpszClassName = _T("hfghhfdgClass");
if (!RegisterClassEx(&wcx))
return 0;
return DialogBox(hInstance, MAKEINTRESOURCE(DLG_MAIN), NULL, (DLGPROC)MainDlgProc);
}
static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static HWND hmodglobal;
static HWND hmodcampaign;
static HWND hmodmultiplay;
static HWND hmodmusic;
switch (uMsg)
{
case WM_INITDIALOG:
{
hmodglobal = GetDlgItem(hwndDlg, IDMODGLOBAL);
hmodcampaign = GetDlgItem(hwndDlg, IDMODCAMPAIGN);
hmodmultiplay = GetDlgItem(hwndDlg, IDMODMULTIPLAY);
hmodmusic = GetDlgItem(hwndDlg, IDMODMUSIC);
SendMessage(hmodglobal, CB_ADDSTRING, 0, (LPARAM)"this is test 1");
SendMessage(hmodglobal, CB_ADDSTRING, 0, (LPARAM)"this is test 2");
SendMessage(hmodglobal, CB_ADDSTRING, 0, (LPARAM)"this is test 3");
SendMessage(hmodglobal, CB_ADDSTRING, 0, (LPARAM)"this is test 4");
return TRUE;
}
case WM_SIZE:
return TRUE;
case WM_COMMAND:
switch (GET_WM_COMMAND_ID(wParam, lParam))
{
case IDOK:
EndDialog(hwndDlg, TRUE);
return TRUE;
}
break;
case WM_CLOSE:
EndDialog(hwndDlg, 0);
return TRUE;
}
return FALSE;
}
// INCLUDE FILE generated by "Pelles C for Windows, version 1.00".
#define DLG_MAIN 1001
#define IDR_ICO_MAIN 8001
#define IDMODGLOBAL 4001
#define IDMODCAMPAIGN 4002
#define IDMODMULTIPLAY 4003
#define IDMODMUSIC 4004
open main.rc as a text file
// RESOURCE SCRIPT generated by "Pelles C for Windows, version 7.00".
#include <windows.h>
#include <commctrl.h>
#include <richedit.h>
#include "main.h"
LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US
DLG_MAIN DIALOGEX DISCARDABLE 6, 18, 194, 102
STYLE DS_SHELLFONT|DS_MODALFRAME|DS_3DLOOK|WS_THICKFRAME|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_VISIBLE
CAPTION "hfghhfdgdffd Program"
CLASS "hfghhfdgClass"
FONT 8, "MS Shell Dlg", 0, 0, 1
{
CONTROL "OK", IDOK, "Button", WS_TABSTOP, 72, 4, 45, 15
CONTROL "", 4001, "ComboBox", WS_BORDER|CBS_DROPDOWN|CBS_SORT|WS_VSCROLL|WS_TABSTOP, 4, 32, 96, 64
CONTROL "", 4002, "ComboBox", WS_BORDER|CBS_DROPDOWN|CBS_SORT|WS_VSCROLL|WS_TABSTOP, 104, 32, 88, 40
CONTROL "", 4003, "ComboBox", WS_BORDER|CBS_DROPDOWN|CBS_SORT|WS_VSCROLL|WS_TABSTOP, 0, 80, 100, 40
CONTROL "", 4004, "ComboBox", WS_BORDER|CBS_DROPDOWN|CBS_SORT|WS_VSCROLL|WS_TABSTOP, 104, 80, 88, 40
}
IDR_ICO_MAIN ICON "main.ico"
the line in main.rc:
CONTROL "",4001, "ComboBox" ......
must match with:
#define IDMODGLOBAL 4001
in main.h in order to make work:
hmodglobal = GetDlgItem(hwndDlg, IDMODGLOBAL);
Laur