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. changing the position of CFileDialog

changing the position of CFileDialog

Scheduled Pinned Locked Moved C / C++ / MFC
question
8 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.
  • I Offline
    I Offline
    iayd
    wrote on last edited by
    #1

    Hi How can I change the position of the dialog box which is created from CFileDialog? This is not work; TCHAR strFilter[] = { TEXT("Files (*.*)|*.*||") }; CFileDialog dlg(TRUE, TEXT(".*"), NULL, 0, strFilter,this); dlg.SetWindowPos(&wndTop,0,0,20,30,SWP_SHOWWINDOW); Thanks

    P D 2 Replies Last reply
    0
    • I iayd

      Hi How can I change the position of the dialog box which is created from CFileDialog? This is not work; TCHAR strFilter[] = { TEXT("Files (*.*)|*.*||") }; CFileDialog dlg(TRUE, TEXT(".*"), NULL, 0, strFilter,this); dlg.SetWindowPos(&wndTop,0,0,20,30,SWP_SHOWWINDOW); Thanks

      P Offline
      P Offline
      prasad_som
      wrote on last edited by
      #2

      iayd wrote:

      This is not work;

      Because, you are using API, on uninitialized window. Try to create it modelles. If you want it modal, then derive a class from CFileDialog and use SetWindowPos or MoveWindow in OnInitDialog.


      Prasad MS MVP -  VC++

      I 1 Reply Last reply
      0
      • P prasad_som

        iayd wrote:

        This is not work;

        Because, you are using API, on uninitialized window. Try to create it modelles. If you want it modal, then derive a class from CFileDialog and use SetWindowPos or MoveWindow in OnInitDialog.


        Prasad MS MVP -  VC++

        I Offline
        I Offline
        iayd
        wrote on last edited by
        #3

        But still I cannot change the width of dialog box.I want a narrower diialog box.I used SetwindowPos in OnInitDialog.Is there a solution for this problem.

        P 1 Reply Last reply
        0
        • I iayd

          Hi How can I change the position of the dialog box which is created from CFileDialog? This is not work; TCHAR strFilter[] = { TEXT("Files (*.*)|*.*||") }; CFileDialog dlg(TRUE, TEXT(".*"), NULL, 0, strFilter,this); dlg.SetWindowPos(&wndTop,0,0,20,30,SWP_SHOWWINDOW); Thanks

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

          Modeless or modal, this will not work. You'll need to provide a hook (OFN_ENABLEHOOK). In that hook procedure, respond to the WM_INITDIALOG message, and call SetWindowPos().


          "A good athlete is the result of a good and worthy opponent." - David Crow

          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

          I 1 Reply Last reply
          0
          • I iayd

            But still I cannot change the width of dialog box.I want a narrower diialog box.I used SetwindowPos in OnInitDialog.Is there a solution for this problem.

            P Offline
            P Offline
            prasad_som
            wrote on last edited by
            #5

            As told earlier, MoveWindow or API mentioned by you can be used. Make sure, you are using these API's after initialization of window handle.


            Prasad MS MVP -  VC++

            1 Reply Last reply
            0
            • D David Crow

              Modeless or modal, this will not work. You'll need to provide a hook (OFN_ENABLEHOOK). In that hook procedure, respond to the WM_INITDIALOG message, and call SetWindowPos().


              "A good athlete is the result of a good and worthy opponent." - David Crow

              "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

              I Offline
              I Offline
              iayd
              wrote on last edited by
              #6

              Hoe will I do waht you said?Can you write a sample code? Thanks

              D M 2 Replies Last reply
              0
              • I iayd

                Hoe will I do waht you said?Can you write a sample code? Thanks

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

                See here.


                "A good athlete is the result of a good and worthy opponent." - David Crow

                "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                1 Reply Last reply
                0
                • I iayd

                  Hoe will I do waht you said?Can you write a sample code? Thanks

                  M Offline
                  M Offline
                  Mark Salsbery
                  wrote on last edited by
                  #8

                  I'm pretty sure MFC hooks the dialog for you.  Why not just derive a class from CFileDialog and call MoveWindow() in a WM_INITDIALOG handler? Mark

                  Mark Salsbery Microsoft MVP - Visual C++ :java:

                  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