Creating Office 97 Menus

Posted on 1997-05-03
Medium Priority
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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3

Accepted Solution

StevenB earned 1020 total points
ID: 1335870
 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

ID: 1335871
 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

ID: 1335872
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

ID: 1335873
 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

777 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