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. SetWindowPos

SetWindowPos

Scheduled Pinned Locked Moved C / C++ / MFC
learningcsharpc++visual-studioquestion
7 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.
  • G Offline
    G Offline
    gomez_a
    wrote on last edited by
    #1

    I prepared (in Visual Studio 2003 + MFC) "Dialog Based" Application. Now, I have one dialog window where I want to add two book marks. I have two objects: class DlgPage1 : public CPropertyPage // variable mPage1 class DlgPage2 : public CPropertyPage // variable mPage2 In the resource window I have done two dialogs with properties: Style = child Border = thin TitleBar = true Disabled = true In the OnInitDialog (main window) function I have code: mPropertySheet = new CPropertySheet("Simple PropertySheet"); mPage1 = new DlgPage1(); mPage2 = new DlgPage2(); mPropertySheet->AddPage(mPage1); mPropertySheet->AddPage(mPage2); mPropertySheet->Create(this, WS_CHILD | WS_VISIBLE, 0); mPropertySheet->ModifyStyleEx(0, WS_EX_CONTROLPARENT); mPropertySheet->ModifyStyleEx(0, WS_TABSTOP); mPropertySheet->ModifyStyleEx(0, WS_MAXIMIZE); // now, I want to resize windows for almost maximum size CRect rect; GetClientRect(&rect); int Width = rect.Width()-7; int mHeight = rect.Height()-7; mPropertySheet->SetWindowPos(NULL, 7, 7, mWidth, mHeight, SWP_NOZORDER); ================ The SetWindowPos doesn't do what I expect. Why the windows doesn't resize? It has the size - I designed in the Resource. Regards mwgomez/Poland

    R S V 3 Replies Last reply
    0
    • G gomez_a

      I prepared (in Visual Studio 2003 + MFC) "Dialog Based" Application. Now, I have one dialog window where I want to add two book marks. I have two objects: class DlgPage1 : public CPropertyPage // variable mPage1 class DlgPage2 : public CPropertyPage // variable mPage2 In the resource window I have done two dialogs with properties: Style = child Border = thin TitleBar = true Disabled = true In the OnInitDialog (main window) function I have code: mPropertySheet = new CPropertySheet("Simple PropertySheet"); mPage1 = new DlgPage1(); mPage2 = new DlgPage2(); mPropertySheet->AddPage(mPage1); mPropertySheet->AddPage(mPage2); mPropertySheet->Create(this, WS_CHILD | WS_VISIBLE, 0); mPropertySheet->ModifyStyleEx(0, WS_EX_CONTROLPARENT); mPropertySheet->ModifyStyleEx(0, WS_TABSTOP); mPropertySheet->ModifyStyleEx(0, WS_MAXIMIZE); // now, I want to resize windows for almost maximum size CRect rect; GetClientRect(&rect); int Width = rect.Width()-7; int mHeight = rect.Height()-7; mPropertySheet->SetWindowPos(NULL, 7, 7, mWidth, mHeight, SWP_NOZORDER); ================ The SetWindowPos doesn't do what I expect. Why the windows doesn't resize? It has the size - I designed in the Resource. Regards mwgomez/Poland

      R Offline
      R Offline
      Rage
      wrote on last edited by
      #2

      gomez_a wrote:

      It has the size - I designed in the Resource.

      And this is exactely what you request by doing this:

      // now, I want to resize windows for almost maximum size
      CRect rect;
      GetClientRect(&rect); // Get size in resource
      int Width = rect.Width()-7;
      int mHeight = rect.Height()-7;

      // Give control the resource size again !! (start + height/widht -7 = 7 + h/w - 7 = h/w)
      mPropertySheet->SetWindowPos(NULL, 7, 7, mWidth, mHeight, SWP_NOZORDER);

      If you want to maximize your widows, use GetSystemMetrics to get the screen size, and use SetWindowPos to update your window size:

      int cx,cy;
      cx=GetSystemMetrics(SM_CXSCREEN);
      cy=GetSystemMetrics(SM_CYSCREEN);
      mPropertySheet->SetWindowPos(NULL, 7, 7, cx-7, cy-7, SWP_NOZORDER);

      ~RaGE();

      G 1 Reply Last reply
      0
      • R Rage

        gomez_a wrote:

        It has the size - I designed in the Resource.

        And this is exactely what you request by doing this:

        // now, I want to resize windows for almost maximum size
        CRect rect;
        GetClientRect(&rect); // Get size in resource
        int Width = rect.Width()-7;
        int mHeight = rect.Height()-7;

        // Give control the resource size again !! (start + height/widht -7 = 7 + h/w - 7 = h/w)
        mPropertySheet->SetWindowPos(NULL, 7, 7, mWidth, mHeight, SWP_NOZORDER);

        If you want to maximize your widows, use GetSystemMetrics to get the screen size, and use SetWindowPos to update your window size:

        int cx,cy;
        cx=GetSystemMetrics(SM_CXSCREEN);
        cy=GetSystemMetrics(SM_CYSCREEN);
        mPropertySheet->SetWindowPos(NULL, 7, 7, cx-7, cy-7, SWP_NOZORDER);

        ~RaGE();

        G Offline
        G Offline
        gomez_a
        wrote on last edited by
        #3

        I have the same effect like before... Regards mwgomez

        1 Reply Last reply
        0
        • G gomez_a

          I prepared (in Visual Studio 2003 + MFC) "Dialog Based" Application. Now, I have one dialog window where I want to add two book marks. I have two objects: class DlgPage1 : public CPropertyPage // variable mPage1 class DlgPage2 : public CPropertyPage // variable mPage2 In the resource window I have done two dialogs with properties: Style = child Border = thin TitleBar = true Disabled = true In the OnInitDialog (main window) function I have code: mPropertySheet = new CPropertySheet("Simple PropertySheet"); mPage1 = new DlgPage1(); mPage2 = new DlgPage2(); mPropertySheet->AddPage(mPage1); mPropertySheet->AddPage(mPage2); mPropertySheet->Create(this, WS_CHILD | WS_VISIBLE, 0); mPropertySheet->ModifyStyleEx(0, WS_EX_CONTROLPARENT); mPropertySheet->ModifyStyleEx(0, WS_TABSTOP); mPropertySheet->ModifyStyleEx(0, WS_MAXIMIZE); // now, I want to resize windows for almost maximum size CRect rect; GetClientRect(&rect); int Width = rect.Width()-7; int mHeight = rect.Height()-7; mPropertySheet->SetWindowPos(NULL, 7, 7, mWidth, mHeight, SWP_NOZORDER); ================ The SetWindowPos doesn't do what I expect. Why the windows doesn't resize? It has the size - I designed in the Resource. Regards mwgomez/Poland

          S Offline
          S Offline
          Stephen Hewitt
          wrote on last edited by
          #4

          Does mPropertySheet actually represent a dialog control? Normally in MFC you'll have an instance of a C++ class for a dialog control in the header of the dialog and DDX_Control in your DoDataExchange handler to associate the class with the control. i.e.:

          // In header file.
          class CMyDialog : public CDialog
          {
          // Stuff here
          CEdit m_EditControl;
          // More stuff here
          };
          
          void CMyDialog::DoDataExchange(CDataExchange* pDX)
          {
              CDialog::DoDataExchange(pDX);
              //{{AFX_DATA_MAP(MyDialog)
              DDX_Control(pDX, IDC_EDIT1, m_EditControl);
              //}}AFX_DATA_MAP	
          }
          

          In your code it looks like you're just creating a CPropertySheet but I can't see where you're associating it with a control on your dialog. Steve

          G 1 Reply Last reply
          0
          • G gomez_a

            I prepared (in Visual Studio 2003 + MFC) "Dialog Based" Application. Now, I have one dialog window where I want to add two book marks. I have two objects: class DlgPage1 : public CPropertyPage // variable mPage1 class DlgPage2 : public CPropertyPage // variable mPage2 In the resource window I have done two dialogs with properties: Style = child Border = thin TitleBar = true Disabled = true In the OnInitDialog (main window) function I have code: mPropertySheet = new CPropertySheet("Simple PropertySheet"); mPage1 = new DlgPage1(); mPage2 = new DlgPage2(); mPropertySheet->AddPage(mPage1); mPropertySheet->AddPage(mPage2); mPropertySheet->Create(this, WS_CHILD | WS_VISIBLE, 0); mPropertySheet->ModifyStyleEx(0, WS_EX_CONTROLPARENT); mPropertySheet->ModifyStyleEx(0, WS_TABSTOP); mPropertySheet->ModifyStyleEx(0, WS_MAXIMIZE); // now, I want to resize windows for almost maximum size CRect rect; GetClientRect(&rect); int Width = rect.Width()-7; int mHeight = rect.Height()-7; mPropertySheet->SetWindowPos(NULL, 7, 7, mWidth, mHeight, SWP_NOZORDER); ================ The SetWindowPos doesn't do what I expect. Why the windows doesn't resize? It has the size - I designed in the Resource. Regards mwgomez/Poland

            V Offline
            V Offline
            vallikumar
            wrote on last edited by
            #5

            Hi, I am not clear about your problem. Any how, I'll tell you what I feel about this If nFlags is nonzero in ModifyStyleEx, then the fuction calls the Win32 function SetWindowPos and redraw the window. So please take a look into all the parameters in ModifyStyleEx function call. better remove the function calls of ModifyStyleEx and use only SetWindowPos. Once after getting correct try to add the above three function calls of ModifyStyleEx on by one. :cool: regards Vallikumar A

            G 1 Reply Last reply
            0
            • S Stephen Hewitt

              Does mPropertySheet actually represent a dialog control? Normally in MFC you'll have an instance of a C++ class for a dialog control in the header of the dialog and DDX_Control in your DoDataExchange handler to associate the class with the control. i.e.:

              // In header file.
              class CMyDialog : public CDialog
              {
              // Stuff here
              CEdit m_EditControl;
              // More stuff here
              };
              
              void CMyDialog::DoDataExchange(CDataExchange* pDX)
              {
                  CDialog::DoDataExchange(pDX);
                  //{{AFX_DATA_MAP(MyDialog)
                  DDX_Control(pDX, IDC_EDIT1, m_EditControl);
                  //}}AFX_DATA_MAP	
              }
              

              In your code it looks like you're just creating a CPropertySheet but I can't see where you're associating it with a control on your dialog. Steve

              G Offline
              G Offline
              gomez_a
              wrote on last edited by
              #6

              I was based on the book: "Visual C++ Bible" Richard C.Leinecker, Tom Archer. There are samples how to create instance of the classes CPropertyPage, CPropertySheet. There is no associating with a Control and it works. But there is also a sample - how to create this classes in existing Dialog. I wrote it in my sample - and there is no right effect :) (I think it will be a little problem, but I am interesting in solve it). Regards mwgomez

              1 Reply Last reply
              0
              • V vallikumar

                Hi, I am not clear about your problem. Any how, I'll tell you what I feel about this If nFlags is nonzero in ModifyStyleEx, then the fuction calls the Win32 function SetWindowPos and redraw the window. So please take a look into all the parameters in ModifyStyleEx function call. better remove the function calls of ModifyStyleEx and use only SetWindowPos. Once after getting correct try to add the above three function calls of ModifyStyleEx on by one. :cool: regards Vallikumar A

                G Offline
                G Offline
                gomez_a
                wrote on last edited by
                #7

                It is my code: // CSheet *sheet: class CSheet : public CPropertySheet sheet = new CSheet("Sheet"); // CDlg1 and CDlg2 properties: // style = child // border = Thin // Disabled = TRUE // //CDlg1 *pg1: class CDlg1 : public CPropertyPage pg1 = new CDlg1(); //CDlg2 *pg2: class CDlg2 : public CPropertyPage pg2 = new CDlg2(); sheet->AddPage(pg1); sheet->AddPage(pg2); sheet->Create(this, WS_CHILD | WS_VISIBLE, 0); sheet->SetWindowPos(&CWnd::wndTopMost, 12, 12, 578, 578, SWP_NOZORDER); sheet->ModifyStyleEx(0, WS_EX_CONTROLPARENT, SWP_NOZORDER); sheet->ModifyStyleEx(0, WS_TABSTOP, SWP_NOACTIVATE); But it still desn't work. Have I any mistake? I thought - it is simple. I have an example from the book: "Visual C++ 6 Bible". (: Regards mwgomez

                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