Thread: resource problem/question

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    157

    resource problem/question

    i was just writing a test app in dev c++ and what i did was, of course, started and chose to have the WinAPI project. so then i looked in the folder in which i created the project file (.dev) and also there was a file called "rsrc.rc" which i believe is a resource file, rigth?

    so i was planning on making a dialog to call from the main window and of course i need a resource file to put my dialog's scripting in it to get it out. so i wasnt sure if i should use this "already created" resource file or create a new one, so i just used this "rsrc.rc" file.

    i looked in the resource and this was the first and only line in it:
    Code:
    500 ICON MOVEABLE PURE LOADONCALL DISCARDABLE "C:/Dev-C++/Bin/Mainicon.ico"
    and then i just figured i would insert my dialog "code" in the resource file and after i finished that it looked like this:
    Code:
    500 ICON MOVEABLE PURE LOADONCALL DISCARDABLE "C:/Dev-C++/Bin/Mainicon.ico"
    
    OptionsDlg DIALOG 0, 0, 200, 200
    CAPTION "Quizer Options"
    STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
    {
     PUSHBUTTON "Okay", IDD_OKAY, 32, 40, 30, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
    }
    and then i hit to build the resource and i got this error:

    C:\DEV-C_~1\Bin\windres: C:\\Progs\\WinAPI\\TestAPI\\rsrc.rc:5: parse error

    i'm not sure what to do from here. did i use the wrong .rc file? should i have created my own? if so, then why was this .rc file initially there? and what is this error "parse" and the fix to it?

    thanks!

  2. #2
    Registered User
    Join Date
    Nov 2002
    Posts
    157
    now i finally got the resource to build but i'm having more troubles. in my code i successfully get to this line and execute the DialogBox() function as such
    Code:
    DialogBox(hInst, "OptDlg", hwnd, (DLGPROC)OptDlgProc);
    but it doesn't bring up my dialog and i have no idea why not!
    here is the resource file that defines the dialog
    Code:
    #include <windows.h>
    #include "resources.h"
    
    OptDlg DIALOG 18, 18, 142, 192
    CAPTION "Quizer Options"
    STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
    {
     DEFPUSHBUTTON "Okay", IDD_OKAY, 32, 50, 30, 14,
                   WS_CHILD | WS_VISIBLE | WS_TABSTOP
    }
    what am i doing wrong? shouldnt it bring up the dialog? oh, and the "resources.h" file only contains a "#define IDD_OKAY 1" for the dialog's button. what's the problem with my code?

    thanks!

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    try adding WS_VISIBLE (or using a ShowWindow(hWnd,SW_SHOW); prahaps in WM_CREATE or WM_INIT.)

    put a break point on the first switch in OptDlgProc() to ensure it is actually creating teh dialog.
    "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

  4. #4
    Registered User
    Join Date
    Nov 2002
    Posts
    157
    i had put the MessageBox() function before the switch in the dialog proc and when i ran the program, the message box didn't come up so i guess that the procedure wasn't executed and im' not sure, but i guess that means the dialog wasn't created.

    any idea why this happened?

    thanks!

  5. #5
    Registered User
    Join Date
    Nov 2002
    Posts
    157
    nevermind, i got it working. it turns out that the compiler/linker only recognizes the resource file (.rc) that it created itself (rsrc.rc) and not the one i created myself. so i just moved the dialog definition to rsrc.rc and then it worked.

    thanks!

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, 07:12 PM
  2. unmanaged resource
    By George2 in forum C++ Programming
    Replies: 2
    Last Post: 01-03-2008, 04:23 AM
  3. CreateProcess with Resource of executable, not the Filename
    By Ktulu in forum Windows Programming
    Replies: 4
    Last Post: 11-04-2006, 01:07 AM
  4. JPEG Resource
    By dragunsflame in forum Windows Programming
    Replies: 2
    Last Post: 04-08-2003, 10:07 PM
  5. Serial Communications in C
    By ExDigit in forum Windows Programming
    Replies: 7
    Last Post: 01-09-2002, 10:52 AM