Creating Office 97 Menus

Posted on 1997-05-03
Last Modified: 2010-04-06
I use Delphi 3.0.  Coolbars are great but they have not implemented the Office 97 CommandBar componets.  I want a menu that mimics the Office 97 Menu Coolbar.  All menu items behave as Internet Explorer style buttons and remain in the down state when an item's popup menu is showing.

How do I use Delphi's existing TMenu and TMainMenu to get the regions of menuitems and allow them to respond to mousemove messages (I havent' been able to get it to work), thus allowing me to determine using api calls what menu item the user is over and use another call to get the item's bounding region.  From there, I think I can learn to modify the canvas underneath the items to make them behave like IE buttons.  

Or, if I can't use the TMenu, how do I do it from scratch - I tried and got a lot of things to work but was unable to determine how to let other menu items continue to receive mousemove messages while one menu item's popup menu had captured the mouse (if I open files drop down menu and while its open move my mouse over the Edit menu item, the Edit menu item's menu drops down even though I never clicked outside of the file popup menu.  This drives me crazy since I can't figure out how they did it.)
Question by:bruceg050397
  • 3

Accepted Solution

StevenB earned 340 total points
Comment Utility
 O.K. There are a lot of questions here and rather than try and tackle tham all at once I'll give you the advice which I think will be the best launch pad for your problem. I'm happy to play arround with this and other ideas, but its probably best done with comments.
  The main issue seems to be getting hold of the fact that a mouse has moved off a component. This issue is central to most of the 'win97 look' problems and isn't obviously supported by delphi. The solution is to use the following two messages:

 message CM_MouseEnter;
 message CM_MouseLeave;

 If you put the following declarations in the protected are of your component:

    procedure CMMouseEnter(var msg:TMessage); message CM_MouseEnter;
    procedure CMMouseLeave(var msg:TMessage); message CM_MouseLeave;

  Then you can use the messages to trigger some boolean toggle of your own, rather than neccessarily using MouseCapture (Which you may have to turn off). Combined with MouseDown and MouseUp events and careful use of booleans you can get very good control of mouse movements over your components.

  I hope this is some help.


Expert Comment

Comment Utility
 It just struck me that perhaps I wasn't completely clear about mouse capture. MouseCapture is a normal property which can be set to false on the MouseLeave event which I mentioned previously. Careful experimentation with this should lead to some success.

Author Comment

Comment Utility
Steve, I'll give you an Excellent rating if you'll help with just this one aspect of the question which your answer touched on.  The crux of the problem is that I must use an api call to "popup" a standard windows popup menu when the user clicks on my button.  From that point on I have no control since the api does NOT provide a means to tell that popup menu to NOT capture the mouse.  So, how do I prevent a standard windows popup window from capturing the mouse.  Once it has done this (default windows functionality which I can't get my hands into) my hands are tied and no other control in the application will receive much less respond the onmouseenter and onmouseleave messages -- I tried this even before I asked this question.

Thanks for your time and sorry it took so long to respond, my wife just had our first child.


Expert Comment

Comment Utility
 Firstly :  Congratulations.

  Secondly :
  I was concentrating mainly on creating your own menu's from scratch, not a particulatly difficult task, if you use borderless forms and mouse events to control different aspects of the paint method and event triggering. I tend to favour this 'Start From Scratch' solution to problems myself, but thats just personal preference.
  If you are using standard Popup Menus then the calls to use are probably these:

  GetCapture(VOID) : Returns HWND of window with mouse capture.
  SetCapture(HWND) : Sets HWND to capture mouse.

  And most importantly

  ReleaseCapture(VOID) : Releases mouse capture from window in the current thread.

  I confess I havn't tested these calls myself, but I think they are what you're after. If I'm going down the wrong track again then let me know.


Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now