Novice Question - Is my dialog based MFC app done correctly?

Ok, firstly, sorry for the very general question!

Basically, I have coded a program using MFC. It is Dialog Based and consists 
of some textfields and a few buttons. My program is called DCP and the App 
Wizard created a DCP.cpp and DCPDlg.cpp files for me (and a few others).

The bulk of the functionality of my program is written in the DCPDlg.cpp 
file - is this correct? For example, when I created a button and clicked on 
it in the resource (dialog) view it automatically puts a function for it in 
the DCPDlg.cpp file i.e.

void CDCPDlg::OnButtonPrint() 
{
// Do some stuff here
}

I have never had to touch the DCP.cpp file. My question is really, should 
all the 'work' get done in the DCP file, or is it ok to do the 'work' in the 
DCPDlg.cpp file? I mean, does the Document View Architecture (coding 
convention thing) apply to simple Dialog based apps?

Sorry if this seems obvious. Thanks for any info.

David






0
David4882 (672)
10/3/2005 11:01:01 AM
vc.mfc 33608 articles. 0 followers. Follow

4 Replies
414 Views

Similar Articles

[PageSpeed] 28

All dialog code should go within dialog files (CPCDlg.cpp / h), all 'MFC 
application' code in the CPC.cpp/h

-- 
- Mark Randall
http://zetech.swehli.com

"Those people that think they know everything are a great annoyance to those 
of us who do"
    Isaac Asimov

"David++" <David@discussions.microsoft.com> wrote in message 
news:BD857C6C-F8A9-48E5-AC1A-C4CD5C892464@microsoft.com...
> Ok, firstly, sorry for the very general question! 


0
yr (150)
10/3/2005 11:17:36 AM
>The bulk of the functionality of my program is written in the DCPDlg.cpp 
>file - is this correct?

David,

Yes - if the dialog interactions are most likely the bulk of your
application.

>I have never had to touch the DCP.cpp file. My question is really, should 
>all the 'work' get done in the DCP file, or is it ok to do the 'work' in the 
>DCPDlg.cpp file? I mean, does the Document View Architecture (coding 
>convention thing) apply to simple Dialog based apps?

Doc/View doesn't generally apply to a simple dialog application. On
the other hand, if it's a logical split for your application, there's
no reason you shouldn't apply your own modularity.

If you really wanted a SDI doc/view dialog presentation, perhaps you
ought to use an SDI app with a CFormView as the view?

Dave Lowndes
-- 
MVP VC++ FAQ: http://www.mvps.org/vcfaq
0
davidl7375 (2060)
10/3/2005 11:22:06 AM
Hi folks,

Thanks for your answers. It seems that the the standards by which we code an 
MFC app in Dialog mode is reasonably flexible and dependent on the 
application at hand. I guess a level of 'common sense' comes into the 
equation here. Hopefully then my app is ok after all as most of my 
functionality does occur in the dialog (phew, wipe sweat from brow)

Thanks for quick responses.

Best Regards,
David

"David Lowndes" wrote:

> >The bulk of the functionality of my program is written in the DCPDlg.cpp 
> >file - is this correct?
> 
> David,
> 
> Yes - if the dialog interactions are most likely the bulk of your
> application.
> 
> >I have never had to touch the DCP.cpp file. My question is really, should 
> >all the 'work' get done in the DCP file, or is it ok to do the 'work' in the 
> >DCPDlg.cpp file? I mean, does the Document View Architecture (coding 
> >convention thing) apply to simple Dialog based apps?
> 
> Doc/View doesn't generally apply to a simple dialog application. On
> the other hand, if it's a logical split for your application, there's
> no reason you shouldn't apply your own modularity.
> 
> If you really wanted a SDI doc/view dialog presentation, perhaps you
> ought to use an SDI app with a CFormView as the view?
> 
> Dave Lowndes
> -- 
> MVP VC++ FAQ: http://www.mvps.org/vcfaq
> 
0
David4882 (672)
10/3/2005 12:35:04 PM
>Thanks for your answers. It seems that the the standards by which we code an 
>MFC app in Dialog mode is reasonably flexible and dependent on the 
>application at hand. I guess a level of 'common sense' comes into the 
>equation here.

Indeed - *always* apply a large amount of common sense :)

Dave
-- 
MVP VC++ FAQ: http://www.mvps.org/vcfaq
0
davidl7375 (2060)
10/3/2005 1:02:38 PM
Reply:

Similar Artilces:

Keeping data updated between 2 sheets... novice needs help.
Good afternoon, My question is a bit hard to explain.. but I will do my best to convey it. I have two spreadsheets in an Excel file. In the first sheet I have "raw data" (hereon called RawData). The second sheet (hereon called DisplayData) contains basic formulas that just pull the data from RawData, and arranges them in the way I want them displayed (ultimately for printing). This excel spreadsheet will be used by laymen who don't have time (or the understanding) to fool with layouts for their data. So I am trying to take data, and arrange it into a easily updatable document...

WinInet Questions
I have a question about using the WinInet Library. I am trying to use it to download some data from the web, unfortunatly to get to this information it requires a username and password. So how should I go about issuing my userid and password? The login style looks to be the same as yahoo mail login. So how do I issue it? ...

"Server Busy" dialog
I am trying to prevent a "Server Busy" dialog from appearing: "This action cannot be completed because the other program is busy. Chose "Switch To" to activate the busy program and correct the problem. Buttons: "Switch To...", "Retry", and "Cancel" The dialog appears when I try to exit a program that uses COM with Microsoft Outlook. It only appears if I close Outlook before closing the program. I find it interesting that the "Server Busy" dialog will close auto magically if it loses focus. (I don't have to click one of ...

Custom CView in CWinApp based project
Hello, I'm trying to create an SDI application in whitch i would my CDocument object is composed by in the one hand a view with a combobox and a Tree, in the other hand a view containing an image List. Each view is separate by a splitter. I've created resource Dialog Box for the view containing the combobox and the tree and i derive it from CFormView In the CMainFrame::OnCreateClient, i'm using the CSplitterWnd Object to create each view. mplitter.CreateStatic( this, 1,2 ); mSplitter.CreateView( 0,0, RUNTIME_CLASS( MyClassDerivedFromCFormView), CSize(100,100), pContext ) mSpli...

questions about Autoplay
Last year I installed KB971029 Update Autoplay functionality in XP. I now want to restore Autoplay to original settings. Forgetting this I first ran Autofix.exe. It did some corrections. Original functionality still doesn't work. I navigate to the KB971029 folder in Windows. When I use spuninst it say's a whole host of programs may not work. I'm nervous. This does just affect autoplay on drives doesn't it? Is this just a Generic warning? I have autoplay set to "Prompt me each time" for action (on the CD-ROM drive). Nothing. How can I get the original ...

Phishing Confidence Level (PCL) Questions
I've had a few internal mailings lately that have been inadvertently flagged as Spam, and had their links disabled as a result. I understand this is as a result of a high Phishing Confidence Level (PCL) score. Does anyone know at what point on the 1-8 scale Outlook disables the links, and what the rules Exchange uses to assign a PCL score? Thanks, Alex Foley I can't say authoratatively, but I doubt that you will get an answer to this. If the bad guys knew this, they would be able to craft around it - therefore MS wouldn't make it public, just like they treat the Junk E-ma...

Rendering questions
I have an xml file: <bio> <title>zzzzz</title> <body>blah blah blah</body> <source>Abe Lincoln</source> <site>www.yahoo.com</site> <timedate>1/1/2005</timedate> </bio> I want to add say the last blah would be really <b>blah</b>; how would I render the html tags thru my xslt file so that the last blah would be bold. tia aaron In article <#x8RXF8XFHA.3620@TK2MSFTNGP09.phx.gbl>, Me wrote: > I have an xml file: > <bio> > <title>zzzzz</title> > <body>blah blah blah&l...

One More Quick Question
Hi Again: Posted earlier about a failed installation of our first Exchange 2003 Server. SRS failed to install and looking at MS KB Articles I found this as the probable reason. The top-level public folder creation access control has been configured in the Microsoft Exchange Server 5.5 site that you are joining. I have no clue what this is or how to remedy it. That would be the first question. My second is this. The public folder mess that I inherited is not used at all and we do not intend to migrate it over. We will be starting fresh. Can I exclude public folders from being examined ...

Rules question #3
Outlook 2007 for example, I subscribe to numerous groups from yahoo and google, I want them all in the same folder, is it better to have one rule that moves the messages, like, "apply to message sent to group1 or group2 or group3, etc. move to folder" or one rule for each email I want sent to the folder even though its the same folder? is there a clear "best" way? I hope my explanation is clear. TIA Brian There's no 'best' way but I'd use one rule to move the items based on their From or To addresses. "BrianT" <brian@NOSPAM.com> w...

subform reference question
Hello - I use code like this in the after update event of cboFindCust, and the code works as expected on several of my forms. Dim strSrch As String strSrch = "custID = " & cboFindCust.Column(0) Me.RecordsetClone.FindFirst strSrch Me.Bookmark = Me.RecordsetClone.Bookmark Me!cboFindCust = Null My problem comes when cboFindCust is on a main form but the CustID records are on a subform. How do I change the syntax to find the matching record on the subform? Sarah wrote: >Hello - I use code like this in the after update event of cboFindCust, and >th...

Recordsouce question
Can I change the recordsource of a form on the fly? In other words, I have one table (a small one-to-one so I didn't split it) and I would like to have 3 maybe 4 queries off that one table. Then change the recordsouce of the form to query1, or query 2, etc, depending on what the user picks in a combo. The fields displayed on the form from each query would be the same. I know I might be able to do it with case statements, but is there an easier way? Thanks a bunch!!! -- Milton Purdy ACCESS State of Arkansas "golfinray" <golfinray@discussions.microsoft.com&g...

Results Question...
I have a results section, and I am using a Dropdown populated with years...2010, 2009, etc. How can I have this results display when the page loads based on the first item in the Drodown? David If you are referring to using the DBRW see if this helps http://www.spiderwebwoman.com/tutorials/picklist_with_dropdown.htm -- _____________________________________________ SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ] "Warning - Using the F1 Key will not break anything!" (-; _____________________________________________ "116" <116@discussio...

small questions
Is there a way to manually enter a transaction nr before=20 completing a transaction at pos?=20 How can a cashier perform a price increase on a total=20 transaction at pos? How do I create a detailed sales report with tax &=20 transaction nr=B4s at HQ? Thanks=20 Arjen On Thu, 8 Jul 2004 10:38:54 -0700, Arjen Brandt <info@edctechnology.net> wrote: > Is there a way to manually enter a transaction nr before > completing a transaction at pos? > No, the transaction numbers are autogenerated. In Administrator you can set the next transaction number, but once that's d...

No Mutual Fund Quotes
Cal, Do you know why the mutual fund quotes won't load, but on the "My Money Home Page", "Best and Worst Performers", the change in NAV is accurate for the top gainers. Does the mutual fund quote and the change in NAV not come from the same source? Thanks in advance. I have same problem in M2004, although it's inconsistent. Money will update stock quotes accurately, but mutual fund price changes are not reflected in my PV prices or totals. "ga" <gashfordjr@hotmail.com> wrote in message news:YlA8f.16645$0d3.15619@fe06.lga... > Cal, &g...

Automatic Update question
Winxp pro sp3 I have automatic updates disabled. I prefer to do them manually being still connected to a dial up connection !! Is there any way to ge rid of the red sheild in the taskbar? On Tue, 15 Dec 2009 13:36:06 +0200, "joe" <joe@ebox.com> wrote: >I have automatic updates disabled. I prefer to do them manually being still >connected to a dial up connection !! > >Is there any way to ge rid of the red sheild in the taskbar? > Yes. Go to the Control Panel, click on the Security Center and look on the left side for, "Change the...

Easy question
How to not display focus at startup when the form contains the array of check boxes covering the whole form? Claire "Claire" <replyto@fra> wrote > How to not display focus at startup when the form contains the array of > check boxes covering the whole form? Focus HAS to go somewhere and it has to go to a control that is visible. If you don't want the user to see a focus rectangle, you can add a 1x1 pixel Picturebox with no borders (so it matches the form background) and set its TabStop to 0 in the IDE. A Picturebox does not show a focus rectangle....

RUS Easy question
Hi All, This may be a easy question. I need to add another domain to the reciepient policy on our mail server. I know how to do that, but what i need to know is if i need to reboot the server after i create the policy, or will it take effect after i create it? If it need to be restarted, i will need to do this on off hours. Any comments thanks! The addition of a new RUS should take effect almost immediately (with the possibility of waiting for a few minutes for Active Directory replication to complete.) Don't forget to run setup /domainprep in the new domain. -- Jim McBee ...

conditional formatting question #8
hello, I have a list of prices from 2 stores with same part numbers. I'd like to format the spreadsheet so if the part price from store 1 is higher than store 2 - make that cell Blue. The lower price (either store 1 or 2) should be Red. I've tried this several times but the colors don't change. I'm using the conditional formatting wizard under the Tools menu. What am I missing? Thanks, Oskar Difficult to guess. Is your price data just in different columns of the same row for the same part number? Is your price data on different sheets of the same workbook? If that&#...

STAN STARINSKI
I WANT A JOB IN YOUR GLOBAL EMPIRE. IS GOVERNOR STILL AVAILABLE? Kevin Panzke Jr. wrote: > I WANT A JOB IN YOUR GLOBAL EMPIRE. IS GOVERNOR STILL AVAILABLE? Yes...you get to govern his enormous head. If it tilts to the left, poor diet Coke in his ear. If it tilts to the right, poor Bud Light in his ear. When he babbles...shake his head figorously until he foams at the mouth. -- Vita brevis breviter in brevi finietur, Mors venit velociter quae neminem veretur. Death wrote: > Kevin Panzke Jr. wrote: > >> I WANT A JOB IN YOUR GLOBAL EMPIRE. IS GOVERNOR S...

Mail Merge Question
Hello - When I do a mail merge from our excel database (excel 2002 SP3) to Word.. (word 2002 SP3)... to create labels, I have to specify which values I want to use because I don't want to use them all. For some reason... it's merging PAST the values I specify to fill up the last page. What gives? FNORD For help on Word mail merge using Excel as the data source. http://www.mvps.org/dmcritchie/excel/mailmerg.htm http://www.mvps.org/word/FAQs/MailMerge/CreateAMailMerge.htm http://www.mvps.org/word/FAQs/MailMerge/CreateADataSource.htm Gord Dibben Excel MVP On Mon, 7 Feb 2005...

LoadLibrary question
Hi All, Could anyone please let me know if it is possible to load a library which has been built with a /MD compiler witch into an exe which has been build with a /ML compiler switch using 'LoadLibrary'? I am sure that it can be done, but I want to know what will be the implications of such a load? Would that be a good idea? Also, if at all I am to load a dll into an exe which has been statically linked to C runtime libraries (using /ML option), should the dll to be loaded be also statically linked to C runtime libraries or it will be OK if the dll has been dyanamically linked with C...

Charting help for a novice?
I have a value in Column A and a calculated value in column B =if(A1,A1*14,"") I want to plot column B on a chart, however where there is no data in A then the chart plots B as a zero, but I don't want it to plot anything if there is no data. Can anyone help this relative novice? Thanks in anticipation Dave =if(A1,A1*14,NA()) should cure it on the chart. If you don't want the NA# to show in your data sheet, you can hide it with conditional formatting. -- David Biddulph "Dave Jones" <dave.g.jones@btinternet.com> wrote in message news:9_ednVQGkPw-b3_Y...

Date Question
In Money 2006, In previous versions of Money you could set the check register to show either the date an EPay was processed by the back or the date it was due at the Vendor. In Money 2006 I can't seem to find that setting. Can anyone direct me to the right place? Thanks. Steve ...

questions about CToolbarCtrl buttons
Hi, I have a couple questions about buttons in CToolbarCtrl. Here is the code (It is from the KBBar example): NUM_TOOLBAR_BUTTONS = 4; COMBO_IDX = 3; if (!CToolBarCtrl::Create(DEFAULT_TOOLBAR_STYLE, rcClientParent, pWndParent, IDR_IETOOLBAR)) return false; SetButtonSize(CSize(24, 24)); AddStrings("Go\0Stop\0Options\0"); if (AddBitmap(3, IDR_IETOOLBAR) == -1) { DWORD dwError = ::GetLastError(); return false; } TBBUTTON tbs[NUM_TOOLBAR_BUTTONS]; for (int i = 0; i < NUM_TOOLBAR_BUTTONS; i++) { tbs[i].dwData = 0; tbs[i].fsState = TBSTATE_ENABLED; tbs[i].f...

POP3 / SMTP Using Exchange Question
I have a need to have a connection to Exchange as well as multiple POP3 accounts. Currently my default account is one of the POP3 accounts. I am having problems replying to emails that come into one of the POP3 accounts. I don't know what the problem is. Is there a way that I should be doing this? Here are the details. Say my POP3 account is mike@robbie.com. My Exchange (Active Directory) email address is mike@bobby.com. I have two accounts configured in Outlook, 1 Exchange and 1 POP3. I know my settings are correct since individually everything works fine. If I set my default acc...