Bonjour j'utilise visual studio 2022,

j'ai un problème avec l'ajout d'éléments à une combobox après sa création : si je tape
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
 
    TCHAR Planets[10] = L"Mercury";
    // Add string to combobox.
    SendMessage(hwnd_correct_shape_combobox, (UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)Planets);
dans la fonction:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
 
int WINAPI WinMain (HINSTANCE hinstance,
                    HINSTANCE hPrevInstance,
                    LPSTR     lpCmdLine, 
                    int       nCmdShow)
{
    HWND hwnd_correct_shape_combobox = CreateWindow(WC_COMBOBOX, TEXT(""),
        CBS_DROPDOWN | CBS_HASSTRINGS | WS_CHILD | WS_OVERLAPPED | WS_VISIBLE,
        xpos, ypos, nwidth, nheight, hwndParent, NULL, hinstance,
        NULL);
    TCHAR Planets[10] = L"Mercury";
    // Add string to combobox.
    SendMessage(hwnd_correct_shape_combobox, (UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)Planets);
}
la combobox ajoute bien le texte "Mercury",
mais si je tape le même code avec bien sur "hwnd_correct_shape_combobox" en variable globale :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
 
    TCHAR Planets[10] = L"Mercury";
    // Add string to combobox.
    SendMessage(hwnd_correct_shape_combobox, (UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)Planets);
en dehors de la fonction :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
 
int WINAPI WinMain (HINSTANCE hinstance,
                    HINSTANCE hPrevInstance,
                    LPSTR     lpCmdLine, 
                    int       nCmdShow)
la combobox reste vide....
Et j'aurais besoin que la combobox ajoute ce texte en dehors de WinMain