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. DoModal() Dialog Position

DoModal() Dialog Position

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
4 Posts 4 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.
  • M Offline
    M Offline
    mehmetned
    wrote on last edited by
    #1

    I have a dialog and this dialog's domodal function(myDlg->DoModal) is called from another cpp file. I got rectangle of this dialog at the end of the oninitdialog function and a button clicked event after the dialog had been visible but these two rectangle values were different. Does domodal function do something about position of the dialog after oninitdialog function of this dialog? other.cpp: myDlg->domodal() myDlg.cpp: myDlg::OnInitDialog { //other code ...... ...... GetWindowRect(&rect); // top=29 bottom=221 left=165 right=1033 //end of function } myDlg::ButtonClick //i clicked button while the dialog was on the screen { GetWindowRect(&rect); // top=431 bottom=623 left=407 right=1275 } Why are these two rectangle diffenrent? Thanks.

    C N W 3 Replies Last reply
    0
    • M mehmetned

      I have a dialog and this dialog's domodal function(myDlg->DoModal) is called from another cpp file. I got rectangle of this dialog at the end of the oninitdialog function and a button clicked event after the dialog had been visible but these two rectangle values were different. Does domodal function do something about position of the dialog after oninitdialog function of this dialog? other.cpp: myDlg->domodal() myDlg.cpp: myDlg::OnInitDialog { //other code ...... ...... GetWindowRect(&rect); // top=29 bottom=221 left=165 right=1033 //end of function } myDlg::ButtonClick //i clicked button while the dialog was on the screen { GetWindowRect(&rect); // top=431 bottom=623 left=407 right=1275 } Why are these two rectangle diffenrent? Thanks.

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      Did you move your dialog before clicking the button ? If yes, then it's normal that the rectangle changed.

      Cédric Moonen Software developer
      Charting control [v1.4]

      1 Reply Last reply
      0
      • M mehmetned

        I have a dialog and this dialog's domodal function(myDlg->DoModal) is called from another cpp file. I got rectangle of this dialog at the end of the oninitdialog function and a button clicked event after the dialog had been visible but these two rectangle values were different. Does domodal function do something about position of the dialog after oninitdialog function of this dialog? other.cpp: myDlg->domodal() myDlg.cpp: myDlg::OnInitDialog { //other code ...... ...... GetWindowRect(&rect); // top=29 bottom=221 left=165 right=1033 //end of function } myDlg::ButtonClick //i clicked button while the dialog was on the screen { GetWindowRect(&rect); // top=431 bottom=623 left=407 right=1275 } Why are these two rectangle diffenrent? Thanks.

        N Offline
        N Offline
        Nibu babu thomas
        wrote on last edited by
        #3

        mehmetned wrote:

        Does domodal function do something about position of the dialog after oninitdialog function of this dialog?

        There is a function called _AfxPostInitDialog which does some additional house keeping after OnInitDialog! From what I see it's centering the dialog!

        Nibu thomas Microsoft MVP for VC++ Code must be written to be read, not by the compiler, but by another human being. Programming Blog: http://nibuthomas.wordpress.com

        1 Reply Last reply
        0
        • M mehmetned

          I have a dialog and this dialog's domodal function(myDlg->DoModal) is called from another cpp file. I got rectangle of this dialog at the end of the oninitdialog function and a button clicked event after the dialog had been visible but these two rectangle values were different. Does domodal function do something about position of the dialog after oninitdialog function of this dialog? other.cpp: myDlg->domodal() myDlg.cpp: myDlg::OnInitDialog { //other code ...... ...... GetWindowRect(&rect); // top=29 bottom=221 left=165 right=1033 //end of function } myDlg::ButtonClick //i clicked button while the dialog was on the screen { GetWindowRect(&rect); // top=431 bottom=623 left=407 right=1275 } Why are these two rectangle diffenrent? Thanks.

          W Offline
          W Offline
          wct
          wrote on last edited by
          #4

          Sure, GetWindowRect is not correct at OnInitDialog. Use GetWindowPlacement to get window position is a better idea. Chintse Wu/[^]

          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