Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / May 2004

Tip: Looking for answers? Try searching our database.

setting up controls in a dialog.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
maddog - 22 Apr 2004 12:13 GMT
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. :-)
maddog - 22 Apr 2004 12:37 GMT
Sorry, ignore that question. Just found a very very very silly bug/typo on
my part. Doh!. Works fine now. :-)

> Sorry, bit of a noob question.
>
[quoted text clipped - 19 lines]
> the control. If UpdateData(0) worked as I had expected I would have been a
> happy chappy. :-)
James Sexton - 02 May 2004 08:56 GMT
I do not use MFC but I understand your problem. DoModul is a macro for

DialogBox(Instance,MAKEINTRESOURCE(IDD_RESOURCE),hwnd, 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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.