[91ef65]: MenuTipper.h Maximize Restore History

Download this file

MenuTipper.h    53 lines (44 with data), 1.7 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
* Copyright (c) 2003-2007 Rony Shapiro <ronys@users.sourceforge.net>.
* All rights reserved. Use of the code is allowed under the
* Artistic License terms, as specified in the LICENSE file
* distributed with this code, or available from
* http://www.opensource.org/licenses/artistic-license.php
*/
////////////////////////////////////////////////////////////////
// Based on MSDN Magazine -- November 2003
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
// Compiles with Visual Studio .NET on Windows XP. Tab size=3.
//
#pragma once
#include "PupText.h"
#include "subclass.h"
//////////////////
// Implement menu tips for any MFC main window. To use:
//
// - instantiate CMenuTipManager in your CMainFrm
// - call Install
// - implement prompt strings the normal way: as resource strings w/ID=command ID.
//
class CMenuTipManager : public CSubclassWnd {
protected:
CPopupText m_wndTip; // home-grown "tooltip"
BOOL m_bMouseSelect; // whether menu invoked by mouse
BOOL m_bSticky; // after first tip appears, show rest immediately
public:
int m_iDelay; // tooltip delay: you can change
CMenuTipManager()
: m_iDelay(2000), m_bSticky(FALSE), m_bMouseSelect(FALSE) { }
~CMenuTipManager() { }
// call this to install tips
void Install(CWnd* pWnd) { HookWindow(pWnd); }
// Useful helpers to get window/rect of current active menu
static CWnd* GetRunningMenuWnd();
CRect GetMenuTipRect(HMENU hmenu, UINT nID);
// hook fn to trap main window's messages
virtual LRESULT WindowProc(UINT msg, WPARAM wp, LPARAM lp);
// Call these handlers from your main window
void OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hMenu);
void OnEnterIdle(UINT nWhy, HWND hwndWho);
};