1

I am writing an editor for my project by using scintilla editor component. The editor is for an internal scripting language, having all the basic functionalities like cut,copy, paste etc. As one of the feature I am also providing searching functionality. When a user presses the Ctrl+F ideally it should show this dialog:

Search

But because of some reason CreateDialog API is failing, but the GetLastError returns 0. Also please note that I am using Windows Common Controls.

>>Code for creating dialog

HWND CreateFindDialog(HINSTANCE hInstance, HWND hWnd, UINT id)
{
    HWND dlgHwnd = ::CreateDialog(hInstance, MAKEINTRESOURCE(id), hWnd, FindDlgProc);
    if(dlgHwnd == NULL)
    {
        wchar_t buf [100];
        wsprintf (buf, L"Error x%x", GetLastError ());
        MessageBox (0, buf, L"CreateDialog", MB_ICONEXCLAMATION | MB_OK);
    }

    return(dlgHwnd);
}

BOOL CALLBACK FindDlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
    switch(Msg)
    {
    case WM_INITDIALOG:
        MessageBox (0, L"in", L"CreateDialog", MB_ICONEXCLAMATION | MB_OK);
        return TRUE;

    case WM_COMMAND:
        switch(wParam)
        {
        case IDOK:
            EndDialog(hWndDlg, 0);
            return TRUE;
        }
        break;
    }

    return FALSE;
}

>>Resource entry for the dialog

IDD_FIND DIALOGEX 0, 0, 304, 90
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Find Text"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
    LTEXT           "Search String",IDC_STATIC,7,7,44,8
    EDITTEXT        IDC_FIND_TEXT,7,20,217,14,ES_AUTOHSCROLL
    DEFPUSHBUTTON   "Find Next",IDC_FIND_NEXT,243,7,54,16,WS_DISABLED
    PUSHBUTTON      "Find Previous",IDC_FIND_PREVIOUS,243,26,54,16,WS_DISABLED
    PUSHBUTTON      "Close",IDCANCEL,243,45,54,16
    CONTROL         "Match case",IDC_FIND_CASE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,42,52,10
    CONTROL         "Match whole word",IDC_FIND_WHOLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,55,74,10
    CONTROL         "Wrap around",IDC_FIND_WRAP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,116,42,58,10
    CONTROL         "<a>Goto Replace (Ctrl+H)</a>",IDC_FIND_OPENREPLACE,
                    "SysLink",WS_TABSTOP,218,70,79,13
END

The only page talking about the same problem is this: CreateDialog Failed, but GetLastError return 0. I have checked the solution mentioned there but in my project I am linking to comctl32.lib. I have also checked my resource file and the resource header. The dialog entry seems to be proper.


>>Common control initialization
 INITCOMMONCONTROLSEX iccx;
 iccx.dwSize = sizeof(INITCOMMONCONTROLSEX);
 iccx.dwICC = ICC_WIN95_CLASSES|ICC_COOL_CLASSES|ICC_BAR_CLASSES|ICC_USEREX_CLASSES;
 if (!InitCommonControlsEx(&iccx))
    return;

Any suggestion/idea would be helpful. Thanks.

Favonius
  • 13,959
  • 3
  • 55
  • 95
  • how did you initialize comctl32? Which version did you manifest? – David Heffernan Sep 04 '11 at 06:24
  • I ask because [SysLink](http://msdn.microsoft.com/en-us/library/bb760706(v=vs.85).aspx) requires v6 comctl32. – David Heffernan Sep 04 '11 at 06:32
  • @David Heffernan: Please see my updated answer. If it helps, I am using windows vista withs service pack 1, visual studio 2008 and latest release of scintilla. thanks. – Favonius Sep 04 '11 at 06:37
  • which comctl32 version? Do you have the v6 app manifest? – David Heffernan Sep 04 '11 at 06:46
  • @David Heffernan: Sorry i didn't answer your question earlier. My app is picking up comctl version 5.82. I have used this small code snippet to find it out http://www.davekb.com/browse_programming_tips:get_version_of_comctl32_dll:txt – Favonius Sep 04 '11 at 07:13
  • @David Heffernan: Oh. I get it now :). Thanks. After removing the `SysLink` it is working fine. Could you please suggest how to use the `comctl` 6.0 version. Also, please put it as answer. I will mark it accepted. Thanks. – Favonius Sep 04 '11 at 07:19

1 Answers1

3

The SysLink control requires v6 of comctl32 as explained by the documentation. You are linking to v5 comctl32 and I suspect this is the cause of your error. You need to include the v6 comctl32 application manifest.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490