Windows 7 Win32 API Dev Visual Styles difficulty

Discussion in 'Programming and Scripting' started by Silberling, Sep 29, 2012.

  1. Silberling

    Silberling New Member

    Joined:
    Sep 29, 2012
    Messages:
    4
    Likes Received:
    0
    Hi.

    I am working on a small and fast GUI wrapper for game and tool development. It has been a while that i worked with the win32 api.

    Everything works fine except of the displayed window elements. As you can see in the attached picture, the text looks like Win 3.x ^^.

    I applied a manifest like this one:
    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?><assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
      <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
        <security>
          <requestedPrivileges>
            <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
          </requestedPrivileges>
        </security>
      </trustInfo>
      <dependency>
        <dependentAssembly>
          <assemblyIdentity type="Win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="amd64" publicKeyToken="6595b64144ccf1df" language="*"/>
        </dependentAssembly>
      </dependency>
    </assembly>
    And included it in the RC file
    Code:
    ...
    #include <windows.h>
    #include <commctrl.h>
    #include <winuser.h>
    
    CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "Window.exe.manifest"
    ...
    Added the following code (part) to the core ui-element class:
    Code:
    class UIElement {
    ...
    
    protected:
        static INITCOMMONCONTROLSEX icc;
    
    
    public:
        UIElement() {
            ...
            // FIXME: Better way for that :-S
            if (! (UIElement::icc.dwSize > 0)) {
                UIElement::icc.dwSize = sizeof(UIElement::icc);
                UIElement::icc.dwICC = ICC_WIN95_CLASSES | ICC_STANDARD_CLASSES | ICC_COOL_CLASSES;
                if (! InitCommonControlsEx(&UIElement::icc)) {
                    MessageBox(NULL, TEXT("InitCommonControlsEx failed."), TEXT("Error"), MB_OK | MB_ICONINFORMATION);
                }
            }
            ...
        }
    
    ...
    }
    I really don't know how to get a nice Win7 UI, but this Win 3.x like style ^^.

    Help is appreciated.

    Thanx

    Silberling

    EDIT:
    Oh i forgot:
    TDM-GCC 4.7.1-tdm64-1, not Visual Studio
     

    Attached Files:

    #1 Silberling, Sep 29, 2012
    Last edited: Sep 29, 2012
  2. Silberling

    Silberling New Member

    Joined:
    Sep 29, 2012
    Messages:
    4
    Likes Received:
    0
    MVP in MSDN and a german forum helped:

    I was told i have to specify fonts always on my own.

    Code:
    [COLOR=#000000][FONT=Courier New]HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); [/FONT][/COLOR]
    [COLOR=#000000][FONT=Courier New]SendMessage(hwnd, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));[/FONT][/COLOR]
    This helped.
     
  3. AceInfinity

    AceInfinity Senior Member
    Microsoft MVP

    Joined:
    Aug 12, 2011
    Messages:
    159
    Likes Received:
    11
    I'm assuming what is happening is that it's taking fonts based on system default, so yes, then you'd have to specify your own.

    TDM-GCC is a compiler suite, Visual Studio is an IDE, there can't be a comparison :topsy_turvy:
     

Share This Page

Loading...