Jump to content
Sign in to follow this  
Johan

Rightclick / Leftclick

Recommended Posts

Johan

I have a form in the shape of a gif file. When I click it I would like one thing to happen and when I leftclick it I like to have a context menu showed, here is my code:

Opt("TrayIconHide", 1)

;Opt("GUIOnEventMode", 1)

#include <GUIConstants.au3>

$form=GUICreate("", 32, 32, 500, 10,$WS_POPUP,BitOr($WS_EX_LAYERED,0)) ;,$WS_EX_MDICHILD),$gui)

FileInstall("print.gif", @TempDir & "\print.gif")

$pic=GUICtrlCreatePic(@TempDir & "\print.gif",0,0, 0,0)

Guictrlsetonevent($pic,"FormClicked")

$trackmenu = GuiCtrlCreateContextMenu ($pic)

$aboutitem = GuiCtrlCreateMenuitem ("About",$trackmenu)

; next one creates a menu separator (line)

GuiCtrlCreateMenuitem ("",$trackmenu)

$exititem = GuiCtrlCreateMenuitem ("Exit",$trackmenu)

GUISetState()

While 1

$msg = GuiGetMsg()

If $msg = $exititem Or $msg = -3 Or $msg = -1 Then FormClicked()

If $msg = $aboutitem Then Msgbox(0,"About","A simple example with a context menu!")

if $msg = $GUI_EVENT_PRIMARYDOWN then FormClicked()

Wend

if I use GUIOnEventMode then the rightclick works but the context menu don't and if I don't use GUIOnEventMode then the context menu works but the rightclick don't. Can this be solved?

Edited by Johan

Share this post


Link to post
Share on other sites
Johan

Ok,

I found how to do it.

Opt("TrayIconHide", 1)

#include <GUIConstants.au3>

$form=GUICreate("", 32, 32, 500, 10,$WS_POPUP,BitOr($WS_EX_LAYERED,0)) ;,$WS_EX_MDICHILD),$gui)

FileInstall("print.gif", @TempDir & "\print.gif")

$pic=GUICtrlCreatePic(@TempDir & "\print.gif",0,0, 0,0)

$trackmenu = GuiCtrlCreateContextMenu ($pic)

$aboutitem = GuiCtrlCreateMenuitem ("About",$trackmenu)

; next one creates a menu separator (line)

GuiCtrlCreateMenuitem ("",$trackmenu)

$exititem = GuiCtrlCreateMenuitem ("Exit",$trackmenu)

GUISetState()

While 1

$msg = GuiGetMsg()

If $msg = $exititem Or $msg = -3 Or $msg = -1 Then FormClicked()

If $msg = $aboutitem Then Msgbox(0,"About","A simple example with a context menu!")

if $msg = $pic then FormClicked()

Wend

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×