Subclassing a subclass of CDialog, for cross-platform compilation

Hi people,

I've been working on porting an app from PC to Mac. What I'm trying to
do, is separate out the PC specific components into it's own subclass.
So there are the PC specific functions like PCAppDlg::OnBtnClicked1,
and mac specific functions like MacAppDlg::BlaBlaBla. Of course the Mac
subclass doesn't compile on the PC, and the same the other way around.
I've had to write my own CDialog wrapper for Mac but that's another
story.

Now anyhow, this leads me to a question. How to subclass a subclass?
Specifically, how does the message maps work? Will there be any
problems with subclassing from a subclass? What about the system
defined maps, like for OnInitDialog, or OnPaint?

Let's say the classes hierarchy is like this:

CDialog
AppDlg
PCAppDlg

Both AppDlg and PCAppDlg will actually have some MFC message mapping
right now, unfortunately :( It's too much work to put all the message
mapping into the PCAppDlg, especialyl considering both Mac and PC
versions will need to call some functions like OnDeleteSelectedItem.

So, will the message mapping be possible? Any special considerations I
must make when subclassing a subclass of CDialog?

It's a lot of work I must do! But I've done bigger things on this
project already so it's not too much for me.

0
1/4/2007 8:17:56 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
643 Views

Similar Articles

[PageSpeed] 10

Take a look at my essay on subclassing dialogs on my MVP Tips site.  I do this all the
time and it works perfectly well.
					joe

On 4 Jan 2007 12:17:56 -0800, collection60@googlemail.com wrote:

>Hi people,
>
>I've been working on porting an app from PC to Mac. What I'm trying to
>do, is separate out the PC specific components into it's own subclass.
>So there are the PC specific functions like PCAppDlg::OnBtnClicked1,
>and mac specific functions like MacAppDlg::BlaBlaBla. Of course the Mac
>subclass doesn't compile on the PC, and the same the other way around.
>I've had to write my own CDialog wrapper for Mac but that's another
>story.
>
>Now anyhow, this leads me to a question. How to subclass a subclass?
>Specifically, how does the message maps work? Will there be any
>problems with subclassing from a subclass? What about the system
>defined maps, like for OnInitDialog, or OnPaint?
>
>Let's say the classes hierarchy is like this:
>
>CDialog
>AppDlg
>PCAppDlg
>
>Both AppDlg and PCAppDlg will actually have some MFC message mapping
>right now, unfortunately :( It's too much work to put all the message
>mapping into the PCAppDlg, especialyl considering both Mac and PC
>versions will need to call some functions like OnDeleteSelectedItem.
>
>So, will the message mapping be possible? Any special considerations I
>must make when subclassing a subclass of CDialog?
>
>It's a lot of work I must do! But I've done bigger things on this
>project already so it's not too much for me.
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15972)
1/5/2007 12:36:11 AM
Joseph M. Newcomer wrote:
> Take a look at my essay on subclassing dialogs on my MVP Tips site.  I do this all the
> time and it works perfectly well.
> 					joe

Thanks a lot!!

> On 4 Jan 2007 12:17:56 -0800, collection60@googlemail.com wrote:
>
> >Hi people,
> >
> >I've been working on porting an app from PC to Mac. What I'm trying to
> >do, is separate out the PC specific components into it's own subclass.
> >So there are the PC specific functions like PCAppDlg::OnBtnClicked1,
> >and mac specific functions like MacAppDlg::BlaBlaBla. Of course the Mac
> >subclass doesn't compile on the PC, and the same the other way around.
> >I've had to write my own CDialog wrapper for Mac but that's another
> >story.
> >
> >Now anyhow, this leads me to a question. How to subclass a subclass?
> >Specifically, how does the message maps work? Will there be any
> >problems with subclassing from a subclass? What about the system
> >defined maps, like for OnInitDialog, or OnPaint?
> >
> >Let's say the classes hierarchy is like this:
> >
> >CDialog
> >AppDlg
> >PCAppDlg
> >
> >Both AppDlg and PCAppDlg will actually have some MFC message mapping
> >right now, unfortunately :( It's too much work to put all the message
> >mapping into the PCAppDlg, especialyl considering both Mac and PC
> >versions will need to call some functions like OnDeleteSelectedItem.
> >
> >So, will the message mapping be possible? Any special considerations I
> >must make when subclassing a subclass of CDialog?
> >
> >It's a lot of work I must do! But I've done bigger things on this
> >project already so it's not too much for me.
> Joseph M. Newcomer [MVP]
> email: newcomer@flounder.com
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm

0
1/5/2007 2:11:47 AM
Reply:

Similar Artilces:

Compile Error ??
I used some code from Allen B. and it works fine in Access 2K3. However, it will not compile in 2K7. It fails at .Edit. Member or data object not found. What might I do to change/alter to comply with 2K& standards? Any help appreciated. Function UpdateGroupAlias() On Error GoTo UpdateGroupAlias_Err Dim strErrMsg As String 'For Error Handling Dim strSQL As String Dim intAlias As Integer Dim bytLevel As Byte Dim lngMakeID As Long Dim bytMaxColumns As Byte Dim pbytNumColumns As Byte Dim db As Database Dim rs As Recordset s...

CDialog in Win32
Hello Everybody, I have created a Win32 application. Now I added one Dialog thru resource.I have created class for this dialog, derived from CDialog. Now I want to call this dialog using , DoModal. But it is crashing.why? #include "MyDialog.h" in WinMain() MyDialog dlg; dlg.DoModal(); it is crashing in AfXWIN1.INL _AFXWIN_INLINE HINSTANCE AFXAPI AfxGetInstanceHandle() { ASSERT(afxCurrentInstanceHandle != NULL); it is crashing when it is doing DoModal. Am using MFC shared library. reg spicy_kid2000 wrote: > > Hello Everybody, > > I have created a Win32 applic...

Subclassing
Hello, Im very new to c++ programming so pardon me if this is a dumb question and my bad english. I made a subclass from CListBox. I want to handle all the list controls derived from this class on one function, for example, void CListBox_SC::OnRButtonUp(UINT nFlags, CPoint point) { ..... } on this function I want to manage the OnRButtonUp event, and with a switch or if statement, select the code to execute. The following does work: SetCurSel(ItemFromPoint(point, ifp)); but the following comparison is never true, (IDC_LST_TIPO is a resource for one of the ListBoxes) UINT currLst = It...

Cross browser question
Hi, I built a website using Pub 2003. It is now on the internet. www.anovelmillion.com I have been made aware through a few people that some links and formatting are not working in Firefox. I have read through the comments here that there is bad cross browser support. Basically about 30% of people who have looked at my site are using firefox. I am wondering 2 things: Firstly, does anyone here have different types of browsers that they could check out my site on and tell me how bad it is in each type of browser. Secondly, what recommendations would you have for me given how good/bad i...

Custom Drawing CEdit : Subclassing
Hello experts, My objective is simple, but I'm not entirely sure what needs tweaking. I am using MSVC 6, and I would like to subclass the CEdit box so that it appears as the color-picker editbox of a PropertyGrid. There is a color box followed by three values. Like this: [###] 255; 192; 192 Where ### is just a color box representation of the value. So thus far, I've made a masked CEdit box, where I can edit the numbers (or click a button that visually sets the numbers from a different window), and I'm happy with that - but what I would like to do next is to subclass the dra...

Microsoft CRM Platform Error Report:
In CRM 1.2 When trying to create a custom view for Accounts, I get a dialog that pops up saying: Microsoft CRM Platform Error Report: Error Description: The statement has been terminated. Error Details: Detail on this error have not been proivded by the platform. Error Number: 0x80040E2F Source File: Not available Line Number: Not available Query String: /tools/vieweditor/viewManager.aspxobjectTypeCode=1&mode=new I've never had this problem before. I've added plenty of custom views. It happens on the Web Client, on both client and CRM server machines. I tried looking up...

max speed compilation failed.
I have a simpe win32 dll. when I make an optimization/max speed compilation, it always says: Compiling... Command line error D2016 : '/ZI' and '/O2' command-line options are incompatible if I use other options in optimization, it can compile. I wonder if I remove /ZI /O2, is it still in max speed ? or how can I get a max speed compilation ? thanks. /* Call Library source file */ #include "extcode.h" #include <ole2.h> #include <stdio.h> #include <conio.h> #include <winbase.h> void GetSeeThrough(unsigned char *aLine,int *seeThrough,int aL...

Help with subclassing a RichEditCtrl
Hi folks, I could use some help. As a side project I am trying to write a DLL that will extend the functionality of an existing application that I do not have source code for, i.e., some autocompletion functionality, word lookup, etc. In the actual DLL, I am going to have to inject it into the existing app and then use FindWindow or something like that to subclass the existing RichEditCtrl. I need to be able to process the WM_CHAR and WM_KEYDOWN messages only. I started out by creating my own sample project using a RichEditCtrl in my project to code my object. I've now moved everythin...

Problem after Cross Site move to Exchange 2003
I have moved a few mailboxes from an Exchange 5.5 site to an Exchange 2003 Site within the same Org and when users from the old E55 site try and send messages to the users who were moved they receive the following NDR but the message seems to be delivered anyway. The recipient could not be processed due to congestion in the message transfer service Any help is greatly appreciated, JoeAHM Issue was resolved it was due to an old non-existant server making the mta queues get backed up. "JoeAHM" <joseph.gonzalez@americanhm.com> wrote in message news:OjOOrB1AHHA.4060@TK2...

Compiling MC file in Unicode format
Hi, I have an urgent problem here with regards to MC files. I have created a .mc file which contain messages in English, Japanese, Chinese, etc. According to the example given on Microsoft website (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tools/tools/sample_message_text_file.asp), the file is stored in Unicode (UTF-8) format, so if I view the file using a Unicode-compatible editor, I can actually see the messages in its respective languages. Now, according to Microsoft documentation, I should be able to now compile the .mc file and then generate different lan...

WM_CREATE for a subclass
Hi All, I am fairly new to C++, although I have developed OO windows applications in the past using CTD and Power Builder. I am developeing an edit class based on a CEdit. I am trying to trap the WM_CREATE message to modify the style of the window (i.e. to make is multiline). For some reason the control does not appear to be getting the WM_CREATE message ( or at least it is not implementing the handler I have for it). At present I create an edit control on a form and the Subclass the edit. This appears to work as my user defined menu is used and my color modifications appear as requir...

Calculate areas from a cross section chart??
Can you, and if so, how do you calculate an area off of a cross section chart???:confused: -- nated7777 ------------------------------------------------------------------------ nated7777's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=31684 View this thread: http://www.excelforum.com/showthread.php?threadid=513810 See http://www.stfx.ca/people/bliengme/ExcelTips/AreaUnderCurve.htm for finding area under curve If an approximation is OK here is the old chemist's way (pre-computer): Plot graph and print Cut out the cross section (A) and cut out a rectang...

CDialog::DoModal
hi! i have a modal login dialog which calls a function (let's say "GetMsg") in its OnInitDialog function. the function "GetMsg" opens a modal dialog with a progress bar showing the data transfer progress for getting the logindata from a server via socket connection. the socket resides in a separate uithread. the problem is, that the (modal) dialog with the progress bar on it does not get a parent wnd on initialisation so it takes the application's main wnd as parent and causes an EnableWindow of the application's main wnd when it is closed. after this the OnI...

Subclassing CWinThread
I created a subclass of CWinThread - no big deal! Now, what I would like to do is use that subclass as a base class for a couple of other, more specialized classes. How can I do this? If I create a subclass as a generic C++ class, then I'm running into the assertion, "Invalid Address specified to RtlValidateHeap( 00940000, 0042DBA0 )" when I post the quit message to the thread. I assume this might have something to do with the virtual/non-virtual constructor combination of the MFC class and the generic C++ class. Any thoughts? Create more subclasses of CWinThread, then ...

Cross-Site Mailbox move error
I have a mixed-mode Exchange environment consisting of Exchange 5.5 servers and Exchange 2003 servers. I am attempting to move a couple of mailboxes out of one site from a 5.5 server to a different site and onto a 2003 server (both sites have 5.5 and 2003 servers deployed). This has worked fine for me in the past! However, I believe someone has changed something and now I receive the following error when the mailbox move task looks at the environment to verify the Consistency Adjuster patch is installed on my 5.5 servers: "Unable to find a responsive Exchange 5.5 server in the s...

CDialog in static library
Hi all, I have been working on this seemingly simple problem for hours now and don't see where I go wrong. The situation is as follows: I have a static library project (Visual Studio 7) in which I wish to display a dialog to the user of the client application (i.e. the application linking to the library). The client application is dialog based. To narrow down the problem, I have defined the following method in one of the library classes: CLibraryClass::doit(CWnd* parentWnd) { AFX_MANAGE_STATE(AfxGetStaticModuleState( )); AFX_MODULE_STATE* ms = AfxGetStaticModuleState(); ...

Subclassing TreeView
I created a class derived from a TreeView (ShellTree) that displays the Shell directory structure . I changed the LeftView class so that it is derived from my ShellTree class, and everything works as expected, except I cannot add any TreeView specific message handlers to my LeftView class any more eg. NM_DBLCLICK. Basically in a nutshell what i want to do is display the directory name (which is stored in a variable in the ShellTree class) when the LeftView is Double clicked Check out http://www.codeproject.com/treectrl/enumdeskclones.asp Which isn't perfect.. but is a good star...

How do you do cross worksheet formulae's
I've just started writing basic addition and multiplication formulae etc. for multiple cells. I want to know how to write formulae to d this across worksheets (I think thats what they are called - the tab at the bottom?) For exaple, how would I add A1 on sheet1 to A1 o sheet2 -- Liam Green ----------------------------------------------------------------------- Liam Greene's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=897 View this thread: http://www.excelforum.com/showthread.php?threadid=26786 Liam, if you formula is in sheet one, =A1+Sheet2!A1, if you f...

CDialog::Create Problems
I am writing an MFC dll program to be used as a plugin for a C application. I need for my program to open up a new dialog box for user input based on user interaction in the host application. The end user clicks a button in the host app, to which I've assigned a callback function. The function gets called properly, and that function looks like the following: if (!strcmp((char *)userData, "Show a Dialog")){ theApp.PopDialog(); } When debugging, I can see that the PopDialog function gets fired properly. void CpluginApp::PopDialog(void) { AFX_MANAGE_STATE(AfxGetStat...

Subclassing a subclass of CDialog, for cross-platform compilation
Hi people, I've been working on porting an app from PC to Mac. What I'm trying to do, is separate out the PC specific components into it's own subclass. So there are the PC specific functions like PCAppDlg::OnBtnClicked1, and mac specific functions like MacAppDlg::BlaBlaBla. Of course the Mac subclass doesn't compile on the PC, and the same the other way around. I've had to write my own CDialog wrapper for Mac but that's another story. Now anyhow, this leads me to a question. How to subclass a subclass? Specifically, how does the message maps work? Will there be any p...

compilation prob in VC++ 6 evnironment after installing XP SP2 PSD
Hi All, I have Win 2000 and VS 6. I cut the CD from image version of WinXP SP2 Platform SDK available at http://www.microsoft.com/downloads/details.aspx?FamilyID=9be921b3-585e-47d9-bcc1-980879b69b34&displaylang=en After installing the above Platform SDK I also registred the PSDK Directories with VS by clicking on Start-->Programmes-->Microsoft Platform SDK for Windows XP SP2-->Visual Studio Registration-->Register PSDK directories with Visual Studio. After that when I am trying to rebuild my VC++ apllication it give me following two compilation errors. 1. C:\Program Files\...

Xml Serializing subclass problem
Hi guys. I've come across a problem when I tried to serialize a class into xml, only to discover that the parent class's XML Serialization properties weren't included in the output xml. Actually, the class I'm serializing is two steps down in the inheritance ladder. It's got a parent class which also has a parent class :( All those classes in the hierarchy are Xml Serializable, and I'd think that it should be obvious that all attributes/properties of the parents should be serialized for any given subclass, no ? Here's the two classes, subclass first, parent class...

Cross Tab Query in Report?
I am trying to create a report based off my cross tab query. Idynamically assigned the fields on the report and used VBA to load theappropriate data into the field.My issue involves where there are too many columns to fit on onepage. I have a page footer (confidential info and the page number).The Report footer has fields that summarize the columns.I would like to have the columns that do not fit on the one page to beput on a separate page with the main column (first name) repeated(like Excel). It would be nice if the page footer appears on thispage also.I have looked through all the postin...

CDialog
So I wrote this little CDialog-derived app but when I launch it it is not immediately visible on the screen, I have to go to Taskbar and select it to get to see it. How can I fix it? Is it not visible or simply being hidden behind some window. Perhaps you have a window which always stays topmost (or something on those lines). ----- Ajay Kalra ajaykalra@yahoo.com ...

Subclassing problem???
Hi there, I've got: LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){ switch(uMsg){ case WM_NCACTIVATE: if((BOOL)wParam==FALSE){ DefWindowProc(hwnd, uMsg, wParam, lParam); CreateText(hwnd); return TRUE; } case WM_NCPAINT: DefWindowProc(hwnd, uMsg, wParam, lParam); CreateText(hwnd); break; } DefWindowProc(hwnd, uMsg, wParam, lParam); } void CreateText(HWND hwnd){ HDC hDC = GetWindowDC(hwnd); int x,y; RECT rc1,rc2; GetWindowRect(hwnd, (LPRECT)&rc2 ); x = GetSystemMetrics(SM_CXSIZE) + GetSystemMetrics(SM_CXBORDE...