Click here to Skip to main content
15,917,177 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Using of one object in three dialog ... Pin
Stan Shannon12-Jul-01 4:59
Stan Shannon12-Jul-01 4:59 
GeneralRe: Using of one object in three dialog ... Pin
Tomasz Sowinski12-Jul-01 7:00
Tomasz Sowinski12-Jul-01 7:00 
GeneralRe: Using of one object in three dialog ... Pin
Hadi Rezaee13-Jul-01 18:26
Hadi Rezaee13-Jul-01 18:26 
GeneralRe: Using of one object in three dialog ... Pin
CMFC6.0VS.NETUser12-Jul-01 4:48
CMFC6.0VS.NETUser12-Jul-01 4:48 
GeneralRe: Using of one object in three dialog ... Pin
Stan Shannon12-Jul-01 5:49
Stan Shannon12-Jul-01 5:49 
GeneralRe: Using of one object in three dialog ... Pin
Hadi Rezaee13-Jul-01 18:19
Hadi Rezaee13-Jul-01 18:19 
GeneralRe: Using of one object in three dialog ... Pin
Hadi Rezaee14-Jul-01 1:49
Hadi Rezaee14-Jul-01 1:49 
GeneralRe: Using of one object in three dialog ... Pin
Stan Shannon14-Jul-01 3:38
Stan Shannon14-Jul-01 3:38 
First, I have never used the DAO classes (I typically use CDatabase/CRecordset for simple stuff and ADO for anything else). So I cannot address issues relatiing to DAO specifically. There may be easier techniques for you to use than what I am suggesting for DAO built into MFC. If you look at MSDN or Codeproject samples you might find something relating to that.

Yes, DoModal returns when the dialog box is closed. That is by design, and is typically the behavior you want. Obviously, I don't know the details of your design, and maybe what I'm suggesting will not work for you. All I'm saying is that it is the approach I *always* take, as I have found it to be a very safe and simple way to do business, especially in a large application that many people have their hands on.

What I am suggesting is that you copy the data that you want to manipulate from the db object, which is "owned" by the MainFrame object, to the dialog box, initializing the dialog box with that data (there are various opinions about how to do that best). Next you allow the user to manipulate that data in the dialog box. Finally, if the user hits OK you copy the edited data from the dialog box and back to the db object, if the user hits cancel, do nothing at all.

In this way, the dialog box never needs to know that the db object even exists, and the db needs to know nothing about the dialog. Only the Mainframe window (and the db object itself, of course) knows, or cares, about the db object, or the dialog. In this way, the db object, and whatever global data it contains, is not made public to the entire application unnecessarily.

If the db data also needs to be accessed from objects other than dialogs, (views, for example), than that might be an argument for giving ownership of the db object to your document class rather than the Mainframe. If more than one document/view needs access to the db data, well, than you might need to consider letting the App class handle it afterall. As the programmer, its your call.



GeneralCImageList containing variable width images Pin
ov11-Jul-01 22:34
ov11-Jul-01 22:34 
GeneralRe: CImageList containing variable width images Pin
12-Jul-01 1:57
suss12-Jul-01 1:57 
Questionprovider for access? Pin
Gérald Mercet11-Jul-01 22:31
Gérald Mercet11-Jul-01 22:31 
AnswerRe: provider for access? Pin
Anders Molin12-Jul-01 1:24
professionalAnders Molin12-Jul-01 1:24 
Generalsmall problem(so I hope) with a small spin . Please help !!! Pin
11-Jul-01 22:13
suss11-Jul-01 22:13 
GeneralRe: small problem(so I hope) with a small spin . Please help !!! Pin
Michael Dunn11-Jul-01 22:31
sitebuilderMichael Dunn11-Jul-01 22:31 
GeneralThank ! But I did not understant , What I need to do ??? Pin
11-Jul-01 22:48
suss11-Jul-01 22:48 
GeneralGray the desktop problem 2 Pin
inforix11-Jul-01 21:54
inforix11-Jul-01 21:54 
GeneralGray the desktop problem Pin
inforix11-Jul-01 20:59
inforix11-Jul-01 20:59 
Generalopen folder Pin
11-Jul-01 20:56
suss11-Jul-01 20:56 
GeneralRe: open folder Pin
coder847211-Jul-01 22:33
coder847211-Jul-01 22:33 
QuestionTime Diff in C++ and Windows Tray??? Pin
Dan Madden11-Jul-01 20:50
Dan Madden11-Jul-01 20:50 
AnswerRe: Time Diff in C++ and Windows Tray??? Pin
Anders Molin12-Jul-01 1:20
professionalAnders Molin12-Jul-01 1:20 
GeneralCombo box border Pin
Dejan Petrovic11-Jul-01 19:55
Dejan Petrovic11-Jul-01 19:55 
GeneralNot print the brush creating with Bitmap Pin
Eugene Pustovoyt11-Jul-01 19:09
Eugene Pustovoyt11-Jul-01 19:09 
GeneralRe: Not print the brush creating with Bitmap Pin
Christian Graus11-Jul-01 19:29
protectorChristian Graus11-Jul-01 19:29 
GeneralAdd ActiveX in a modeless windows Pin
Francis B.11-Jul-01 17:20
Francis B.11-Jul-01 17:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.