SetWindowPos
-
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
-
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
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();
-
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();
-
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
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 andDDX_Control
in yourDoDataExchange
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 -
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
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
-
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 andDDX_Control
in yourDoDataExchange
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. SteveI 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
-
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
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