Author Topic: Windows resource files.  (Read 9872 times)

sethjackson

  • Guest
Windows resource files.
« on: September 12, 2005, 07:26:33 pm »
In my project I (did) have two .rc files. When I compile and run the menu doesn't show up and my about dialog won't work.
If I have one .rc file with both the menu and dialog code it works perfectly. This was not a problem with Dev-C++ (I had two .rc files) but maybe this is a problem with the resource compiler.

Here is what didn't work.

menu.rc
Code: [Select]
#include <windows.h>
#include "main.h"

IDM_MENU MENU
{
    POPUP "&File"
    {
MENUITEM "&New\tCtrl+N", IDM_FILE_NEW
MENUITEM "&Open\tCtrl+O", IDM_FILE_OPEN
MENUITEM "&Save\tCtrl+S", IDM_FILE_SAVE
MENUITEM "&Save as...", IDM_FILE_SAVEAS
MENUITEM SEPARATOR
MENUITEM "&Page Setup...", IDM_FILE_PAGESETUP
MENUITEM "&Print\tCtrl+P", IDM_FILE_PRINT
MENUITEM SEPARATOR
MENUITEM "&Exit\tAlt+F4", IDM_FILE_EXIT
    }
   
    POPUP "&Edit"
    {
    MENUITEM "&Undo\tCtrl+Z", IDM_EDIT_UNDO
    MENUITEM SEPARATOR
    MENUITEM "&Cut\tCtrl+X", IDM_EDIT_CUT
    MENUITEM "&Copy\tCtrl+C", IDM_EDIT_COPY
    MENUITEM "&Paste\tCtrl+V", IDM_EDIT_PASTE
    MENUITEM "&Delete\tDel", IDM_EDIT_DELETE
    MENUITEM SEPARATOR
    MENUITEM "&Select all\tCtrl+A", IDM_EDIT_SELECTALL   
    }
   
    POPUP "&Search"
    {
    MENUITEM "&Find\tCtrl+F", IDM_SEARCH_FIND
    MENUITEM "&Find next\tF3", IDM_SEARCH_FINDNEXT
    MENUITEM "&Find previous\tShift+F3", IDM_SEARCH_FINDPREVIOUS
    MENUITEM SEPARATOR
    MENUITEM "&Replace\tCtrl+R", IDM_SEARCH_REPLACE
    }
   
    POPUP "F&ormat"
    {
    MENUITEM "&Word Wrap", IDM_FORMAT_WORDWRAP
    MENUITEM "&Font...", IDM_FORMAT_FONT
    }
   
    POPUP "&Help"
    {
MENUITEM "&Contents\tF1", IDM_HELP_CONTENTS
MENUITEM "&Search", IDM_HELP_SEARCH
MENUITEM "&Using help", IDM_HELP_HELP
MENUITEM SEPARATOR
MENUITEM "&About...", IDM_HELP_ABOUT
    }
}


dialog.rc
Code: [Select]
#include <windows.h>
#include "main.h"

#ifndef IDC_STATIC
#define IDC_STATIC -1
#endif

IDD_ABOUT DIALOG 0, 0, 239, 66
STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Text Editor 0.1.1.1"
FONT 8, "MS Sans Serif"
{
DEFPUSHBUTTON "&OK", IDOK, 174, 18, 50, 14
PUSHBUTTON "&Cancel", IDCANCEL, 174, 35, 50, 14
GROUPBOX "About this program...", IDC_STATIC, 7, 7, 225, 52
CTEXT "This is a simple text editor written in C++.\r\n"
      "The GUI was created with the Win32 API.",
      IDC_STATIC, 16, 18, 144, 33
}


Here is the code I used that worked.

resources.rc
Code: [Select]
#include <windows.h>
#include "main.h"

#ifndef IDC_STATIC
#define IDC_STATIC -1
#endif

IDM_MENU MENU
{
    POPUP "&File"
   {
MENUITEM "&New\tCtrl+N", IDM_FILE_NEW
MENUITEM "&Open\tCtrl+O", IDM_FILE_OPEN
MENUITEM "&Save\tCtrl+S", IDM_FILE_SAVE
MENUITEM "&Save as...", IDM_FILE_SAVEAS
MENUITEM SEPARATOR
MENUITEM "&Page Setup...", IDM_FILE_PAGESETUP
MENUITEM "&Print\tCtrl+P", IDM_FILE_PRINT
MENUITEM SEPARATOR
MENUITEM "&Exit\tAlt+F4", IDM_FILE_EXIT
    }
   
    POPUP "&Edit"
    {
    MENUITEM "&Undo\tCtrl+Z", IDM_EDIT_UNDO
    MENUITEM SEPARATOR
    MENUITEM "&Cut\tCtrl+X", IDM_EDIT_CUT
    MENUITEM "&Copy\tCtrl+C", IDM_EDIT_COPY
    MENUITEM "&Paste\tCtrl+V", IDM_EDIT_PASTE
    MENUITEM "&Delete\tDel", IDM_EDIT_DELETE
    MENUITEM SEPARATOR
    MENUITEM "&Select all\tCtrl+A", IDM_EDIT_SELECTALL   
    }
   
    POPUP "&Search"
    {
    MENUITEM "&Find\tCtrl+F", IDM_SEARCH_FIND
    MENUITEM "&Find next\tF3", IDM_SEARCH_FINDNEXT
    MENUITEM "&Find previous\tShift+F3", IDM_SEARCH_FINDPREVIOUS
    MENUITEM SEPARATOR
    MENUITEM "&Replace\tCtrl+R", IDM_SEARCH_REPLACE
    }
   
    POPUP "F&ormat"
    {
    MENUITEM "&Word Wrap", IDM_FORMAT_WORDWRAP
    MENUITEM "&Font...", IDM_FORMAT_FONT
    }
   
    POPUP "&Help"
    {
MENUITEM "&Contents\tF1", IDM_HELP_CONTENTS
MENUITEM "&Search", IDM_HELP_SEARCH
MENUITEM "&Using help", IDM_HELP_HELP
MENUITEM SEPARATOR
MENUITEM "&About...", IDM_HELP_ABOUT
    }
}

IDD_ABOUT DIALOG 0, 0, 239, 66
STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Text Editor 0.1.1.1"
FONT 8, "MS Sans Serif"
{
DEFPUSHBUTTON "&OK", IDOK, 174, 18, 50, 14
PUSHBUTTON "&Cancel", IDCANCEL, 174, 35, 50, 14
GROUPBOX "About this program...", IDC_STATIC, 7, 7, 225, 52
CTEXT "This is a simple text editor written in C++.\r\n"
      "The GUI was created with the Win32 API.",
      IDC_STATIC, 16, 18, 144, 33
}

« Last Edit: September 12, 2005, 07:28:40 pm by sethjackson »

Offline Vampyre_Dark

  • Regular
  • ***
  • Posts: 255
  • Hello!
    • Somewhere Over The Rainbow...
Re: Windows resource files.
« Reply #1 on: September 12, 2005, 08:39:22 pm »
If you have a control that needs to be loaded first, it won't work. Even though it appears to compile. Say you put a rich edit control in there. If you didn't load the richedit dll into your program first, the dialog will never display.

If this is the case, here is the control list at MSDN. Find your control, and find the requirements.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/indivcontrol.asp
C::B Wishlist
~BOYCOTT THE EVIL YELLOW BOXES~

sethjackson

  • Guest
Re: Windows resource files.
« Reply #2 on: September 12, 2005, 08:59:53 pm »
Let me clarify this is just part of my project I have created a window already before I load the menu or dialog box. I think there is a linking problem somewhere.

Offline grv575

  • Official tester
  • Regular
  • ***
  • Posts: 381
Re: Windows resource files.
« Reply #3 on: September 16, 2005, 05:22:49 am »
check the option to show the full commandline.  then see that both .rc files are on the rc.exe part of the commandline.  if it's just one (and something like private.rc) then I think CB may create a single .rc file and #include each of the .rc files in the project.  So check that this private.rc file is correct.