[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


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


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

649 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