Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Win32 (http://www.go4expert.com/forums/win32/)
-   -   Problem using Combobox control on modeless dialog boxes (http://www.go4expert.com/forums/using-combobox-control-modeless-dialog-t16045/)

koushal 3Feb2009 18:15

Problem using Combobox control on modeless dialog boxes
 
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;
}



All times are GMT +5.5. The time now is 09:38.