Windows SDK General: How to register Windows Common Controls in a Win32 application?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1

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

Hybrid View

  1. #1
    ovidiucucu's Avatar
    ovidiucucu is offline Moderator/Reviewer Power Poster
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,058

    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()'


    Code:
    #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()
    {
      INITCOMMONCONTROLSEX iccex;
    
      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
      InitCommonControlsEx(&iccex);
    }
    
    int APIENTRY WinMain(HINSTANCE hInstance,
                         HINSTANCE hPrevInstance,
                         LPSTR     lpCmdLine,
                         int       nCmdShow)
    {
      RegisterCommonControls();
      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 05: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

This is a CodeGuru survey question.


Featured


HTML5 Development Center