CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1
  1. #1
    Join Date
    Feb 2003
    Iasi - Romania

    Windows SDK General: How to register Windows Common Controls in a Win32 application?

    Q: How to register Windows Common Controls in a Win32 application?

    A: You must register the control classes from the common control DLL ('comctl32.dll'):

    1. include 'commctrl.h' header file;
    2. link your project to 'comctl32.lib', e.g. using '#pragma' comment
    3. call 'InitCommonControlsEx()'

    #include <windows.h>
    #include <commctrl.h>
    #include <resource.h>
    BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
    void RegisterCommonControls();
    #pragma comment(lib, "comctl32.lib")
    void RegisterCommonControls()
      iccex.dwSize = sizeof(INITCOMMONCONTROLSEX); 
      iccex.dwICC  = ICC_TREEVIEW_CLASSES  // tree view and tooltip control classes
                      | ICC_LISTVIEW_CLASSES; // list view and header control classes
                               // see INITCOMMONCONTROLSEX in MSDN for a complete list
    int APIENTRY WinMain(HINSTANCE hInstance,
                         HINSTANCE hPrevInstance,
                         LPSTR     lpCmdLine,
                         int       nCmdShow)
      INT_PTR nRet = DialogBox(hInstance,                    // handle to module
                               MAKEINTRESOURCE(IDD_DIALOG1), // dialog box template
                               NULL,                         // handle to owner window
                               DialogProc);                  // dialog box procedure
      return 0;

    Last edited by Andreas Masur; July 24th, 2005 at 04:05 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.