1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Problem using Combobox control on modeless dialog boxes

Discussion in 'Win32' started by koushal, Feb 3, 2009.

  1. koushal

    koushal New Member

    Joined:
    Feb 3, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    I'm unable to use my mouse to select any item from a combobox control placed on a modeless dialog box. I can very well do it with the keyboard but there still is a problem.
    When I've dropped the combobox list down, I cannot move my main window (i.e. the modeless dialog).

    Here is my code:
    Code:
    #include <afxwin.h>
    #include <tchar.h>
    #include "resource.h"
    
    BOOL CALLBACK
    DlgProc(
        HWND hwnd,
        UINT message,
        WPARAM wParam,
        LPARAM lParam
        );
    
    int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                        PSTR szCmdLine, int iCmdShow)
    {
        MSG msg;
        HWND hDlg;
    
        hDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, DlgProc);
        if (NULL == hDlg)
        {
            MessageBox(NULL, _T("CreateDialog...FAILED."), 0, 0);
            return 0;
        }
    
        ShowWindow(hDlg, SW_SHOW);
        UpdateWindow(hDlg);
    
        while (GetMessage (&msg, NULL, 0, 0))
        {
            IsDialogMessage(hDlg, &msg);
        }
    
        return msg.wParam;
    }
    
    BOOL CALLBACK
    DlgProc(
        HWND hwnd,
        UINT message,
        WPARAM wParam,
        LPARAM lParam
        )
    {
        HWND hDlgCtrl;
        CComboBox cmbOb;
    
        switch (message)
        {
        case WM_INITDIALOG:
            hDlgCtrl = GetDlgItem(hwnd, IDC_CMB_TEST);
            cmbOb.Attach(hDlgCtrl);
    
            cmbOb.AddString("str 1");
            cmbOb.AddString("str 2");
            cmbOb.SetCurSel(0);
            cmbOb.Detach();
            return TRUE;
    
        case WM_CLOSE:
            DestroyWindow(hwnd);
            return TRUE;
    
        case WM_DESTROY:
            PostQuitMessage(0);
            return TRUE;
        }
    
        return FALSE;
    }
    
     

Share This Page