Solved

How to preload dialog fields

Posted on 2010-09-15
3
402 Views
Last Modified: 2013-12-14
Hi,

I am writing an mfc based visual c++ application (Visual Studio 2008) and I am having some
difficulties with configuring a modal dialog box.

The dialog box is intended to configure database access parameters - database name,
password etc.

Problem is that I can't figure out how to preload the fields on dialog box creation
ie I need to read some data from the registry, and populate the fields.

Any suggestion for this would be appreciated.  I've tried a number of methods including overloading OnInitialUpdate, but no success.

Thanks

Chris

0
Comment
Question by:chrisd-r
  • 2
3 Comments
 
LVL 30

Accepted Solution

by:
Zoppo earned 500 total points
ID: 33680549
Hi chrisd-r,

best place to do this is in an overloaded 'OnInitDialog' (which you can easy add via ClassWizard by adding a message handler for WM_INIT_DIALOG message) somehow like this:

> BOOL CMyDlg::OnInitDialog()
> {
>  CDialog::OnInitDialog();
>  // load your values here and fill the controls
>  UpdateData( FALSE ); // This is needed if you use DDX-Data exchange using variables for controls
> }

Hope that helps,

ZOPPO
0
 
LVL 30

Expert Comment

by:Zoppo
ID: 33680562
Here you can find samples for some different ways to init the values of an edit control: http://functionx.com/visualc/controls/editbox.htm
0
 

Author Comment

by:chrisd-r
ID: 33680641
Thanks for the help - It is now fixed.

Forgot to call UpdateData(FALSE);

Chris
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now