Page 2 of 4

Posted: Sun May 27, 2007 12:08 pm
by Flype
that's really neat. thank you for this.

now, the good idea is to add icons support :)

Posted: Mon May 28, 2007 10:16 am
by eesau
Updated the code in my first post (also put it between a single code-block for easier copy-pasting).

Added: Icon support! Add icons to menu items with:

Code: Select all

OfficeMenuSetIcon ( MenuID , ItemID , IconID )
Only native icons for now, will add support later for other image types. (See the "Tools"-menu for an example on how they look).

Added: Check marks. See "File"-menu for example.

Still to do:

- There's some slight flickering, I'll hopefully get rid of that by using memdc's.
- Fix code for Win98. Hard to do, since I don't have Win98 available right now, but I'll try anyway. The problems with the code and W98 is that previous Windows-versions had globally shared menu resources, which were very particular about what you did to them. W2K is probably the same. I'll see if I can find a fix though.
- Better icon support, different image formats and so on. Also, disabled icon states.
- Fix edit control (string gadget) context menus.
- Better coloring and color management.
- Slap the whole thing on a rebar, so we can get a menu identical to the ones in MS Office -products.

That's it for now, let me know if you find more bugs.

Posted: Mon May 28, 2007 10:45 am
by Derek
This is getting better and better. Like the icons.

Doesn't seem to flicker on my system.

Posted: Mon May 28, 2007 12:06 pm
by DoubleDutch
On Vista the chr(9) stuff to put the keyboard shortcut on the right (right justified) just seems to do a regular tab. Haven't looked on anything other than Vista, maybe the same on others?

Posted: Mon May 28, 2007 12:57 pm
by electrochrisso
Great Work
Works great on my clunky old laptop under 98se but I get odd character next to some menu items, probably where the icons should go?. otherwise it works smoothly.

Posted: Mon May 28, 2007 2:26 pm
by eesau
electrochrisso wrote:Great Work
Works great on my clunky old laptop under 98se but I get odd character next to some menu items, probably where the icons should go?. otherwise it works smoothly.
What menu items exactly? Do you see any icons or checkmarks at all?

Posted: Mon May 28, 2007 2:28 pm
by eesau
Updated the code to include yet another hack to work around the system menu, hopefully the last one needed.

Posted: Tue May 29, 2007 10:43 am
by Tranquil
The Code seems not to Work on Windows 2000 (completely patched). I have a normal menu here without any Icon and some ASCII Codes in there....

Image

Posted: Tue May 29, 2007 11:23 am
by ABBKlaus
@Tranquil
change this line to If OSVersion ( ) => #PB_OS_Windows_98

Code: Select all

Procedure InitOffice ( Window ) 
    
   If OSVersion ( ) => #PB_OS_Windows_98 ; #PB_OS_Windows_XP 
    
      If Not GetProp_ ( WindowID ( Window ) , "OfficeMenuHook" ) 
         
         SetProp_ ( WindowID ( Window ) , "WindowProc" , SetWindowLong_ ( WindowID ( Window ) , #GWL_WNDPROC , @OfficeWindowCallback ( ) ) ) 
    
         SetProp_ ( WindowID ( Window ) , "OfficeMenuHook" , SetWindowsHookEx_ ( #WH_CALLWNDPROC , @OfficeHook ( ) , #Null , GetWindowThreadProcessId_ ( WindowID ( Window ) , #Null ) ) ) 
       
         ProcedureReturn #True 
       
      EndIf 

   EndIf 

   ProcedureReturn #Null 

EndProcedure

Posted: Tue May 29, 2007 11:45 am
by techjunkie
Extremely super cool!! :D and very nice looking code! Great work!

Posted: Tue May 29, 2007 12:46 pm
by eesau
Added: Coloring that is system color-consistent and mimics Office about 99% accurately.

Posted: Tue May 29, 2007 1:02 pm
by Derek
Brilliant, will be using this in the programs I write for work. Thanks. :D

Posted: Tue May 29, 2007 1:06 pm
by eesau
Oh, almost forgot. A big thanks to everyone for the nice comments :wink:

Posted: Tue May 29, 2007 6:20 pm
by ABBKlaus
@eesau : again no run on Win98 :?:

Code: Select all

Procedure InitOffice ( Window ) 
    
   If OSVersion ( ) > #PB_OS_Windows_98 
    
      If Not GetProp_ ( WindowID ( Window ) , "OfficeMenuHook" ) 
         
         SetProp_ ( WindowID ( Window ) , "WindowProc" , SetWindowLong_ ( WindowID ( Window ) , #GWL_WNDPROC , @OfficeWindowCallback ( ) ) ) 
    
         SetProp_ ( WindowID ( Window ) , "OfficeMenuHook" , SetWindowsHookEx_ ( #WH_CALLWNDPROC , @OfficeHook ( ) , #Null , GetWindowThreadProcessId_ ( WindowID ( Window ) , #Null ) ) ) 
       
         ProcedureReturn #True 
       
      EndIf 

   EndIf 

   ProcedureReturn #Null 

EndProcedure 

Posted: Tue May 29, 2007 7:03 pm
by eesau
ABBKlaus wrote:@eesau : again no run on Win98 :?:

Code: Select all

If OSVersion ( ) > #PB_OS_Windows_98
Forgot to remove that :oops:

It *should* run on Win98, but I'll have to test some more.