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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Modal dialog coordinates

Modal dialog coordinates

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionlearning
5 Posts 3 Posters 2 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
    Johnny Peszek
    wrote on last edited by
    #1

    Hi! I have a dialog based application with one modal dialog as an inserted dialog resource. The modal dialog is always displayed in the middle of the dialog based application. I would like to display it not in the middle but with given coordinates e.g. in the upper left corner of the screen. Can somebody help me? Regards.

    RaviBeeR D 2 Replies Last reply
    0
    • J Johnny Peszek

      Hi! I have a dialog based application with one modal dialog as an inserted dialog resource. The modal dialog is always displayed in the middle of the dialog based application. I would like to display it not in the middle but with given coordinates e.g. in the upper left corner of the screen. Can somebody help me? Regards.

      RaviBeeR Offline
      RaviBeeR Offline
      RaviBee
      wrote on last edited by
      #2

      You can reposition the dialog by making a call to MoveWindow() or SetWindowPos() in the dialog's WM_INITDIALOG handler. Here's an example of how to position the dialog at the top left corner.

      CRect rectDlg;
      GetWindowRect (&rectDlg);
      int nWidth = rectDlg.Width();
      int nHeight = rectDlg.Height;
      rectDlg.left = 0;
      rectDlg.right = nWidth;
      rectDlg.top = 0;
      rectDlg.bottom = nHeight;
      MoveWindow (&rectDlg);

      • or -

      SetWindowPos (NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOZORDER);

      /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

      J 1 Reply Last reply
      0
      • J Johnny Peszek

        Hi! I have a dialog based application with one modal dialog as an inserted dialog resource. The modal dialog is always displayed in the middle of the dialog based application. I would like to display it not in the middle but with given coordinates e.g. in the upper left corner of the screen. Can somebody help me? Regards.

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        Call SetWindowPos() from the dialog's OnInitDialog() method.


        "When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen

        J 1 Reply Last reply
        0
        • RaviBeeR RaviBee

          You can reposition the dialog by making a call to MoveWindow() or SetWindowPos() in the dialog's WM_INITDIALOG handler. Here's an example of how to position the dialog at the top left corner.

          CRect rectDlg;
          GetWindowRect (&rectDlg);
          int nWidth = rectDlg.Width();
          int nHeight = rectDlg.Height;
          rectDlg.left = 0;
          rectDlg.right = nWidth;
          rectDlg.top = 0;
          rectDlg.bottom = nHeight;
          MoveWindow (&rectDlg);

          • or -

          SetWindowPos (NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOZORDER);

          /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

          J Offline
          J Offline
          Johnny Peszek
          wrote on last edited by
          #4

          Thanks!

          1 Reply Last reply
          0
          • D David Crow

            Call SetWindowPos() from the dialog's OnInitDialog() method.


            "When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen

            J Offline
            J Offline
            Johnny Peszek
            wrote on last edited by
            #5

            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