Champak Posted October 13, 2023 Posted October 13, 2023 I have a function that spawns the following gui. I want to be able to click on the graphics created to activate a different function but I don't know how. I made $hGraphics and $hGraphics a global variable (I didn't know which to use to accomplish this) at the top of my script and put it as a case in the main loop, but that just constantly calls it without actually clicking on the pic. I tried various ways in notify and command, but it doesn't seem to be picked up. How can I accomplish this? $GuiProductImage = GUICreate($sName, $sImageDimension, $sImageDimension, $sLeft, $sTop, $sPopUp, Default, $sParent) GUISetBkColor ( 0xffffff, $GuiProductImage ) GUISetState(@SW_SHOWNOACTIVATE) $hGraphics = _GDIPlus_GraphicsCreateFromHWND($GuiProductImage) $hGraphic2 = _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap_Scaled, $adjustedX, $adjustedY) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_BitmapDispose($hBitmap_Scaled) _GDIPlus_Shutdown() ; GUIDelete($GuiProductImage) Note: I found a different solution, but now I'm just curious of getting the image to register a press.
Andreik Posted October 13, 2023 Posted October 13, 2023 (edited) Click on what picture? It's just a draw over the GUI. You can check if a click was pressed inside the GUI or use a picture control and check if it was clicked. Something like this: ; Probably you already have the $hBitmap_Scaled already $GuiProductImage = GUICreate($sName, $sImageDimension, $sImageDimension, $sLeft, $sTop, $sPopUp, Default, $sParent) $cPic = GUICtrlCreatePic('', 0, 0, $sImageDimension, $sImageDimension) GUISetBkColor(0xffffff, $GuiProductImage) $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_Scaled) _WinAPI_DeleteObject(GUICtrlSendMsg($cPic, 0x0172, 0, $hHBITMAP)) _WinAPI_DeleteObject($hHBITMAP) GUISetState(@SW_SHOWNOACTIVATE) While True Switch GUIGetMsg() Case -3 ExitLoop Case $cPic MsgBox(0, '', 'Clicked') EndSwitch WEnd Edited October 13, 2023 by Andreik
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now