User forums > Using Code::Blocks

Windows resource files.

(1/1)

sethjackson:
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: ---#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
    }
}


--- End code ---

dialog.rc

--- Code: ---#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
}


--- End code ---

Here is the code I used that worked.

resources.rc

--- Code: ---#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
}


--- End code ---

Vampyre_Dark:
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

sethjackson:
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.

grv575:
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.

Navigation

[0] Message Index

Go to full version