CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2006
    Posts
    63

    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.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    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

  3. #3
    Join Date
    Mar 2006
    Posts
    63

    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.

  4. #4
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    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.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  5. #5
    Join Date
    Mar 2006
    Posts
    63

    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
  •  





Click Here to Expand Forum to Full Width

Featured