WTL - OwnerDrawn menus 
Author Message
 WTL - OwnerDrawn menus

Hi,

I'm deriving a class off of the WTL's CCommandBarCtrlImpl in an attempt to
recreate the new look of Office XP or DevStudio.NET.  I'm running into a
problem, however, as I cannot seem to get the WM_DRAWITEM message sent to
draw the 'root' menus on the screen ( those which appear at app startup ).
I've overridden the AttachMenu function as follows to change the base menus
to be owner drawn ( the base command bar control doesn't ):

long CCoolMenu::AttachMenu ( HMENU hMenu ) {
 ATLASSERT(::IsMenu(hMenu));

 for ( int i = 0; i < ::GetMenuItemCount ( hMenu ); i++ ) {

  MENUITEMINFO mii;

  char menuString [MAX_MENU_STRING];

  mii.fMask = MIIM_CHECKMARKS | MIIM_DATA | MIIM_ID | MIIM_STATE |
MIIM_SUBMENU | MIIM_TYPE;
  mii.fType = MFT_STRING;
  mii.dwTypeData = menuString;
  mii.cch = MAX_MENU_STRING;

  mii.cbSize = sizeof ( mii );
  ::GetMenuItemInfo ( hMenu, i, TRUE, &mii );
  int errorval = GetLastError();

  mii.fType = MFT_OWNERDRAW;
  ::SetMenuItemInfo( hMenu, i, TRUE, &mii );
  errorval = GetLastError();

 }

 CCommandBarCtrlImpl<CCoolMenu>::AttachMenu( hMenu );

 return 0;

Quote:
}

This seems to almost work.  The errorval variable thrown in to test shows
that the menu is being set without error.  The app starts up, and no menu
information is displayed at the top.  However, I put breakpoints in the
CCommandCtrlImpl OnDrawItem and OnMeasureItem functions, and they are only
receiving messages when I click to open a submenu.  I have also intercepted
the WM_DRAWITEM and WM_MEASUREITEM commands in my own class, with the same
results.  So now I am confused.  Is it possible to ownerdraw the root menu's
at all?  Or will I be forced to do something more drastic?

Thanks, this is starting to give me a headache...

--russell



Wed, 25 Feb 2004 09:12:58 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. WTL - Very new to WTL - Trying to insert new COM object in WTL

2. Ownerdraw context menu fails.

3. OwnerDraw menu problems on Win95

4. Colors come up wrong in OwnerDraw Menu

5. Ownerdrawn Menu

6. Drawing the check mark etc for OwnerDraw menu

7. OwnerDraw menus

8. Help with ownerdraw menu!

9. Please help me with a ownerdraw menu problem!

10. OwnerDrawn Menu font problem

11. ownerdrawn menu

12. ownerdrawn menu problems

 

 
Powered by phpBB® Forum Software