Program interface multi-mode display

zhaozj2021-02-08  215

Program interface multi-mode display

Author: Xu Jing Zhou

Download Related Example Source Codes (http://www.vchelp.net/itbookreview/view_paper.asp?paper_id=311)

If you have used the RealPlayer player, you must not be strange to its multi-mode display mode! RealPlayer has a normal and streamlined display mode. We sometimes want to implement a similar function on your own program interface, how do you implement it? Let's take the example of a multi-mode display program that uses VC6.0 to show you how it implements similar functions. As shown in the figure below: (Figure 1) Normal display mode; (Figure 2) Simple display mode, no view; (Figure 3), streamline display mode, only the tool bar.

Figure one

Figure II

Figure three

Basic composition of ideas:

The implementation principle is simple, as long as the form size, the customer area size, the toolbar size, the state, the size, and the size of the title bar can be calculated based on different display modes, the height of different new forms (the key is To recall the height, width). Such as: Simple Display Mode (no visual mode), the width is unchanged, the height = Form height - the height of the customer area - status bar height - the height of the border. Streamline display mode (in toolbeans only), the width is unchanged, first hide menu, height = title bar height toolbar height border height can be used. Normal display mode, I don't want to say it! In fact, it is so simple, RealPlayer is a width and height change and calculates. This example only changes the height, the width is unchanged, but the basic principle is the same. Let's take a look at its code implementation!

Key code implementation:

I have made a mandate, this sample program can be implemented simply. When the nViewType is 0, for normal display mode, the pass value is 1, for the simple display mode, the pass value is 2, and the display mode is streamlined.

Void CMAINFRAME :: ViewMode (int NViewType)

{

CRECT ClientRect;

CRECT WINDOWRECT;

CRECT TOOLBARRECT;

CRECT STATUSBARRECT;

/ / Get the size of the form, customer zone and tools

WindowRect = m_windower;

ClientRect = m_client;

M_WndToolBar.GetWindower (& ToolbarRect);

// Get the size of the border and the title bar

Int borderheight = getSystemmetrics; SM_CYBORDER

INT CAPTIONHEIGHT = GetSystemMetrics (SM_CYCAPTION);

/ / Get the size of the status

CSTATUSBAR * PSTATUS = (cstatusbar *) AFXGetApp () -> m_pmainwnd-> getDescendantWindow (AFX_IDW_STATUS_BAR);

Pstatus-> getWindowRect (& statusbarRect);

// Stop the toolbar

DockControlbar (& M_WndToolbar);

INT CompactCX; // New Form Wide

Int Compactcy; // High new form

// Display in a variety of modes

Switch (nViewType) {

Case 0: // Normal display mode

{

// Display menu

IF (HMenu! = NULL)

:: SetMenu (M_HWND, HMENU);

// Display status strip

PStatus-> showwindow (sw_show);

// New form wide, high

Compactcx = windowRect.width ();

Compactcy = windowRect.height ();

}

Break;

Case 1: // Simple display mode

{

// Display menu

IF (HMenu! = NULL)

:: SetMenu (M_HWND, HMENU);

// Hidden status bar

PStatus-> showwindow (sw_hide);

// New form wide, high

Compactcx = windowRect.width ();

Compactcy = WindowRect.height () - ClientRect.Height () ToolbarRect.height () - BorderHeight;

}

Break;

Case 2: // Streamlined Mode

{

// Hide menu

HMENU = :: getMenu (m_hwnd);

:: SetMenu (M_HWND, NULL);

// Hidden status bar

PStatus-> showwindow (sw_hide);

// New form wide, high

Compactcx = windowRect.width ();

Compactcy = CaptionHeight ToolbarRect.Height () BorderHeight * 2;

}

Break;

}

/ / Set a new form display

SetwindowPos (& Wndtop, WindowRect.Left, WindowRect.top, Compactcx, Compactcy, SWP_SHOWINDOW);

}

The details of the specific implementation of the above part of the code can be done after downloading the instance code, and the source code can be carefully viewed (in detail).

Contact information:

Email: jingzhou_xu@163.com

Future Studio (Future Studio)

转载请注明原文地址:https://www.9cbs.com/read-2130.html

New Post(0)