Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Access to its caller from a Dialog

Access to its caller from a Dialog

Scheduled Pinned Locked Moved C / C++ / MFC
questiongraphics
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jazzkiller
    wrote on last edited by
    #1

    Hi all, Inside a View class (CChildView), I call CDialog. The Dialog pops up. Now, how can I talk to the CChildView while the Dialog still shows? Say CChildView display a bitmap; in my dialog, I change the zoom parameter to 2x, I want the image to reflex the change immediately in the CChildView. Thank you in advance,

    K 1 Reply Last reply
    0
    • J jazzkiller

      Hi all, Inside a View class (CChildView), I call CDialog. The Dialog pops up. Now, how can I talk to the CChildView while the Dialog still shows? Say CChildView display a bitmap; in my dialog, I change the zoom parameter to 2x, I want the image to reflex the change immediately in the CChildView. Thank you in advance,

      K Offline
      K Offline
      KaRl
      wrote on last edited by
      #2

      What about defining an user message (WM_APP + something) and post it/ send it from the dialog to the view?


      Fold With Us! What a sad world it would be if everyone said and did only what was easy - Shog9

      J 1 Reply Last reply
      0
      • K KaRl

        What about defining an user message (WM_APP + something) and post it/ send it from the dialog to the view?


        Fold With Us! What a sad world it would be if everyone said and did only what was easy - Shog9

        J Offline
        J Offline
        jazzkiller
        wrote on last edited by
        #3

        Do I define WM_APP message in View and from Dialog I do: this->SendMessage(WM_DO_STUFF,0,0)? I did that, but it didn't work out. Thanks

        K 1 Reply Last reply
        0
        • J jazzkiller

          Do I define WM_APP message in View and from Dialog I do: this->SendMessage(WM_DO_STUFF,0,0)? I did that, but it didn't work out. Thanks

          K Offline
          K Offline
          KaRl
          wrote on last edited by
          #4

          * Is your dialog modal or modeless? * Try to use PostMessage instead of SendMessage you should have in : #define WM_DO_STUFF WM_APP+1 In <myview.h> BEGIN_MESSAGE_MAP(CMyView, CView) [...] afx_msg LRESULT OnDoStuff(WPARAM wParam, LPARAM lParam); END_MESSAGE_MAP() In <myview.cpp> BEGIN_MESSAGE_MAP(CMyView, CView) [...] ON_MESSAGE(WM_DO_STUFF, OnDoStuff) END_MESSAGE_MAP() LRESULT CMyView::OnDoStuff(WPARAM wParam, LPARAM lParam) { // do stuff return 0L; } in <mydialog.cpp> (CMyDialog must know about the view) void CMyDialog::OnActionButton() { ASSERT(m_pMyView); m_pMyView->PostMessage(WM_DO_STUFF); } HTH,


          Fold With Us! What a sad world it would be if everyone said and did only what was easy - Shog9

          J 2 Replies Last reply
          0
          • K KaRl

            * Is your dialog modal or modeless? * Try to use PostMessage instead of SendMessage you should have in : #define WM_DO_STUFF WM_APP+1 In <myview.h> BEGIN_MESSAGE_MAP(CMyView, CView) [...] afx_msg LRESULT OnDoStuff(WPARAM wParam, LPARAM lParam); END_MESSAGE_MAP() In <myview.cpp> BEGIN_MESSAGE_MAP(CMyView, CView) [...] ON_MESSAGE(WM_DO_STUFF, OnDoStuff) END_MESSAGE_MAP() LRESULT CMyView::OnDoStuff(WPARAM wParam, LPARAM lParam) { // do stuff return 0L; } in <mydialog.cpp> (CMyDialog must know about the view) void CMyDialog::OnActionButton() { ASSERT(m_pMyView); m_pMyView->PostMessage(WM_DO_STUFF); } HTH,


            Fold With Us! What a sad world it would be if everyone said and did only what was easy - Shog9

            J Offline
            J Offline
            jazzkiller
            wrote on last edited by
            #5

            Thank you K, I finally passed a pointer of MyView to Dialog and access functions in MyView such as Invalidate and other member functions through this pointer. Thanks,

            1 Reply Last reply
            0
            • K KaRl

              * Is your dialog modal or modeless? * Try to use PostMessage instead of SendMessage you should have in : #define WM_DO_STUFF WM_APP+1 In <myview.h> BEGIN_MESSAGE_MAP(CMyView, CView) [...] afx_msg LRESULT OnDoStuff(WPARAM wParam, LPARAM lParam); END_MESSAGE_MAP() In <myview.cpp> BEGIN_MESSAGE_MAP(CMyView, CView) [...] ON_MESSAGE(WM_DO_STUFF, OnDoStuff) END_MESSAGE_MAP() LRESULT CMyView::OnDoStuff(WPARAM wParam, LPARAM lParam) { // do stuff return 0L; } in <mydialog.cpp> (CMyDialog must know about the view) void CMyDialog::OnActionButton() { ASSERT(m_pMyView); m_pMyView->PostMessage(WM_DO_STUFF); } HTH,


              Fold With Us! What a sad world it would be if everyone said and did only what was easy - Shog9

              J Offline
              J Offline
              jazzkiller
              wrote on last edited by
              #6

              Hi K, I finally passed a MyView pointer to CDialog through constructor. Thus, I can access MyView member functions from CDialog. However, when I clicked OK on the Dialog, the program crashed. My guess is that I don't know how to delete the *pView that I passed to Dialog. I delete it in the contructor Dialog destructor). Any thought? By the way, it is a Modal dialog. Thanks,

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups