Solved

Creating Office 97 Menus

Posted on 1997-05-03
4
281 Views
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.)
0
Comment
Question by:bruceg050397
  • 3
4 Comments
 
LVL 4

Accepted Solution

by:
StevenB earned 340 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.

  Steven.
0
 
LVL 4

Expert Comment

by:StevenB
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.
0
 

Author Comment

by:bruceg050397
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.

Bruce
0
 
LVL 4

Expert Comment

by:StevenB
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.

  Steven.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

832 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