Resource Problem

This is a discussion on Resource Problem within the Windows Programming forums, part of the Platform Specific Boards category; I'm having a compiling problem with a resource. The entire program code was taken directly from http://winprog.org/tutorial/ and I'm getting ...

  1. #1
    Work in Progress..... Jaken Veina's Avatar
    Join Date
    Mar 2005
    Location
    Missouri. Go Imos Pizza!
    Posts
    256

    Resource Problem

    I'm having a compiling problem with a resource. The entire program code was taken directly from http://winprog.org/tutorial/ and I'm getting compiling errors on both the STYLE and EXSTYLE lines of the resource.
    Code:
    IDD_TOOLBAR DIALOGEX 0, 0, 98, 52
    STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
    EXSTYLE WS_EX_TOOLWINDOW
    CAPTION "My Dialog Toolbar"
    FONT 8, "MS Sans Serif"
    BEGIN
        PUSHBUTTON      "&Press This Button",IDC_PRESS,7,7,84,14
        PUSHBUTTON      "&Or This One",IDC_OTHER,7,31,84,14
    END
    The precompiled program works perfectly and when I comment the two lines out, It also works just fine (except the styles aren't there, of course). I'm using the Dev C++ compiler with the C language settings (I've switched to C++ and that makes no changes). And, of course, my project type is set to GUI, not Console or anything like that. Is the FAQ simply wrong or do my problems lie deeper?

    Thanks.

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    You could search you compiler's include folder for a header file that defines those styles and include it in your resource file.

  3. #3
    Work in Progress..... Jaken Veina's Avatar
    Join Date
    Mar 2005
    Location
    Missouri. Go Imos Pizza!
    Posts
    256
    Ahh. Not a bad idea. Hope there is one though.......

  4. #4
    Work in Progress..... Jaken Veina's Avatar
    Join Date
    Mar 2005
    Location
    Missouri. Go Imos Pizza!
    Posts
    256
    Well, I made a map of all the files included by windows.h (which is the only file I'm supposed to need to include) and then made a search and checked through the results. However, it wasn't until I had searched through each file until I realized I was searching for STYLE instead of DS_MODALFRAME and the rest.

    But now that I think about it, the error I was getting was a syntax error. And that wouldn't have to do with the definitions of DS_MODALFRAME and the rest. Any other ideas?

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    hmm I don't see any bad syntax.
    try adding these to your resource file
    Code:
    #define DS_MODALFRAME       0x80L
    #define WS_POPUP            0x80000000L
    #define WS_CAPTION          0x00C00000L
    #define WS_EX_TOOLWINDOW        0x00000080L

  6. #6
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,803
    Are you sure you are including <windows.h>? This works for me
    Code:
    #include <windows.h>
    #include "resource.h"
    
    //My Stuff Ignore :) 
    mainMenu MENU
    {
        POPUP "&File"
        {
            MENUITEM "&New", fileMenuNew
            MENUITEM "E&xit", fileMenuExit
        }
        POPUP "&Help"
        {
            MENUITEM "&About", helpMenuAbout
        }
    }
    
    helpDialog DIALOGEX 0, 0, 98, 52
    STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
    EXSTYLE WS_EX_TOOLWINDOW
    CAPTION "My Dialog Toolbar"
    FONT 8, "MS Sans Serif"
    BEGIN
        PUSHBUTTON      "&Press This Button",IDC_PRESS,7,7,84,14
        PUSHBUTTON      "&Or This One",IDC_OTHER,7,31,84,14
    END
    resource.h
    Code:
    #ifndef resource_h
    #define resource_h
    
    #define mainMenu 100
    #define fileMenuExit 101
    #define fileMenuNew 102
    #define helpMenuAbout 103
    #define helpDialog 200
    #define IDC_PRESS 201
    #define IDC_OTHER 202 
    
    #endif //resource_h
    Woop?

  7. #7
    Work in Progress..... Jaken Veina's Avatar
    Join Date
    Mar 2005
    Location
    Missouri. Go Imos Pizza!
    Posts
    256
    Yes, of course I'm including windows.h.

    Wait.....do #defines work in resources? cause earlier I used one in my resource and when I calledf that definition in my main function, imy compiler said it was undefined. I'm thinking this might mean that my compiler isn't inlcuding the resource(based on another project I was trying to make, not this one). If that's true then I've got a whole other problem.

    Hold on, I'll try defining those in my resource.h file....................

    Okay, all of them are defined already, so that's not the problem. Still getting the syntax error on both of those lines. It's bolding STYLE and EXSTYLE like it does with any other type identifier or test identifier (like int, char, if, for, etc). I wonder if it's just using an outdated syntax of STYLE and EXSTYLE. The Dev C++ compiler I'm using was linked to on your site. I wonder if anyone else who's using it could help me.

  8. #8
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Quote Originally Posted by Jaken Veina
    Yes, of course I'm including windows.h.

    Wait.....do #defines work in resources?
    Yes but they would be only visible from the resource file since resource files aren't included by source files. This has just ocured to me, you are adding your resource files to the project and not #include ing them right?

  9. #9
    Work in Progress..... Jaken Veina's Avatar
    Join Date
    Mar 2005
    Location
    Missouri. Go Imos Pizza!
    Posts
    256
    Ahh, that makes sense.

    Yes, but I'm not quite sure if it's working correctly in this project. The resource contains not only the dialog, but a menu as well. When I ran the program before with those two lines commented, it ran just the same, but the dialog simply did not have the specified styling. For some reason, when I run it now, the Message Box that's programmed to appead when the dialog fails, appears. Plus, the menu, which was also there before, is completely absent. My guess is that this is because the resource is no longer included correctly. But, either way, I still get syntax erros on those two lines. Plus, when I created a new project and compiled the source code from the tutorial's menu only example, it ran perfectly fine.

    ...............holy crap, I just noticed something..........I need to have windows.h included in my main code AND in my resource, don't I? Let me try that.............................................. ..Okay, someone hit me, please.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sorting out a resource manager
    By psychopath in forum Game Programming
    Replies: 1
    Last Post: 11-10-2008, 06:12 PM
  2. unmanaged resource
    By George2 in forum C++ Programming
    Replies: 2
    Last Post: 01-03-2008, 03:23 AM
  3. CreateProcess with Resource of executable, not the Filename
    By Ktulu in forum Windows Programming
    Replies: 4
    Last Post: 11-04-2006, 12:07 AM
  4. Resources with Dev C++ Problem (many simple problems)
    By Zeusbwr in forum Windows Programming
    Replies: 4
    Last Post: 04-06-2005, 11:08 PM
  5. beginner problem
    By The_Nymph in forum C Programming
    Replies: 4
    Last Post: 03-05-2002, 04:46 PM

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