ComboBox Not showing items

I have set up this combo box in a dialogue box but it isn't showing any itmes. It displays but there is nothing inside

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//The include header file
#include "resource.h"

BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{

    HWND cboGame;

    const char *Game[] = { "Death Match", "Team Death Match" };

	switch(Message)
	{
		case WM_INITDIALOG:
			// Default values
			SetDlgItemText(hwnd, IDC_TEXT, "Press the browse button and choose your map file...");
			SetDlgItemText(hwnd, IDC_TEXT1, "Type the full name of your map here...");
			                                            
                        
            cboGame = GetDlgItem(hwnd, IDC_GAME);

        for(int Count = 0; Count < 12; Count++)
        {
            SendMessage(cboGame,
                        CB_ADDSTRING,
                        0,
                        reinterpret_cast<LPARAM>((LPCTSTR)Game[Count]));
        }
        return TRUE;


		break;
		
		case WM_COMMAND:
             switch(LOWORD(wParam))
			{
                case IDC_ADD:
                     {
                     OPENFILENAME ofn;
                     char szFileName[MAX_PATH] = "";

                     ZeroMemory(&ofn, sizeof(ofn));

                     ofn.lStructSize = sizeof(ofn); // SEE NOTE BELOW
                     ofn.hwndOwner = hwnd;
                     ofn.lpstrFilter = "Map Files (*.ctm)\0*.ctm\0All Files (*.*)\0*.*\0";
                     ofn.nMaxFile = MAX_PATH;
                     ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
                     ofn.lpstrDefExt = "ctm";
                     ofn.lpstrFileTitle = szFileName;
                     ofn.nMaxFileTitle = 100;

                     if(GetOpenFileName(&ofn))
                     {
                     SetDlgItemText(hwnd, IDC_TEXT, szFileName);
                     }
                     }
            }
        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_MAIN), NULL, DlgProc);
}


If you need my header or resource file then just tell me

Thanks in advance.
Two things I can think of:

1. Your ComboBox may not be big enough. What dimensions have you specified??
If that is ok then:

2. confirm that reinterpret_cast<LPARAM>((LPCTSTR)Game[Count])) does provide the
strings.
You can for test purposes change the loop to something like:
1
2
3
4
5
6
7
        for(int Count = 0; Count < 12; Count++)
        {
            SendMessage(cboGame,
                        CB_ADDSTRING,
                        0,
                        (LPARAM)"Hello" /*reinterpret_cast<LPARAM>((LPCTSTR)Game[Count])*/);
        }
Last edited on
Topic archived. No new replies allowed.