Running Environment: VC6, 98/NT4
CPopup class
This class allows you to display controls in the pop-up mode.
A pop-up control becomes visible when it is focused and can be displayed outside the program framework.
For example, you can display a tree control under a button. Take a look at the sample project to learn about other usage of this class.
Run:
ThisThe CPopup class is derived from CMiniFrameWnd. This class has the same basic framework as the floating tool. When CMiniFrameWnd becomes activated, this class allows one CFrameWnd or one CMDIFrameWnd to remain active. It seems that two frameworks are activated at the same time.
Not likeCMiniFrameWnd, CPopup has no title and boundary, it is just an inclusive"Pop-up"Control framework.
Simple class description:
Class CPopup: public CMiniFrameWnd
{
Public:
Bool Display (CWnd * pControl, CWnd * pCaller, CRect & rcCaller, IPopupCtrlEvent * pEvents = NULL );
Protected:
CPopup ();
Virtual ~ CPopup (){};
Void EndPopup (bool bAbort = false, bool bSetFocus = true );
DECLARE_DYNCREATE (CPopup)
};
Usage:
You must create a dynamic instance becauseIs automatic.
The display method is a unique public method of this class.
CreateThe CPopup object (through the CreateObject method) pops up your control.
Bool CPopup: Display (CWnd * pControl,
CWnd * pCaller,
CRect & rcCaller,
IPopupCtrlEvent * pEvents = NULL );
The first parameter is the control you need to bring up. You can specifyListbox, listctrl, treectrl,
Formview, activex ,...
The second parameter can be specified for youCaller. It is usually used to define the parent window of the pop-up window. This object is used to focus on it at the end of the pop-up operation. It can also be set to NULL.
ThirdThe CRect parameter specifies the position of the pop-up control on the screen. It may be a caller rectangle (as pushbutton) or an item rectangle (as a tool button ). It is not just a point, because it applies a small rule to the placement pop-up control.
Time-savingThe control is displayed in the lower left corner of the rectangle, but if there is not enough position to display the control, it can be displayed on the right and/or on the top.
The displayed size is the size of the control before display.T, it is not a rectangle size.
The last parameter points to an interface that defines some callbacks. See the following description.
This method returns a Boolean variable indicating whether the pop-up control is correctly displayed.
IPopupCtrlEvent Interface
Interface IPopupCtrlEvent
{
Virtual bool OnInit () = 0;
Virtual void OnShow () = 0;
Virtual void OnHide (bool bAbort) = 0;
Virtual int OnKeyDown (UINT nChar, UINT nRepCnt, UINT nFlags) = 0;
Virtual int OnLButtonDown (UINT nFlags, CPoint point) = 0;
Virtual int OnLButtonUp (UINT nFlags, CPoint point) = 0;
Virtual IPopupCtrlEvent * GetInterfaceOf (HWND hWnd) = 0;