Jump to content

Left-Click context menu AND Bitmap/Icon on button on shaped GUI


Recommended Posts

A: Could you possibly tell me how, or suggest how to open a context menu on a PRIMARY mouse button click - tried

; Script generated by GUIBuilder 9.4

#include "CoreIncludes.sin";GUIConstants, Chris Haney's Database, and my GetUser, GetDir and ModuleStart functions

SplashImageOn("splash.bmp",640,480)
Sleep(5000)
$GUI_Handle = GuiCreate("SSIP Anchor", 120, 120,(@DesktopWidth-170), (@DesktopHeight-170), $WS_POPUP)

$Button_1 = GuiCtrlCreateButton("", 0, 0, 120, 120, BitOr($BS_ICON, $BS_FLAT))
GUICtrlSetTip(-1, "Click Here to open the SSIP menu")
GUICtrlSetBkColor(-1, 0x0000FF)
GUICtrlSetImage(-1,"16icon.bmp")
$menu = GUICtrlCreateContextMenu()
$exit = GUICtrlCreateMenuItem("Exit",$menu)

_GuiRoundCorners($GUI_Handle, 0, 0, 120, 120, 120, 120)

GuiSetState()
While 1
 $msg = GuiGetMsg()
 Select
 Case $msg = $GUI_EVENT_CLOSE
  ExitLoop
 Case $msg = $Button_1
  MouseClick("menu")
 Case Else
 ;;;
 EndSelect
WEnd


;etc.

and...

B: In the above program the button loses the image when RoundCorners is applied. Can someone help me solve this?

Sorry if this is any inconvenience or really annoying, but I want this information so I can create a School Information Portal (just as a fun project). This code is for the "anchor" or core of the project.

Thanks

[size="4"]YOU SHALL NOT PARSE!![/size]
Link to comment
Share on other sites

#include <GUIConstants.au3>

Const $WM_CONTEXTMENU = 0x7B

$hwnd = GUICreate("", 300, 300)
$mybutt = GUICtrlCreateButton("Clickalicious", 50, 50, 100, 40)
$context = GUICtrlCreateContextMenu($mybutt)
GUICtrlCreateMenuitem("item1", $context)


GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then Exit
    
    If $msg = $mybutt Then DllCall("user32.dll", "ptr", "SendMessage", "hwnd", ControlGetHandle($hwnd, "", $mybutt), "int", $WM_CONTEXTMENU, "int", $mybutt, "int", 0)
WEnd

The DLLCall is something LazyCat put together some time I believe..

Link to comment
Share on other sites

DllCall("user32.dll", "ptr", "SendMessage", "hwnd", ControlGetHandle($hwnd, "", $mybutt), "int", $WM_CONTEXTMENU, "int", $mybutt, "int", 0)
Thankyou very much Helge. I will test the code and reply in a few minutes.

EDIT: This piece of code is wonderful! Thankyou very much!

Edited by Pa Callender
[size="4"]YOU SHALL NOT PARSE!![/size]
Link to comment
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
 Share

  • Recently Browsing   0 members

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