Link to home
Start Free TrialLog in
Avatar of mallow
mallow

asked on

CFromview-disabling the close window

hello,
   i have a CFormView that my application automatically draw on it's client screen at the start of the application, this is because i specified in appwizard that i want a database view w/file support, so a form is automatically created for me, i want to disable the close window of this form, i want to disable the 'X' box at the upper right hand of the form, so that it cannot be clicked by the user at run time, and also, i want the form to be maximized when that application draws it at the start of the application, how can i do these?  please help, thanks, mallow
ASKER CERTIFIED SOLUTION
Avatar of Chaya
Chaya

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mallow
mallow

ASKER

hello, i tried the code above, i was successful in maximizing the window and graying the 'X' of the window, but it did not disable the 'close window' the 'X' can still be clicked and the it closed the window, do you know what is wrong?  please help
Wow! I checked it out and if the window is not maximixed, clicking the 'X' does nothing (as it should), but when maximized, it works as usual. By running Spy on the application, I discovered that when a child window is maximized the minimize, maximize and close buttons are considered bitmaps on the mainframe's window, and therefore not related to the child system menu. The roundabout that worked for me was to add a handler for OnSysCommand and having it ignore the SC_CLOSE command. The code is as follows:

void CChildFrame::OnSysCommand(UINT nID, LPARAM lParam)
{
// TODO: Add your message handler code here and/or call default
// THE FOLLOWING LINE IS WHAT I ADDED
      if (nID != SC_CLOSE )
//
            CMDIChildWnd::OnSysCommand(nID, lParam);
}

Adding this handler is a trifle tricky so I'll give you the full instructions.
* Open ClassWizard in the CChildFrame class.
* Pick the "Class Info" tab and in the "Message filter" drop-down list - choose "Window".
* Go back to the "Message maps" and in the "Messages" list box choose WM_SYSCOMMAND.

Good luck
Avatar of mallow

ASKER

it worked already, thanks!