-
March 24th, 2014, 10:26 PM
#1
Display data immediately - C++ Dialog domodal?
I haven't seen it anywhere and I've been looking. Is it possible to display data, say in a CEdit field in a dialog as soon as the dialog starts? Either before or after DoModal is fine.. These are essentially the same.
Using Visual Studio 2013 - trial version. It's nice. Coming from VC6. Many things are familiar (so far), at least in the C++ part.
-
March 24th, 2014, 10:31 PM
#2
Re: Display data immediately - C++ Dialog domodal?
BTW, mentioned VC6 because I'm wondering if maybe I missed something when drawing out the CEdit field. Is it still the same- just draw it out, make it a value field and assign a variable to it? I'm thinking that should work for the message handler methods anyways.
Used:
dlg.SetDlgItemText(IDC_TARGETAPP, _T("test tester testing"));
and nothing showed up upon dialog program startup.
-
March 24th, 2014, 10:39 PM
#3
Re: Display data immediately - C++ Dialog domodal?
Did some more research and ran across the DDE thing. I guess somehow that needs to be done upon Dialog startup for this to work. Any suggestions, as in examples of calling DoDataExchange(CDataExchange* pDX);
Thanks for any help.
-
March 25th, 2014, 05:02 AM
#4
Re: Display data immediately - C++ Dialog domodal?
Originally Posted by MarkJS
I haven't seen it anywhere and I've been looking. Is it possible to display data, say in a CEdit field in a dialog as soon as the dialog starts? Either before or after DoModal is fine..
It is not possible to display data in a CEdit field in a dialog before dialog starts.
Do it in the CDialog::OnInitDialog override.
Victor Nijegorodov
-
March 25th, 2014, 07:11 AM
#5
Re: Display data immediately - C++ Dialog domodal?
The Windows part of the dialog and its associated controls don't exist before or after DoModal, so that part doesn't makes sense.
The DDX mechanism is an easy way to do it. Just give a value to the member variable associated with the control before calling CDialog::OnInitDialog.
Another way is to call SetWindowText in your OnInitDialog after it calls CDialog::OnInitDialog.
-
March 25th, 2014, 11:06 AM
#6
Re: Display data immediately - C++ Dialog domodal?
Originally Posted by VictorN
It is not possible to display data in a CEdit field in a dialog before dialog starts.
Do it in the CDialog::OnInitDialog override.
Yep... A WELL-PLACED - Thank You, simple:
SetDlgItemText(IDC_CEDITFIELD, CString);
worked... There is an area in OnInitDialog to put initialized data in (at least in VS 2013).
---------------------------
Nice technique.
I like it, as the program is doing stuff immediately... not staring me in the face, so to speak- with a duhhhh... expression upon startup.
-
March 25th, 2014, 11:19 AM
#7
Re: Display data immediately - C++ Dialog domodal?
Originally Posted by MarkJS
There is an area in OnInitDialog to put initialized data in (at least in VS 2013).
That "area" exists in VS6.0 and even older versions, as well.
-
March 25th, 2014, 12:22 PM
#8
Re: Display data immediately - C++ Dialog domodal?
Originally Posted by MarkJS
Yep... A WELL-PLACED - Thank You, simple:
SetDlgItemText(IDC_CEDITFIELD, CString);
You might be better off at least learning what the DDX control approach has to offer rather than using the older WinAPI style of setting control values.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|