-
November 17th, 2009, 08:21 AM
#1
Dialog Edit Box Access
I created a Dialog-based MFC app. The dialog boilerplate is used to manually start USB controlled hardware functions, which usually execute repeatedly, with various hardware parameters being changed by the function modules as they execute. Headers for these functions are Included in the Dialog header. Everything works ok, no problems. The app could be likened to a data logger. But, now I want to display measurement data as it is produced, "simply" writing it to an Edit Box on the Dialog. Unfortunately I have not been able to devise a method to achieve this. I can see that the problem is that the functions which need to update the Edit Box are "downstream" of the Dialog. Any tips or pointers to similar Dialog apps (where the action code is not coded as part of the dialog) would be greatly appreciated.
-
November 17th, 2009, 08:42 AM
#2
Re: Dialog Edit Box Access
Create a control member variable (say, m_myEdit) for the editbox and use it to set the text to this control:
Code:
m_myEdit.SetWindowText(_T("Some text"));
Victor Nijegorodov
-
November 17th, 2009, 09:01 AM
#3
Re: Dialog Edit Box Access
That's the problem, VictorN: writing to an Edit Box, whether it's a CString or a control member, work fine from within the Dialog, i.e in *Dlg.cpp . But the various modules in different cpp files, whilst they can be invoked from the Dlg, cannot access the Edit Box. How can I get a handle on the Dlg from a function which has been triggered from the Dlg, and which is in a separate source file ? The dialog "knows" the executing function, but the function does not know the object which triggered it.
-
November 17th, 2009, 09:11 AM
#4
Re: Dialog Edit Box Access
You can pass a pointer to the dialog object to those functions. Or you can pass the handle to the window you want to update and from those functions send appropriate messages to the window.
-
November 17th, 2009, 09:26 AM
#5
Re: Dialog Edit Box Access
Sounds cool Cilu.
But from where do I get the pointer to the dialog? Or the handle to the window? Could you recommend a sample project which does either of these? I have tried to implement various SendMessage.. / GetHandle.. procedures based on descriptions found on the web, but without success. I suppose I could just bundle all code into the *Dlg.cpp, that should work nicely.
Thanks.
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
|