GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 06-Feb-2005, 14:16
ubergeek ubergeek is offline
Regular Member
 
Join Date: Jan 2005
Posts: 775
ubergeek is a jewel in the roughubergeek is a jewel in the roughubergeek is a jewel in the rough
Angry

#including resource file causing window procedure to be undeclared???


ok, this is getting really annoying. i have this program that, so far, just displays a window with an edit control in the middle and exits when you press escape. it doesn't even have a menu. however, i am trying to add a menu now, and therein lies my frustrating problem. when i add the include line at the top of my program after the inclusion of my header file and windows.h but before my function declarations, like this:
CPP / C++ / C Code:
#include <windows.h> //for all winapi calls
#include "geekedit.h" //id definitions
#include "geekedit.rc" //menu -- why is it causing MainWndProc to be undeclared???

LRESULT CALLBACK MainWndProc(HWND, UINT, WPARAM, LPARAM); //window procedure
bool MainWndCtrlProc(HWND, WORD, WORD, HWND); //processes WM_COMMAND messages from main window
LONG FAR PASCAL MainWndEditCtrlSubProc(HWND, UINT, WPARAM, LONG); //subclassing process for main window edit control
WNDPROC OldEditCtrlWndProc; //original main window edit control window procedure
void createEditControl(HWND); //make the main window's edit control, set its font, and subclass it
void checkSave(HWND); //called on program quit -- if the file has been modified since the last save, prompts for saving
void saveOptions(HWND); //saves options to .ini file when preferences window is closed
and then try to compile, i get these errors:
Quote:
Originally Posted by Dev-C++
3 P:\C++\GeekEdit\geekedit.cpp In file included from geekedit.cpp
4 P:\C++\GeekEdit\geekedit.rc syntax error before numeric constant
P:\C++\GeekEdit\geekedit.cpp In function `int WinMain(HINSTANCE__*, HINSTANCE__*, CHAR*, int) ':
31 P:\C++\GeekEdit\geekedit.cpp `MainWndProc' undeclared (first use this function)
(Each undeclared identifier is reported only once for each function it appears in.)
P:\C++\GeekEdit\geekedit.cpp In function `LRESULT MainWndProc(HWND__*, unsigned int, unsigned int, long int)':
91 P:\C++\GeekEdit\geekedit.cpp `LRESULT MainWndProc(HWND__*, unsigned int, unsigned int, long int)' used prior to declaration
P:\C++\GeekEdit\Makefile.win [Build Error] [geekedit.o] Error 1
This seems to be saying that something in the resource file is making my window procedure, MainWndProc, fail to be declared (even though it is declared in plain sight on the line below the include statement).

can anyone help? the attachment mechanism is not working for me right now, so my complete source files are posted here:
http://www.geocities.com/zapguyd/dow...ekedit.cpp.txt
http://www.geocities.com/zapguyd/dow...geekedit.h.txt
http://www.geocities.com/zapguyd/dow...eekedit.rc.txt

things of note:
1. if i comment out #include "geekedit.rc" then there are no errors.
2. this program is a work in progress, so there may be things in the code that are not commented out--these are things that are buggy right now, or that i have replaced with something else and have not gotten around to deleting yet. right now i am just trying to figure out this one problem; everything worked before i tried to include the resource file.
3. the compiler errors seem to indicate that there is also something wrong with the
CPP / C++ / C Code:
ID_MAINWNDMNU MENU
line in my resource file. i suspect that this may be the root of the problem. does anyone know the correct syntax that i should be using here? (i did try adding DISCARDABLE to the end of that line, but it didn't change anything)
4. i realize that the line that will actually add the menu to my window class is commented out. again, i am just trying to fix this problem, then i will move on.
  #2  
Old 07-Feb-2005, 07:00
Dr. Evil Dr. Evil is offline
Member
 
Join Date: Oct 2004
Location: Netherlands
Posts: 120
Dr. Evil will become famous soon enough
You don't include resource files, use pragma, like so:

CPP / C++ / C Code:
#pragma resource "resource.res"

Or link it to your object file(s) when compiling.
Last edited by Dr. Evil : 07-Feb-2005 at 07:33.
  #3  
Old 07-Feb-2005, 13:47
ubergeek ubergeek is offline
Regular Member
 
Join Date: Jan 2005
Posts: 775
ubergeek is a jewel in the roughubergeek is a jewel in the roughubergeek is a jewel in the rough
but my resource file is not geekedit.res, it is geekedit.rc
i replaced #include "geekedit.rc" with #pragma resource "geekedit.rc" and i get these errors:
Quote:
Originally Posted by Dev-C++
8 P:\C++\GeekEdit\geekedit.rc [Resource error] parse error
P:\C++\GeekEdit\Makefile.win [Build Error] [GeekEdit_private.res] Error 1

apparently i do not have the correct format for a menu in a resource file

i would be greatly obliged if someone could help with this latest quagmire ;-)
  #4  
Old 07-Feb-2005, 14:39
ubergeek ubergeek is offline
Regular Member
 
Join Date: Jan 2005
Posts: 775
ubergeek is a jewel in the roughubergeek is a jewel in the roughubergeek is a jewel in the rough
nevermind

apparently i don't even have to use the #pragma, just adding the resource file to the dev-c++ project does it

also, i didn't have the values for the menu items #defined....doh!

anyway, it works, thanks dr. evil
 
 

Recent GIDBlogLast Week of IA Training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
CD burner wont burn!! robertli55 Computer Hardware Forum 1 18-Jun-2004 10:53
Yet another CD burner problem: Lite-On LSC-24082K Erwin Computer Hardware Forum 1 22-May-2004 11:28
Re: Programming Techniques WaltP C Programming Language 0 09-Mar-2004 23:56
[Tutorial] Standard I/O aaroncohn C Programming Language 20 27-Feb-2004 21:07

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 01:35.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.