Win32 API GUI problems

This is a discussion on Win32 API GUI problems within the Windows Programming forums, part of the Platform Specific Boards category; i got a problem on my hands: When i create a button with the following code: Code: hButton1 = CreateWindowEx(WS_EX_STATICEDGE, ...

  1. #1
    Registered User Cha0sBG's Avatar
    Join Date
    May 2009
    Posts
    7

    Win32 API GUI problems

    i got a problem on my hands:

    When i create a button with the following code:

    Code:
    hButton1 = CreateWindowEx(WS_EX_STATICEDGE, "Button", "Close", WS_CHILDWINDOW | BS_PUSHBUTTON 
    		| WS_VISIBLE, 130, 185, 50, 20, hwnd, NULL, hInstance, NULL);
    It uses the Windows XP Classic style.

    Trying to make it to Default op system skin with the following code:

    Code:
    #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' " \ "version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
    But it generates the following error :
    Code:
    Error	1	error C2017: illegal escape sequence	d:\c++ projects\phoenixloader\phoenixloader\mainapi.cpp	14
    Any suggestions ?

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,607
    >> " \ "
    I would remove that line continuation and make it one continuous string literal.

    gg

  3. #3
    Registered User Cha0sBG's Avatar
    Join Date
    May 2009
    Posts
    7
    Well bro ... that's the code i saw @ msdn library

    here is the link: Enabling Visual Styles

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,607
    If you would have actually tried what I suggested, you would have found your issue solved.
    Code:
    #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' "\
                            "version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
    //or
    #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
    //or
    #pragma comment(linker, \
                    "/manifestdependency:\"" \
                    "type='win32' " \
                    "name='Microsoft.Windows.Common-Controls' " \
                    "version='6.0.0.0' " \
                    "processorArchitecture='*' " \
                    "publicKeyToken='6595b64144ccf1df' " \
                    "language='*'\"")
    gg

  5. #5
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    Quote Originally Posted by Cha0sBG View Post
    Any suggestions ?
    Use wxWidgets instead.

  6. #6
    Registered User Cha0sBG's Avatar
    Join Date
    May 2009
    Posts
    7
    @Codeplug:
    with your code it compiled but all my controls desapeared -.-

  7. #7
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,854
    Quote Originally Posted by Cha0sBG View Post
    Code:
    hButton1 = CreateWindowEx(WS_EX_STATICEDGE, "Button", "Close", WS_CHILDWINDOW | BS_PUSHBUTTON 
    		| WS_VISIBLE, 130, 185, 50, 20, hwnd, NULL, hInstance, NULL);
    CreateWindowEx's hMenu param should contain the controls ID number (if you use the WS_CHILD style), you have set it to zero.

    If this is a common mistake yo have made with all controls you create it may be the cause.

    The controls ID must be unique (on a dlg basis) or they may not function correctly (like having the style applied to them).
    Depends on how a the control is called/identified by each msg handler (HWND or ID) as to which functionality works and which fails.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  8. #8
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    Controls disappearing sounds like the usual behaviour of forgetting to call InitCommonControls or InitCommonControlsEx. Have you called one of those functions? (The MSND page you link to additionally notes that you must call InitCommonControls(Ex) to enable visual styles.)
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Looking for free win32 gui (resource) editor
    By umen242 in forum Windows Programming
    Replies: 1
    Last Post: 05-22-2008, 03:49 AM
  2. Limitations on Win32 API functions
    By csonx_p in forum Windows Programming
    Replies: 5
    Last Post: 04-09-2008, 04:09 AM
  3. Win32 API help
    By 52Cent in forum Windows Programming
    Replies: 8
    Last Post: 01-23-2008, 09:24 AM
  4. Win32 API and MFC
    By loopshot in forum C++ Programming
    Replies: 6
    Last Post: 12-07-2004, 10:58 AM
  5. Win32 API
    By Liger86 in forum Windows Programming
    Replies: 2
    Last Post: 01-30-2003, 01:19 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21