? Message Maps in HPP Files

Hi,

I'm trying to simplify my reusable code by putting everything for some stuff into self-contained, single files.  For example if I
wrote a a couple of simple classes that I can use in lots of programs, I put all the code for each class in single HPP files instead
of splitting them among separate CPP and H files.

This works for some of my things but I am having trouble with one of them.  I have a class that adds some custom functionality to
the CListCtrl.  It works fine if I have it split, but if I use a single file I get "already defined in the OBJ file" errors for the
message map (which I need to handle some of the list control notifications).  If I remove the message map it compiles but then I
don't get notifications.

I tried creating a simple class that was nothing more than an empty class based on CListCtrl.  I then used the ClassWizard to add a
notification to it and VS created a CPP file which is exactly what I want to avoid.

What can I do to fix this?  Is there a way to write self-contained, single-file classes that have message maps?


Thanks a lot.

-- 
Alec S.
news -.- alec -@- synetech -.- cjb -.- net


0
Alec
9/19/2005 3:47:40 AM
vc.mfc 33608 articles. 0 followers. Follow

5 Replies
368 Views

Similar Articles

[PageSpeed] 18

Not surprising; a message map is a declaration, not a function prototype.  So every file
that includes the .hpp file will get its own private copy of the message map, and of
course this produces the effect you see.

If you have common functionality, the more common solution is to create a class derived
from CLIstCtrl that incorporates the common behavior and derive subclasses from that for
the specialization.
				joe

On Sun, 18 Sep 2005 23:47:40 -0400, "Alec S." <@> wrote:

>Hi,
>
>I'm trying to simplify my reusable code by putting everything for some stuff into self-contained, single files.  For example if I
>wrote a a couple of simple classes that I can use in lots of programs, I put all the code for each class in single HPP files instead
>of splitting them among separate CPP and H files.
>
>This works for some of my things but I am having trouble with one of them.  I have a class that adds some custom functionality to
>the CListCtrl.  It works fine if I have it split, but if I use a single file I get "already defined in the OBJ file" errors for the
>message map (which I need to handle some of the list control notifications).  If I remove the message map it compiles but then I
>don't get notifications.
>
>I tried creating a simple class that was nothing more than an empty class based on CListCtrl.  I then used the ClassWizard to add a
>notification to it and VS created a CPP file which is exactly what I want to avoid.
>
>What can I do to fix this?  Is there a way to write self-contained, single-file classes that have message maps?
>
>
>Thanks a lot.
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
9/20/2005 2:58:54 PM
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message news:nq80j1puigc27leftlsoe4chaam79f5j3p@4ax.com...


> Not surprising; a message map is a declaration, not a function prototype.  So every file
> that includes the .hpp file will get its own private copy of the message map, and of
> course this produces the effect you see.


Right but this happens even if the HPP file is included only once.


> If you have common functionality, the more common solution is to create a class derived
> from CLIstCtrl that incorporates the common behavior and derive subclasses from that for
> the specialization.

What I'm trying to do is to extend CListCtrl by basing a class on it, then make it drop-in so that it handles everything itself; I
want to minimize the amount of extra code that the user has to write to make it work.  I also want to put it all in a single file if
possible.


-- 
Alec S.
news -.- alec -@- synetech -.- cjb -.- net



0
Alec
9/21/2005 1:48:03 AM
I do this all the time, and I've never had to repartition the code as you are suggesting.
You need a header file that defines the class, and an implementation file that does the
implementation, and it would be impossible to do this in "one" file.  The only thing a
user has to write is to change the declaration from CListCtrl to CYourListCtrl, and doing
a #include.  This doesn't strike me as overly complex.
					joe

On Tue, 20 Sep 2005 21:48:03 -0400, "Alec S." <@> wrote:

>"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message news:nq80j1puigc27leftlsoe4chaam79f5j3p@4ax.com...
>
>
>> Not surprising; a message map is a declaration, not a function prototype.  So every file
>> that includes the .hpp file will get its own private copy of the message map, and of
>> course this produces the effect you see.
>
>
>Right but this happens even if the HPP file is included only once.
>
>
>> If you have common functionality, the more common solution is to create a class derived
>> from CLIstCtrl that incorporates the common behavior and derive subclasses from that for
>> the specialization.
>
>What I'm trying to do is to extend CListCtrl by basing a class on it, then make it drop-in so that it handles everything itself; I
>want to minimize the amount of extra code that the user has to write to make it work.  I also want to put it all in a single file if
>possible.
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
9/21/2005 4:10:05 PM
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message news:7b13j11hb7sjdkdtrkvjp6ma51l7apcien@4ax.com...
> I do this all the time, and I've never had to repartition the code as you are suggesting.
> You need a header file that defines the class, and an implementation file that does the
> implementation, and it would be impossible to do this in "one" file.  The only thing a
> user has to write is to change the declaration from CListCtrl to CYourListCtrl, and doing
> a #include.  This doesn't strike me as overly complex.

Well thanks for your "help" but I already know all this.  I have already done all that with my class and was just hoping to reduce
the number of files by putting each class in their own single, self-contained files.  I was asking if it was possible and all that
was nesecessary was to simply say "no"-like someone else did-instead of condescending _your "all-knowing", holiness_.


-- 
Alec S.
news -.- alec -@- synetech -.- cjb -.- net


0
Alec
9/21/2005 5:38:49 PM
This seems an odd approach, given that everyone knows that you need two files, and this
does not represent an undue burden on the end user.  It would not have occurred to me that
using two files even presented a problem.
				joe

On Wed, 21 Sep 2005 13:38:49 -0400, "Alec S." <@> wrote:

>"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message news:7b13j11hb7sjdkdtrkvjp6ma51l7apcien@4ax.com...
>> I do this all the time, and I've never had to repartition the code as you are suggesting.
>> You need a header file that defines the class, and an implementation file that does the
>> implementation, and it would be impossible to do this in "one" file.  The only thing a
>> user has to write is to change the declaration from CListCtrl to CYourListCtrl, and doing
>> a #include.  This doesn't strike me as overly complex.
>
>Well thanks for your "help" but I already know all this.  I have already done all that with my class and was just hoping to reduce
>the number of files by putting each class in their own single, self-contained files.  I was asking if it was possible and all that
>was nesecessary was to simply say "no"-like someone else did-instead of condescending _your "all-knowing", holiness_.
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
9/21/2005 10:29:52 PM
Reply:

Similar Artilces:

#Delete Mark in Bound Memo filed
I have form that has bound memo field, sometime, no sure how it happen, the memo filed is filled with #Delete. My application is a stand alone program. Kindly advise what can cause this and how to avoid it from happening. -- TS Lim When was the last time you performed a compact and repair? Is you db split? Does each user have their own copy of the front-end? Please checkout http://www.granite.ab.ca/access/corruptmdbs.htm http://www.granite.ab.ca/access/corruption/symptoms.htm http://office.microsoft.com/en-ca/access/HA011865661033.aspx - No very helpful but directly from MS ...

Isinteg Warning Message Question
I ran isinteg -pri -test alltests. I came up with 506 warnings. There are basically 4 types of warnings. They are below. Are these something I need to worry about? What should I do? thanks stewart sschwartz@nal.usda.gov ================================== Warning: MsgFolder 165 (Fid=0001-0000000D1864, Mid=0001- 0000000D559D, Inid=0001-000000F33436): PR_READ_RECEIPT_REQUESTED(0029000B) prop in Messages table and MsgFolder table do not match. Warning: MsgFolder 4 (Fid=0001-0000086DC911, Mid=0001- 00000436F972, Inid=0001-000004A583F1): Error JET_errRecordNotFound seeking to INID for this ...

CSV File Problem
Can any one explain why the following problem occurs please? A colleague has a small list of data which is a csv file exported from SQL. Column One is a serial number from 1 to 29. Column 2 is a number of transactions which have occurred.(it should look like example A below in Excel) 1 475 1,475 2 1732 21,732 3 1670 31,670 4 2176 42,176 5 608 5,608 6 1579 61,579 7 43101 743,101 8 54512 854,512 9 51258 951,258 10 61050 1,061,050 A B If I double click on the csv file, it opens in Excel but c...

CFile (delete file)
How can I delete all files that end with ".temp" in some folder? CFile::Remove remove unlink -- cheers, Alok Gupta Blogs: http://wdevs.com/thatsalok "Petar Popara" <my.fake@mail.net> wrote in message news:Op6#URKfFHA.2644@TK2MSFTNGP09.phx.gbl... > > How can I delete all files that end with ".temp" in some folder? > > SHFileOperation() will and it supports wildcards! DeleteFile() will operate on one file at a time. "Petar Popara" <my.fake@mail.net> wrote in message news:Op6%23URKfFHA.2644@TK2MSFTNGP09.phx.gbl... > >...

Opening an *.MSG file with it's respective attachment.
Hello, The file *.MSG is a message file. This can be viewed by any editor, like Notepad. However, when there's an attachment to it, we see garbage. Is there a way to open the attachments present inside the *.MSG files ? Thank you Yes, by opening it with Outlook. -- Roady [MVP] www.sparnaaij.net Microsoft Office and Microsoft Office related News Also Outlook FAQ, How To's, Downloads and more... Tips of the month: -Create your own fully customized Toolbar -Creating a Classic View in Outlook 2003 Subscribe to the newsletter to receive news and tips & tricks in your mailbox!...

Can't open 2005 data file after reinstalling Money 2005
I am experiencing a recurring problem. I have had to reinstall Windows XP and MS Money 2005. I am now unable to open my previously converted 2005 file or restore any backup version. I consistently get the following error message: "Money cannot locate filename or cannot open it, possibly because it is a read-only file, you do not have permission to change it, or your disk drive is write- protected. If you have chosen the correct file and it cannot be accessed, you will need to click OK and then Restore your most recent backup file." Any help or thoughts would be greatly ap...

import a 123 file
My excel version cannot open a Lotus 123 file. Is there an import feature to move the data from Lotus 123 to Excel? Thanks No, you need to convert the file either from Lotus 123 or get commercial converter -- Regards, Peo Sjoblom "Frank" <Frank@discussions.microsoft.com> wrote in message news:59B55F98-4C79-4917-928B-F1B309660730@microsoft.com... > My excel version cannot open a Lotus 123 file. Is there an import feature > to > move the data from Lotus 123 to Excel? > Thanks > > ...

Where is the cache files folder located for windows media player?
Does windows media player have a cache files folder? Where is the cache files folder located for windows media player? Or how do I find the cache files folder for windows media player? Thank You for your Help. Bob Background info: I have a desktop AMD 4400+ 64X2 4GB memory 320GB HD(way bigger than I need) Acer computer (AM3100-U3201A) I purchased new February 2008 running 32-bit MS Vista Home Premium SP2 box. I use MS auto updates. I think it has onboard shared memory for video and sound. My ISP is Comcast 12mbps with Motorola SURFboard SB5101 Cable Modem direct to...

Messages Cut off
A recipient receives forwarded mail messages that are cut off in random locations throughout the email. Outlook 2000 with latest SP. Any ideas? ...

Interface not registered message
when i try to send a e-mail message through outlook, i get the message interface not registered ? and then can't even save message. can anyone tell me why ? ...

Public Folder link to Excel File
Hi - I have a user that claims that he had a shortcut to a spreadsheet "in his public folders" at his old job. Obviously, he's an end user that may or may not know what he's talking about.... I'm trying to figure out the best way to accomodate him. He basically wants an Excel file stored on a shared folder to be available to all user as either a shortcut, or a link in the public folders (can't post to a folder as he will be updating the sheet regularly). When a user clicks on the shortcut/link, it would just launch Excel and display the file. Anybody have any ideas...

Outlook Hangs Reading Messages
I am running Windows XP Pro & Outlook 2003 via POP3 & Symantec AV I had to reinstall everything on my pc and now find when I double click an email outlook hangs for roughly a minute and then it finally opens, I have tried a data compact, reinstalling outlook and creating a new pst then importing but it still happens Does anyone have any ideas? It's driving me mad Thanks Daz Try deleting and recreating the profile as one of your steps in troubleshooting: http://www.howto-outlook.com/Faq/newprofile.htm -- K. Orland Thoughts lead on to purposes; purposes go forth in action; ...

Outlook rule to move read message from Blackberry
I have Outlook configured with a Blackberry server and want to set up a rule to mange messages marked as read: For example. 1. I'm away from the office, Outlook is closed. 2. I read an email on my Blackberry, which marks the message "read" 3. When I return to the office and open Outlook I want to: a. Apply a rule to my inbox that states: If message is marked as read, move to folder "read messages" b. All unread messages will remain in the inbox. I'm a heavy user of rules but I can't find a way to identify "read" messages. Any thoughts? view360@gm...

Opening pub files created with older Publisher versions #2
I have just upgraded to Publisher 2003 from 2000 and am having trouble with pub files sent to me for our chuch newsletter which is using Publisher 97 The text is not wrapping around graphics boxes. Can I fix this? I really don't want to go back to Pub 200 Thank Richard this is caused by Publisher 97 not been printer independent. Even if you went back to Publisher 2000, unless you have the identical font versions and printer driver you would have issues with formatting. It sounds like the person sending you the file has a garbage HP inkjet printer. Get them to install the HP5P laser p...

Renaming Partial File Names
Is it possible to rename part of a file name? (almost like a find and replace) My database pulls in the excel file names from a directory, with it's subfolders and contents as well. Every file begins with "Kay Form". Kay no longer works in our department, and I'd like to run a loop that replaces "Kay Form" with "Featured Track". I don't know how to do a partial replace though. Thank you in advance! -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access/201001/1 Checkout the Replace function. I...

Duplicate Messages
I have just upgraded from Office 2000 to Office XP. Ever since, i have been receiving duplicate email messages. Every time i do a send/receive, about 80% of my emails arrive twice (exactly the same ID, time, date etc.) I have got some rules running but these are necessary. Any ideas anyone. Thanks ...

printing imported gif files in Excel
When printing gif file with transparent background on the grey(25%) background of Excel non-transparent part of the picture has white border around it. Is there any way to prevent it? Thank you in advance... Tim ...

unknown .edb file
I have error messages in the log files that references a corrupt database named C:\Program Files\exchsrvr\Exchangeserver_Outlook.edb. "Outlook" is the name of the server. The problem is that this database is not listed in any of the Mail Stores or Public stores. I want to run the repair utilities on it, but since I'm not sure what it is used for, I don't know how I can restore it if the repair goes bad. Does anyone know what this is used for or how I can determine that myself? BTW, the database always has a current time stamp, so I assume that it is used by something....

Copying dbx files from a CDR back into Outlook
My computer was recently hijakced and I had to reinstall everything. I did however save all of my folders in Outlook onto a CD Rom and I do not know how to transfer them back so I can use them. Also I had an animated version of outlook where you could choose loads of diffent stationery and I cannot seem to find that upgrade anaywhere. Can you help me? Tee <tsahai33@hotmail.com> wrote: > My computer was recently hijakced and I had to reinstall > everything. I did however save all of my folders in > Outlook onto a CD Rom and I do not know how to transfer > them back so...

Forwarded messages are not being sent
One of our users is trying to setup his account to forward all messages to his yahoo account. We setup a rule that says keep a copy in his inbox and forward a copy to his yahoo account. The yahoo copy never gets out and message tracking says it is submitted to the categorizer but never gets any farther. What do we need to do? By default rule-based forwards to external recipients are disabled. To change this, go to Exchange System Manager, Global Settings, Internet Message Formats.. There, you can either enable this for all domains (*), or be specific and create a separate policy f...

Ctrl+D not working on outlook messages
Any idea why? alltimefav wrote: > Any idea why? And what are you expecting to happen? "alltimefav" wrote in message news:a95c52df-a387-4a8f-bf9d-269ff485451f@i29g2000prf.googlegroups.com... > Any idea why? So instead of hitting Ctrl+D to delete an item, what happens when the item is selected and you hit the Del key, or the "X" toolbar button, or right-click on the item and select Delete? Did you really expect a detailed response for such a vague question? You didn't even bother to say what "not working" means, like the item does not get delete...

DB_Backup.MDB file has appeared beside DB.MDB.
I have a local DB.MDB which accesses a DATA.MDB on a network drive. I use a user-level security file. It has been working AOK for a year or so. Yesterday one of the users reported an error dialog when attempting to open the DB.MDB (unfortunately the wording of the dialog was not captured!) After this 'event', the database started working correctly once again. The result was a DB_Backup.MDB file appeared beside the DB.MDB. Any ideas? That backup file is created when ACCESS "crashes" during use..... -- Ken Snell <MS ACCESS MVP> "Andrew (UGL)&quo...

SUTA state message on Pay Code Integration
I'm having trouble importing pay codes that are based on another code, such as Sick and Vacation. These records get rejected with the error message "pay code 'V' requires a SUTA state". I have a SUTA state in the Emp Maint window and the HOURLY pay code already exists and contains a SUTA state. I tried mapping the SUTA State code in my file and even tried using a Constant value in Destination mapping but these codes will not import. I can go into the Pay Code Maintenance window and add these codes manually with no problem. What am I missing? ...

Archiving Outlook.pst files to Novell Netware file server
Hi all We are trying to perform a manual Outlook inbox archive which we are tryingto save to a Novell file server - but it dowsn't work. Any ideas why? (works fine on the MS2000 server but we don't have the space for everyone) We are currently running Outlook 2003 and the Novell file server is 4.8.3 Any help would be appreciated Thanks!! kwan <kevin.kelly@levittbernstein.co.uk> wrote: > We are trying to perform a manual Outlook inbox archive which we are > tryingto save to a Novell file server - but it dowsn't work. Any ideas > why? (works fine on the MS2000 s...

Sorting by file extension in a worksheet
Hello, I have an excel worksheet which has a list of file names from a directory and various stats about each file. I need to be able to sort them by the file extension. Eg. c:\documents\folderA\picture1.eps c:\documents\folderB\document.doc I would like to sort them by the ".eps" extension. I have tried using the Data,Sort menu and something like *?*.eps as the criteria. But am obvisouly missing something. Any help would be most appreciated. Thanks Karl You could use a helper column to extract just the extension then include this in your sort range and sort on the helper col...