Jump to content

Own context menu (with checkbox, radio, images [gif,jpg,bmp,ico], colored squares)


Recommended Posts

Posted (edited)

With this UDF you can create own context menus with following features:

- Show menu only, if an condition is TRUE (ie: number of entries in an listview must be greater than zero)

- Item types: Label, Checkbox, Radio, Image (jpg,bmp,gif), Icon (from Icon file, DLL), Shape --- Image files should be (nearly) quadratic. It is scaled to 16 x 16 pixel.

- The menu width is selectable. (Default 200 px)

- Left margin for general and additional for each menu item can be set (Indents are thus possible)

- The Items are default controls. You can Disable/Enable them, change text color, set state. But don't change background color. The background color is changed when the mouse is over the entry.

- If you like an other hover color, you can change it during the menu creation. Or later with an own function.

Edit:

Now I've made some changes:

- more speed during hover (decrease adlib time from 50 to 10 ms)

- if menu is shown and you click with right: on menu - nothing happens, outside menu - menu will closed

- renamed functions to _GUICtrlOwnContext_...

- used funkeys tip for Bkcolor

- In my Win 7 the hover color is clearly to see. If you've a problem with this, change color during creation of menu or general with changing the declaration:

Global $__iMNU_DEF_HOVERCOLOR = 0xEFFFFF

Edit 2:

- Added: For each entry you can create an submenu (1 level depth). Important: First, create all entries to the menu. Only then can sub-menus and their entries are created. See the example.

- Changed:Now the entire area of the entry is detected as an control. Also used Images.

- Changed: No more Adlib function, all processing inside window- and mouse- procedures.

- New Example for v0.9 (dont works with older version)

Current version: v0.9

So it looks:

v0.8

Posted Image

v0.9

post-8176-0-60100000-1342361879_thumb.jp

OwnContext.au3

OwnContext_Example.au3

OwnContext0.9.au3

OwnContext_Example0.9.au3

Edited by BugFix

Best Regards BugFix  

Posted

Very nice! Thanks for sharing. I will have use for it!

But there are a few things I have to say:

# MenuEx sounds like beeing an extension UDF of the original control. I would call it OwnMenu or GuiMenu or something, but that's just my opinion.

# On my Win7 the hover color is hard to see (nearly the same than the background color).

# And on my WinXP the color after control is hovered is wrong. I would change this line in __IsHover()

If $iID_LastOver <> 0 Then GUICtrlSetBkColor($iID_LastOver, 0x0F0F0F0)

to

If $iID_LastOver <> 0 Then GUICtrlSetBkColor($iID_LastOver, $GUI_BKCOLOR_TRANSPARENT)

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Posted

Very nice concept.

But there is a few problems that i have notice at the beginning:

* The hover is slow.

* If you right click on the gui after menu is shown, the menu is still there and hovering does not working.

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted

Thanks for testing and your replys.

@funkey

I'll change it with next version. (both points)

@MrCreatoR

* The hover is slow.

I'll decrease the Adlib-time to 10 ms. Than it should be fast enough. (atm i use 50 ms)

* If you right click on the gui after menu is shown, the menu is still there and hovering does not working.

I've never used right click if the menu is shown. So i have not seen this behavior. Thanks, that you've found this bug. I'll fix this with next version.

Best Regards BugFix  

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...