Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » How to remove minimize and maximize button on CMDIFrameWnd? Collapse All
Subject Author Date
delu qiu Jul 21, 2006 - 10:33 AM

Hi,

How to remove minimize and maximize button on CMDIFrameWnd?
the frame window minimized when click maximize button.

Technical Support Jul 23, 2006 - 12:23 PM

You can remove the WS_MINIMIZE and WS_MAXIMIZE styles from your frame window. This can be done in the PreCreateWindow() virtual method which should call the parent class method first and then invoke the cs.style &= ~(WS_MINIMIZE|WS_MAXIMIZE) code. Another solution is to modify the system menu of the main frame window in the OnCreate() method. You should invoke the GetSystemMenu(FALSE) code to get a CMenu pointer that represents the system menu of your main frame window. Just disable the SC_MAXIMIZE and SC_MINIMIZE commands in this menu using the CMenu::EnableMenuItem() method.

delu qiu Jul 26, 2006 - 9:36 AM

I tried both way, neither of them works.

this is my code:
class CMainFrame
    : public CExtNCW < CMDIFrameWnd >
{
....
}

class CMainView
    :public CExtWA < CExtWS < CExtAFV < CFormView > > >
{
.....
}

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    bClosed=FALSE;
    CRect cRect;
    cRect.right = GetSystemMetrics (SM_CXSCREEN);
    cRect.top = GetSystemMetrics (SM_CYSCREEN)
                - GetSystemMetrics(SM_CYSCREEN) * 2;

    cRect.left = cRect.right - 150;
    cRect.bottom = cRect.top + GetSystemMetrics(SM_CYCAPTION) +
                 GetSystemMetrics(SM_CYSCREEN) * 2;

    if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
        return -1;
    
    // TODO: Add your specialized creation code here
    CWinApp * pApp = ::AfxGetApp();
    ASSERT( pApp != NULL );
    ASSERT( pApp->m_pszRegistryKey != NULL );
    ASSERT( pApp->m_pszRegistryKey[0] != _T(’\0’) );
    ASSERT( pApp->m_pszProfileName != NULL );
    ASSERT( pApp->m_pszProfileName[0] != _T(’\0’) );

    ASSERT( pApp->m_pszProfileName != NULL );
    g_CmdManager->ProfileSetup(
        pApp->m_pszProfileName,
        GetSafeHwnd()
        );
    VERIFY(
        g_CmdManager->UpdateFromMenu(
            pApp->m_pszProfileName,
            IDR_MAINFRAME
            )
        );
    g_CmdManager->UpdateFromToolBar( pApp->m_pszProfileName, IDR_MAINFRAME8 );
    g_CmdManager->UpdateFromToolBar( pApp->m_pszProfileName, IDR_MAINFRAME9 );

    UINT arrCommandIDs[] = { ID_APP_EXIT,
                            ID_APP_BACK,
                            ID_APP_HELP,
                            ID_MSG_DOWNLOAD,
                            ID_MSG_PRINT,
                            ID_APP_ABOUT};
    if( !m_wndToolBar.Create(_T( "iflash Toolbar" ),
                     this,
                     AFX_IDW_TOOLBAR
        )
        )
    {
        TRACE0( "Failed to create toolbar" );
        return -1;
    }
    m_wndToolBar.SetButtons( arrCommandIDs, sizeof(arrCommandIDs)/sizeof(arrCommandIDs[0]) );
    m_wndToolBar.InitContentExpandButton();

    
    bBigBar=TRUE;

    
    if (!m_wndSplitter.CreateStatic(this,
                                    1,
                                    2,
                                    WS_CHILD | WS_VISIBLE,
                                    AFX_IDW_PANE_FIRST
                                    ))
        return FALSE;

    // First, build the view context structure
    CCreateContext ccx;
    CCreateContext ccx1;

    // Designate the class from which to build the view
    ccx.m_pNewViewClass = RUNTIME_CLASS(CMainView);
    ccx1.m_pNewViewClass = RUNTIME_CLASS(CMessageView);

    if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CMainView), CSize(GetSystemMetrics (SM_CXSCREEN)-DEF_SPLITPOS, 100), &ccx) ||
        !m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CMessageView), CSize(DEF_SPLITPOS, 100), &ccx))
    {
        m_wndSplitter.DestroyWindow();
        return FALSE;
    }

    // Using the structure, create a view
    m_pMainView = DYNAMIC_DOWNCAST( CMainView, m_wndSplitter.GetPane (0,0));

    // Did we succeed ?
    if ( !m_pMainView )
    {
        TRACE0("Creation of view failed");
    }
    
    // Do layout recalc
    m_wndSplitter.SetColumnInfo(0,GetSystemMetrics (SM_CXSCREEN),300);
    m_wndSplitter.SetColumnInfo(1,20,20);
    m_pMainView->SetScaleToFitSize(CSize(800,500));

    // Order it to resize the parent window to fit
    m_pMainView->ResizeParentToFit(FALSE);
    

    m_pRightView = DYNAMIC_DOWNCAST( CMessageView, m_wndSplitter.GetPane (0,1));
    

    if ( !m_pRightView)
    {
        TRACE0("Creation of view failed");
        return 0;
    }

    CMenu * menu=GetSystemMenu(FALSE);
    menu->EnableMenuItem (SC_MINIMIZE,MF_DISABLED);


    return 0;
}


Technical Support Jul 26, 2006 - 12:17 PM

We are sorry. Please use the following line in the PreCreateWindow() virtual method:

cs.style &= ~(WS_MINIMIZEBOX|WS_MAXIMIZEBOX);