Implementation of Easter Eggs in XP Style

zhaozj2021-02-08  234

Implementation of Easter Eggs in XP Style

Author: Xu Jing Zhou

Download related sample source code (http://www.vchelp.net/itbookreview/view_paper.asp?paper_id=317)

If you use the Microsoft Office Series product, you will know that many of them have hidden in the "About" dialog box, which only when the user clicks on some special keyboards or mouse buttons, these features will only be displayed. (As a result of the Easter Eggs). What is your realization? Below, I have made an example program that can tell you the basic principles they implement (in the example with a complete set of XP stylized interface design). As shown below: The picture is an XP style interface, and Fig. 2 is a realization interface similar to Easter eggs.

Figure one

Figure II

Basic composition of ideas:

The principle of implementation is simple, and the hidden portion is not displayed in the initial (the height of the dialog, the default height = total height - hidden part height), set a special keyboard or mouse button to activate it. This sample program uses two ways, keyboard hot keys, and mouse hot keys, where the keyboard hotkey is simultaneously pressing the Ctrl Alt F3 key in the "About" dialog to activate hidden information, the mouse heat key is, "About" "Press the CTRL button in the dialog box, double-click the mouse button in the logo moving image to activate hidden information. Let us take a look at its specific implementation!

Key code implementation:

1. The hidden portion is not displayed by default.

#define WM_SHOWHOTKEY WM_USER 101 // Custom System Hot Key Message

Bool caboutdlg :: oninitdialog ()

{

// "About" dialog box can shrink

CRECT RECT1, RECT2; / / Dialog Seasonal

Getdlgitem (IDC_DYCREDITS) -> getWindowRect (Rect1);

Getdlgitem (IDC_CopyRight) -> getWindowRect (Rect2);

m_nreducedheight = Rect1.Height () (Rect1.top -Rect2.bottom) / 2; // After shrinking the form height

DLGRect.bottom - = (Rect1.Height () (Rect1.top -Rect2.bottom) / 2);

MoveWindow (& DLGRECT); / / If you want to display the dialog starting dynamic effect, you cannot use this sentence.

m_bvertical = false; // Default Continue dialog

// Register the system hotkey, used to display hidden information

RegisterhotKey (GetsafehWnd (), WM_SHOWHOTKEY, MOD_ALT | MOD_CONTROL, VK_F3);

Return True; // Return True UnsS you set the focus to a control

// Exception: OCX Property Pages SHOULD RETURN FALSE

}

2, hidden information activation or hidden

// Function: Whether to honor

Void Caboutdlg :: ONMORE ()

{

m_bvertical =! m_bvertical; if (m_bvertage == false) // does not display

{

Setdlgitemtext (ID_MORE, _T ("more >>"));

SizeWindow (M_nReducedheight, true);

}

ELSE // Display

{

Setdlgitemtext (ID_MORE, _T ("<< Hide"));

SizeWindow (M_nReducedheight, False);

}

UpdateWindow ();

}

// Function: Stretch or Contract dialog

Void Caboutdlg :: SizeWindow (Int ReduceHeight, Bool Bextend)

{

CRECT RC;

GetWindowRect (& RC);

IF (bextend)

{

For (int i = 0; i

{

Rc.bottom

MoveWindow (& RC);

}

}

Else

{

For (int i = 0; i

{

RC.BOTTOM ;

MoveWindow (& RC);

}

}

}

3, in a special keyboard and mouse hot key to hide information display

// Function: Mouse hot button, hold down the Ctrl key in the picture box, double-click the right mouse button to display, display hidden information.

Void Caboutdlg :: OnRbuttondblclk (uint nflags, cpoint point)

{

IF (nflags == (mk_control | mk_rbutton))

{

CPICTureex * Pabout = (cpictureex *) getdlgitem (IDC_FLAG);

CRECT RCABOUT;

Pabout-> getWindowRect (& rcabout);

Cpoint pt;

GetCursorpos (& PT);

IF (rcabout.ptinRect (PT))

Onmore ();

}

CDIALOG :: ONLBUTTONDBLCLK (NFLAGS, POINT);

}

// * Function: Keyboard hotkey Show hidden information

LResult Caboutdlg :: Onhotkey (WPARAM WPARAM, LPARAM LPARAM)

{

IF (WPARAM == WM_SHOWHOTKEY)

{

Onmore ();

}

Return 0;

}

4, don't forget the finishing work, destroy the registered system hotkey

// * Function: Processing work when the program is closed

Bool caboutdlg :: destroyWindow ()

{

// Log out of the registered system hotkey

UnregisterhotKey (GetsafehWnd (), WM_SHOWHOTKEY;

Return CDialog :: destroyWindow ();

}

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-2132.html

New Post(0)