473,473 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

setting up controls in a dialog.

Sorry, bit of a noob question.

But if I bind a var to a radio control, then set that var just before
calling DoModal the control does not reflect the vars value. So I put a
UpdateData(0) in the OnInitDialog func, no joy. So I added.........

HWND hWndCtrl;
GetDlgItem(IDC_RADIO1, &hWndCtrl);
::SendMessage(hWndCtrl, BM_SETCHECK, (WPARAM)test_var, 0L);

and this works!

As far as I can see, that is what UpdateData(0) is doing, via DoDataExchange
and
DDX_Check(pDX,IDC_RADIO1,test_var)

Odd and i'm confused.
I've come up against this many times and in the past ended up adding MFX
contol object to do it, but i've decieded to once and for all find a way to
do it with out adding loads of CButton radio_button.... vars just to init
the control. If UpdateData(0) worked as I had expected I would have been a
happy chappy. :-)
Nov 17 '05 #1
2 1323
Sorry, ignore that question. Just found a very very very silly bug/typo on
my part. Doh!. Works fine now. :-)

"maddog" <ri*****@collins1969.fsnet.co.uk> wrote in message
news:c6**********@newsg4.svr.pol.co.uk...
Sorry, bit of a noob question.

But if I bind a var to a radio control, then set that var just before
calling DoModal the control does not reflect the vars value. So I put a
UpdateData(0) in the OnInitDialog func, no joy. So I added.........

HWND hWndCtrl;
GetDlgItem(IDC_RADIO1, &hWndCtrl);
::SendMessage(hWndCtrl, BM_SETCHECK, (WPARAM)test_var, 0L);

and this works!

As far as I can see, that is what UpdateData(0) is doing, via DoDataExchange and
DDX_Check(pDX,IDC_RADIO1,test_var)

Odd and i'm confused.
I've come up against this many times and in the past ended up adding MFX
contol object to do it, but i've decieded to once and for all find a way to do it with out adding loads of CButton radio_button.... vars just to init
the control. If UpdateData(0) worked as I had expected I would have been a
happy chappy. :-)

Nov 17 '05 #2
I do not use MFC but I understand your problem. DoModul is a macro for

DialogBox(Instance,MAKEINTRESOURCE(IDD_RESOURCE),h wnd, DialogProc)

DialogBox() creates the dialog box and then calls CALLBACK DialogProc() whic
is a kind of do{}while until the dialog box loses focus or is close

BOOL CALLBACK DialogProc (HWND, UINT message, WPARAM wParam, LPARAM lParam

HWND hwnd

switch (message
case WM_INITDIALOG: //here is where and when variables are initialize
//eg. Title the dialog box and check a butto
/
SendMessage(hdlg,WM_SETTEXT,0,(LPARAM) "Dialog Box")
hwnd = GetDlgItem(hdlg,IDC_BUTTON)
SendMessage(hwnd,BM_SETCHECK,BST_CHECKED,0)

break

case WM_COMMAND://here is when and where variables and data exchange
/
switch (wParam

case IDOK: //and here is the en
/
case IDCANCEL: EndDialog()
return(TRUE)
return(FALSE)
//DoModul displays your resource as you made it. Changes you wan
//to make to variables etc. in the Dialog Box are done after DoModul(
//in the CALLBACK procedure. Simply put, DoModul()does all the stati
//graphics and CALLBACK procedure does all the work with variables
//It is in the WM_INITDIALOG where you check buttons and things t
//get started

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Melissa | last post by:
1. Is there a way to programatically remove the focus from the form; ie, so the focus is not on any control on the form? 2. Is there a way to programatically set the focus to the same place as...
2
by: Shane Molton | last post by:
I have a few user controls and I don't want to add them to the main form. I simply want to be able to spawn them like pop-up windows I added them to my project and call show(), but nothing...
2
by: macca | last post by:
Hi, I am writing a GUI application. It will have a number of user defined controls( I plan to use/create a user defined control that will output alarm states that the user can also select and...
5
by: Yifan | last post by:
Hi Could any one tell me what project property controls the setting of '/RTC1' option? Now I have a project which has this build error "Command line error D2016 : '/RTC1' and '/clr' command-line...
2
by: Need Helps | last post by:
I'm trying to create a dialog box that pops when a menu item is selected, and it works fine unless I put certain controls in the dialog box. I tried a month calendar, slider, and a date time picker,...
4
by: JV | last post by:
It's easy to databind a listbox or dropdownlist if all you want is to fill it with a list of values. There are plenty of examples in the online help. Unfortunately, real world applications...
9
by: james.e.coleman | last post by:
Hello, I have created a custom dropdownlist that is used multiple times within a single page. When trying to set the values of the controls with the page in which they are being used, they all...
1
by: Demi | last post by:
I want to be able to define standard colors in a base form, then have child forms use those values instead of standard colors. Ex in my base form I want to do this: Color myColor =...
2
by: Richard Lewis Haggard | last post by:
I've got a problem with the way that some dialogs, er ah, I mean forms, position their controls. On most machines, but not on my client's laptop, all of the forms and their controls display in the...
1
by: ian807 | last post by:
I have a legacy vb.net mdi word processor application which I'm modifying. I've created many new dialogs. In vb6, I could reference controls on the child form with code like this: Dim text as...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.