Page principale | Hiérarchie des classes | Liste par ordre alphabétique | Liste des composants | Liste des fichiers | Composants | Déclarations | Pages associées

MyMenu.h

Aller à la documentation de ce fichier.
00001 #if !defined(AFX_TITLEMENU_H__E69DD9C2_0FDA_11D6_9385_0060086FAC36__INCLUDED_)
00002 #define AFX_TITLEMENU_H__E69DD9C2_0FDA_11D6_9385_0060086FAC36__INCLUDED_
00003 
00004 #include "myString.h"
00005 
00006 #if _MSC_VER > 1000
00007 #pragma once
00008 #endif // _MSC_VER > 1000
00009 
00010 // Issue de http://www.codeproject.com/menu/titlemenu.asp
00011 /* Example *******************************************************************************
00012 
00013 LRESULT CALLBACK TestProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
00014 {
00015         static CMyMenu menu;
00016 
00017         switch (message)
00018         {
00019                 case WM_INIT:
00020                         menu = LoadMenu(hInst,MAKEINTRESOURCE(IDM_MAIN));
00021                         menu.AddTitle("Mon titre");
00022                         return TRUE;
00023 
00024                 case WM_MEASUREITEM:
00025                         menu.MeasureItem((LPMEASUREITEMSTRUCT)lParam);
00026                         return TRUE;
00027 
00028                 case WM_DRAWITEM:
00029                         menu.DrawItem((LPDRAWITEMSTRUCT)lParam);
00030                         return TRUE;
00031         }
00032     return FALSE;
00033 }
00034 
00035 *************************************************************************************** */
00036 
00037 #include "windows.h"
00038 
00039 class CMyMenu 
00040 {
00041         typedef UINT (CALLBACK* LPFNDLLFUNC1)(HDC,CONST PTRIVERTEX,DWORD,CONST PVOID,DWORD,DWORD);
00042 
00043         // Attributes
00044         protected:
00045                 HFONT m_hFont;
00046                 HMENU m_hMenu;
00047                 MyString m_title;
00048 
00049                 LPFNDLLFUNC1 dllfunc_GradientFill;
00050                 HINSTANCE hinst_msimg32;
00051                 long clRight;
00052                 long clLeft;
00053                 long clText;
00054                 bool bDrawEdge;
00055                 UINT flag_edge;
00056 
00057         protected:
00058                 bool m_bCanDoGradientFill;
00059                 HFONT CreatePopupMenuTitleFont();
00060                 BOOL GradientFill(      HDC hdc,
00061                                                         CONST PTRIVERTEX pVertex,
00062                                                         DWORD dwNumVertex,
00063                                                         CONST PVOID pMesh,
00064                                                         DWORD dwNumMesh,
00065                                                         DWORD dwMode);
00066                 
00067 
00068 
00069         // Implementation
00070         public:
00071                 CMyMenu();
00072 
00073                 void AddTitle(char *title);
00074                 void operator= (HMENU hMenu) { m_hMenu = hMenu; };
00075 
00076                 void SetColor(long cl) {clLeft=cl;};
00077                 void SetGradientColor(long cl) {clRight=cl;};
00078                 void SetTextColor(long cl) {clText=cl;};
00079                 // See ::DrawEdge for flag values
00080                 void SetEdge(bool shown,UINT remove=0,UINT add=0) {bDrawEdge=shown; (flag_edge^=remove)|=add;};
00081 
00082                 long GetColor() {return clLeft;};
00083                 long GetGradientColor() {return clRight;};
00084                 long GetTextColor() {return clText;};
00085                 long GetEdge() {return flag_edge;};
00086 
00087                 virtual ~CMyMenu();
00088                 virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMIS);
00089                 virtual void DrawItem(LPDRAWITEMSTRUCT lpDIS);
00090 
00091         private: 
00092 };
00093 
00095 
00096 //{{AFX_INSERT_LOCATION}}
00097 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00098 
00099 #endif // !defined(AFX_TITLEMENU_H__E69DD9C2_0FDA_11D6_9385_0060086FAC36__INCLUDED_)
00100 

Généré le Thu Apr 8 18:58:42 2004 pour SFC par doxygen 1.3.6