Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create win7 style button using CreateWindowEx [duplicate]

Possible Duplicate:
winapi CreateWindowEx -> create button with user system styles?

Hi, I am kinda new to WinAPI and C++ and I am using Visual Studio 2010. I want to create some buttons in the main window. So there are two questions:

1) can I use a dialog window created with resource editor as a main window so that I wouldnt have to create all controls "by hand" in the "post-WM_CREATE message" section?

2) (If I cant use resource script made window with buttons as a main window) When I "hand make" button using CreateWindowEx like this:

case WM_CREATE:

    {
    HFONT buttonFont = CreateFont(-11, 0, 0, 0, 400, FALSE, FALSE, FALSE, 1, 400, 0, 0, 0, fontButtonFont);
    HWND bMainOK = CreateWindowEx(
        0, 
        WC_BUTTON, 
        szOkButton, 
        WS_VISIBLE | WS_CHILD | WS_TABSTOP | BS_PUSHBUTTON, 
        24, 200, 75, 23, 
        hWnd, 
        0, 
        hInst, 
        0);
    SendMessage(bMainOK, WM_SETFONT, (WPARAM)buttonFont, FALSE);
    }

I get very ugly oldstyle button. How do I make it look like Win7/Vista button? Or better how do I make it behave as system style setting says (when using XP get XP style button, when using Vista get Vista style button etc.)?

Thanks

like image 306
Smejki Avatar asked Mar 21 '26 19:03

Smejki


1 Answers

You need to link a manifest to your app that specifies v6 common controls. Websearch will do the rest for you.

like image 65
David Heffernan Avatar answered Mar 24 '26 10:03

David Heffernan