Hello,
I've started learning how to make simple GUI programs in cpp using theforgers tutorial. However I was going to add XP style to my program and I found a page that showed me exacly how to do it for VC++ 6. The problem when I had added the lines in my resource.h file and my res.rc file was that my program refused to start. The window didn't show up. When I removed the line in the resourcefile it showed up again but with the old 95/98/ME/2000 style. What should i do to make it work.

This is my .rc file:

//Microsoft Developer Studio generated resource script.
//
#include "resource.h"


#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#define APSTUDIO_HIDDEN_SYMBOLS
#include "windows.h"
#undef APSTUDIO_HIDDEN_SYMBOLS


/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE DISCARDABLE 
BEGIN
    "resource.h\0"
END

2 TEXTINCLUDE DISCARDABLE 
BEGIN
    "#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
    "#include ""windows.h""\r\n"
    "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
    "\0"
END

3 TEXTINCLUDE DISCARDABLE 
BEGIN
    "\0"
END

#endif    // APSTUDIO_INVOKED


MANIFEST_RESOURCE_ID    24      MOVEABLE PURE   "projekt1.exe.manifest"

/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//

IDD_MAIN DIALOG DISCARDABLE  0, 0, 207, 156
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Simply refreshed"
FONT 8, "MS Sans Serif"
BEGIN
    LTEXT           "Username: ",IDC_STATIC,3,8,140,8
    LTEXT           "Password: ",IDC_STATIC,3,22,140,8
    EDITTEXT        IDC_USERNAME,40,7,70,12,ES_AUTOHSCROLL
    EDITTEXT        IDC_PASSWORD,40,21,70,12,ES_PASSWORD


    PUSHBUTTON      "Login",IDC_LOGIN,113,7,50,14
    PUSHBUTTON      "&Remove",IDC_REMOVE,150,47,50,14
    PUSHBUTTON      "&Clear",IDC_CLEAR,150,63,50,14
    LTEXT           "This item was hhghghghghghgghhghgadded\njj",IDC_STATIC,7,141,66,16
    CTEXT           "-",IDC_SHOWCOUNT,77,141,32,8
    LTEXT           "times",IDC_STATIC,114,141,17,8
END


/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//

#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE 
BEGIN
    IDD_MAIN, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 200
        VERTGUIDE, 145
        VERTGUIDE, 150
        TOPMARGIN, 7
        BOTTOMMARGIN, 149
    END
END
#endif    // APSTUDIO_INVOKED

#endif    // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////

and my resource.h file:

//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by ctl_one.rc
//

#define MANIFEST_RESOURCE_ID            1

#define IDC_STATIC -1
#define IDD_MAIN                        101
#define IDC_TEXT                        1000
#define IDC_NUMBER                      1001
#define IDC_LIST                        1002
#define IDC_LOGIN                       1003
#define IDC_CLEAR                       1004
#define IDC_REMOVE                      1005
#define IDC_SHOWCOUNT                   1007 
#define IDC_USERNAME                    1006
#define IDC_PASSWORD                    1008


// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        102
#define _APS_NEXT_COMMAND_VALUE         40001
#define _APS_NEXT_CONTROL_VALUE         1009
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif

Thanks.

You haven't posted the manifest file.
Did you InitCommonControlsEx() ?

My manifest file:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> 
<assemblyIdentity 
	version="1.0.0.0" 
	processorArchitecture="X86" 
	name="Zhorn.Styles.Styles" 
	type="win32" 
/> 
<description>Styles - demonstrate XP styles</description> 
<dependency> 
<dependentAssembly> 
<assemblyIdentity 
	type="win32" 
	name="Microsoft.Windows.Common-Controls" 
	version="6.0.0.0" 
	processorArchitecture="X86" 
	publicKeyToken="6595b64144ccf1df" 
	language="*" 
/> 
</dependentAssembly> 
</dependency> 
</assembly>

I added InitCommonControlsEx(); at a random location but the compiler said it wasn't defined. What library is InitCommonControlsEx() in?

InitCommonControlsEx (see the table at the bottom)
Try putting it in your WM_CREATE handler.

I still get an error:

Main.cpp In function `BOOL DlgProc(HWND__*, UINT, WPARAM, LPARAM)': 
Main.cpp `InitCommonControlsEx' undeclared (first use this function) 
  (Each undeclared identifier is reported only once for each function it appears in.) 
 Makefile.win [Build Error]  [Main.o] Error 1

My includes:

#include <windows.h>
#include <commctrl.h>
#include "resource.h" 
using namespace std;

I added the WM_CREATE in the Message switch

case WM_CREATE:
    InitCommonControlsEx();
break;

I still get an error:

Main.cpp In function `BOOL DlgProc(HWND__*, UINT, WPARAM, LPARAM)': 
Main.cpp `InitCommonControlsEx' undeclared (first use this function) 
  (Each undeclared identifier is reported only once for each function it appears in.) 
 Makefile.win [Build Error]  [Main.o] Error 1

In your project, #define _WIN32_IE to at least 0x0300 .

InitCommonControlsEx() takes a pointer to a INITCOMMONCONTROLSEX struct. You are not using the function correctly ...

I added the WM_CREATE in the Message switch

case WM_CREATE:
    InitCommonControlsEx();
break;

I added
#define _WIN32_IE 0x0301
in resources.h and created the struct

INITCOMMONCONTROLSEX InitCtrlEx;
            InitCtrlEx.dwICC = ICC_STANDARD_CLASSES;
            InitCtrlEx.dwSize=sizeof(INITCOMMONCONTROLSEX);
            InitCommonControlsEx(&InitCtrlEx);

but the INITCOMMONCONTROLSEX seems to be undeclared:

Main.cpp `INITCOMMONCONTROLSEX' undeclared (first use this function)

resource.h is not the place to define _WIN32_IE. Do it instead above the #includes, i.e.

#define _WIN32_IE 0x0301
#include <windows.h>
#include <commctrl.h>

Or alternatively in the project's configuration.

Thank you it works now! : D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.