Windows Develop Bookmark and Share   
 index > Windows Forms General > AutoScaleMode::Font and FormWindowState::Maximized
 

AutoScaleMode::Font and FormWindowState::Maximized

Why doesn'tthis code snippet work properly? Form2 is an MDI child in an MDI main form. It only fails to maximise properly the first time it is opened. If the form is restored then maximised, it maximised properly. When another Form2 is opened, it maximises properly first time (though with a graphical glitch of the restored-sized window). Another point, when it is maximised, the right hand window edge is still visible (I've noticed this edge in the Scribble sample as well). Have I done something wrong?

void InitializeComponent(void)
{
this->SuspendLayout();
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; // Messes up maximisation when opening form
this->ClientSize = System::Drawing::Size(284, 264);
this->Name = L"Form2";
this->Text = L"Form2";
this->WindowState = System::Windows::Forms::FormWindowState::Maximized; // Doesn't maximize properly when using AutoScale::Font or AutoScale::Dpi. (Inherit and None modes cause no problem though.)
this->ResumeLayout(false);
}

Tim Mawr  Sunday, February 25, 2007 12:11 PM

It's the same old bug as in MFC.

How do you do this in .NET?

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)

{

if( !CMDIFrameWnd::PreCreateWindow(cs) )

return FALSE;

// TODO: Modify the Window class or styles here by modifying

// the CREATESTRUCT cs

cs.style = WS_OVERLAPPED | WS_CAPTION | FWS_ADDTOTITLE

| WS_THICKFRAME | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_MAXIMIZE;

return TRUE;

}

BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)

{

// TODO: Modify the Window class or styles here by modifying

// the CREATESTRUCT cs

if( !CMDIChildWnd::PreCreateWindow(cs) )

return FALSE;

cs.style = WS_CHILD | WS_VISIBLE | WS_OVERLAPPEDWINDOW | WS_MAXIMIZE | FWS_ADDTOTITLE;

return TRUE;

}

void CChildFrame::ActivateFrame(int nCmdShow)

{

// TODO: Modify this function to change how the frame is activated.

nCmdShow = SW_SHOWMAXIMIZED;

CMDIChildWnd::ActivateFrame(nCmdShow);

}

Tim Mawr  Tuesday, March 06, 2007 10:44 PM

You can use google to search for other answers

Custom Search

More Threads

• I Need Help With A Very Strange Problem!
• Combobox dynamic text update issue on SelectedIndexChanged event handler
• How to get the size of the up/down arrows of the Scrollbar?
• Windows menu in simple MDI forms...
• Create an User Interface like Windows Live Mail Desktop
• Open new form
• Tree View, How to put/get a grandchild node into/of selected child node of selected parent node in c#?
• ZedGraph
• error in reopening child form
• How Could I protect my application ?