nitekram Posted June 10, 2015 Share Posted June 10, 2015 (edited) I was wondering if anyone knew of a script that might get me started...objects that can be dragged into window and placed. Lines, circles, boxes, can be drawn in the window with the objects.I do not even know what to search for, so please be kind.I have been also searching for _ControlHover.au3 - but have had little luck. I had it linked in a post, but I reported the post as broken. Thanks for anyones help EDIT found the link for _ControlHover Edited June 11, 2015 by nitekram 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
nitekram Posted June 11, 2015 Author Share Posted June 11, 2015 Found this...thanks_GDIPlus_GraphicsRotateTransform() 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
nitekram Posted June 11, 2015 Author Share Posted June 11, 2015 (edited) So close, but this does not do what I want. It moves the object, no matter where the mouse cursor is...I would like it to only move the object if the mouse is on the image, and the mouse has been clicked. Any idea what function I am looking for? GDI is all new to me. EDITAlso, I am looking to add more than one image to move...not sure of the number, but at least 10 - 20 items? Edited June 11, 2015 by nitekram 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
nitekram Posted June 12, 2015 Author Share Posted June 12, 2015 Does anyone know if this is possible and what might I need to look at - function wise.I want to have a window with object (items) that can individually move around within that window - with user clicking mouse, picking up object and moving it to the new location. 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
UEZ Posted June 12, 2015 Share Posted June 12, 2015 nitekram,maybe you post what you did so far that we get an impression what you are doing! Thx. Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
nitekram Posted June 12, 2015 Author Share Posted June 12, 2015 I am pulling this example from the help file...I have seen apps where you have items on the side of the window, that can be moved into the main window and dragged around. I did a search for drag and drop on here, and went through 45 pages of posts, but could not seem to find what I was looking for - just something to get me to be able to ask more questions lol In the example below, the object is moved around, but if you click anywhere in the window, and move the mouse the object will move - I would not see this working from what I want to try and do - have multiple items to be dragged around - as a idea to work with, if you cut a picture in parts and put it in the window as a puzzle and move the items around to put it back together, but in my limited experience with GDI (not even sure that is what I want or will work?) I cannot even begin to figure it out.expandcollapse popup#include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> Global $g_hGUI, $g_hGraphics, $g_hBmp_Buffer, $g_hGfx_Buffer, $g_hImage Global $g_iMouseX, $g_iMouseY Example() Func Example() AutoItSetOption("GUIOnEventMode", 1) ; X64 running support Local $sWow64 = "" If @AutoItX64 Then $sWow64 = "\Wow6432Node" ;get AutoIt install dir Local $sRegPath = "HKLM\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt" Local $sFile = RegRead($sRegPath, "InstallDir") & "\Examples\GUI\logo4.gif" If Not FileExists($sFile) Then MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", $sFile & " not found!", 30) Exit EndIf $g_hGUI = GUICreate("GDI+", 800, 600) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetOnEvent($GUI_EVENT_SECONDARYDOWN, "_ResetGraphicsTransform") GUISetState(@SW_SHOW) _GDIPlus_Startup() $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) $g_hBmp_Buffer = _GDIPlus_BitmapCreateFromGraphics(800, 600, $g_hGraphics) $g_hGfx_Buffer = _GDIPlus_ImageGetGraphicsContext($g_hBmp_Buffer) $g_hImage = _GDIPlus_ImageLoadFromFile($sFile) GUIRegisterMsg($WM_LBUTTONDOWN, "WM_LBUTTONDOWN") GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL") GUIRegisterMsg($WM_MOUSEMOVE, "WM_MOUSEMOVE") GUISetState(@SW_SHOW) _Draw() While Sleep(10) WEnd EndFunc ;==>Example Func _ResetGraphicsTransform() _GDIPlus_GraphicsResetTransform($g_hGfx_Buffer) _Draw() EndFunc ;==>_ResetGraphicsTransform Func WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam $g_iMouseX = BitAND($lParam, 0x0000FFFF) $g_iMouseY = BitShift($lParam, 16) Return $GUI_RUNDEFMSG EndFunc ;==>WM_LBUTTONDOWN Func WM_MOUSEMOVE($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Switch BitAND($wParam, 0x0000FFFF) Case 1 Local $iX = BitAND($lParam, 0x0000FFFF) Local $iY = BitShift($lParam, 16) _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, $iX - $g_iMouseX, $iY - $g_iMouseY, True) $g_iMouseX = $iX $g_iMouseY = $iY _Draw() EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_MOUSEMOVE Func WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam Switch BitAND($wParam, 0x0000FFFF) Case 1 Local $iAngle = -3 If BitShift($wParam, 16) < 0 Then $iAngle = 3 Local $aMousePos[2][2] = [[1]] $aMousePos[1][0] = $g_iMouseX $aMousePos[1][1] = $g_iMouseY _GDIPlus_GraphicsTransformPoints($g_hGfx_Buffer, $aMousePos) _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, $aMousePos[1][0], $aMousePos[1][1]) _GDIPlus_GraphicsRotateTransform($g_hGfx_Buffer, $iAngle) _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, -$aMousePos[1][0], -$aMousePos[1][1]) Case Else Local $aInfo = GUIGetCursorInfo($g_hGUI) Local $iScale = 1.1 If BitShift($wParam, 16) < 0 Then $iScale = 0.9 _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, -$aInfo[0], -$aInfo[1], True) _GDIPlus_GraphicsScaleTransform($g_hGfx_Buffer, $iScale, $iScale, True) _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, $aInfo[0], $aInfo[1], True) EndSwitch _Draw() Return $GUI_RUNDEFMSG EndFunc ;==>WM_MOUSEWHEEL Func _Draw() _GDIPlus_GraphicsClear($g_hGfx_Buffer, 0xFFFFFFFF) _GDIPlus_GraphicsDrawImage($g_hGfx_Buffer, $g_hImage, 316, 266) Local $hPen = _GDIPlus_PenCreate(0xFF0000FF) _GDIPlus_GraphicsDrawRect($g_hGfx_Buffer, 300, 250, 200, 100, $hPen) _GDIPlus_PenDispose($hPen) Local $hBrush = _GDIPlus_BrushCreateSolid(0xFF00007F) Local $hFormat = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($hFormat, 1) Local $hFamily = _GDIPlus_FontFamilyCreate("Arial") Local $hFont = _GDIPlus_FontCreate($hFamily, 24, 2) Local $tLayout = _GDIPlus_RectFCreate(0, 360, 800) _GDIPlus_GraphicsDrawStringEx($g_hGfx_Buffer, "AutoIt rulez!", $hFont, $tLayout, $hFormat, $hBrush) _GDIPlus_GraphicsDrawImage($g_hGraphics, $g_hBmp_Buffer, 0, 0) _GDIPlus_FontDispose($hFont) $hFont = _GDIPlus_FontCreate($hFamily, 10) _GDIPlus_StringFormatSetAlign($hFormat, 0) DllStructSetData($tLayout, "X", 10) DllStructSetData($tLayout, "Y", 10) _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "left mousebutton = move graphic", $hFont, $tLayout, $hFormat, $hBrush) DllStructSetData($tLayout, "Y", 30) _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "mousewheel = zoom graphic", $hFont, $tLayout, $hFormat, $hBrush) DllStructSetData($tLayout, "Y", 50) _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "mousewheel + left mousebutton = rotate graphic", $hFont, $tLayout, $hFormat, $hBrush) DllStructSetData($tLayout, "Y", 70) _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "right mousebutton = reset", $hFont, $tLayout, $hFormat, $hBrush) Local $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_GraphicsGetTransform($g_hGfx_Buffer, $hMatrix) Local $aMatrix_Values = _GDIPlus_MatrixGetElements($hMatrix) _GDIPlus_MatrixDispose($hMatrix) DllStructSetData($tLayout, "Y", 110) _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "Matrix:", $hFont, $tLayout, $hFormat, $hBrush) DllStructSetData($tLayout, "X", 20) DllStructSetData($tLayout, "Y", 130) _GDIPlus_GraphicsDrawStringEx($g_hGraphics, StringFormat("%.2f %.2f", $aMatrix_Values[0], $aMatrix_Values[1]), $hFont, $tLayout, $hFormat, $hBrush) DllStructSetData($tLayout, "Y", 150) _GDIPlus_GraphicsDrawStringEx($g_hGraphics, StringFormat("%.2f %.2f", $aMatrix_Values[2], $aMatrix_Values[3]), $hFont, $tLayout, $hFormat, $hBrush) DllStructSetData($tLayout, "Y", 170) _GDIPlus_GraphicsDrawStringEx($g_hGraphics, StringFormat("%.2f %.2f", $aMatrix_Values[4], $aMatrix_Values[5]), $hFont, $tLayout, $hFormat, $hBrush) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrush) EndFunc ;==>_Draw Func _Exit() _GDIPlus_ImageDispose($g_hImage) _GDIPlus_GraphicsDispose($g_hGfx_Buffer) _GDIPlus_BitmapDispose($g_hBmp_Buffer) _GDIPlus_GraphicsDispose($g_hGraphics) _GDIPlus_Shutdown() GUIDelete($g_hGUI) Exit EndFunc ;==>_Exit 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
UEZ Posted June 12, 2015 Share Posted June 12, 2015 I would use e.g. picture controls with the content of the image which can be moved easily. Otherwise you have to create path objects which also needs to be moved and check whether cursor hits the object.There is also an example which checks whether the mouse hits the border or inner area of the object. Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
nitekram Posted June 13, 2015 Author Share Posted June 13, 2015 (edited) @UEZAre you talking about this one?If not can you give a function name to start?EDITor maybe this? Edited June 13, 2015 by nitekram 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
UEZ Posted June 13, 2015 Share Posted June 13, 2015 Try something like this here:expandcollapse popup#include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> AutoItSetOption("MouseCoordMode", 2) Global $g_hGUI, $g_hImage, $g_hGDIBitmap Example() Func Example() AutoItSetOption("GUIOnEventMode", 1) ; X64 running support Local $sWow64 = "" If @AutoItX64 Then $sWow64 = "\Wow6432Node" ;get AutoIt install dir Local $sRegPath = "HKLM\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt" Local $sFile = RegRead($sRegPath, "InstallDir") & "\Examples\GUI\logo4.gif" If Not FileExists($sFile) Then MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", $sFile & " not found!", 30) Exit EndIf $g_hGUI = GUICreate("GDI+", 800, 600) Local $iPic1 = GUICtrlCreatePic("", 20, 20, 169, 68) Local $iPic2 = GUICtrlCreatePic("", 200, 200, 169, 68) Local $iPic3 = GUICtrlCreatePic("", 400, 400, 169, 68) Local $iPic4 = GUICtrlCreatePic("", 500, 500, 169, 68) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetState(@SW_SHOW) _GDIPlus_Startup() $g_hImage = _GDIPlus_ImageLoadFromFile($sFile) $g_hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($g_hImage) Local $i For $i = 1 To 4 _WinAPI_DeleteObject(GUICtrlSendMsg(Execute("$iPic" & $i), 0x0172, $IMAGE_BITMAP, $g_hGDIBitmap)) ;$STM_SETIMAGE = 0x0172 Next Local $aMChk, $aCtrlPos, $iDX, $iDY Do $aMChk = GUIGetCursorInfo($g_hGUI) Switch $aMChk[4] Case $iPic1 $aCtrlPos = ControlGetPos($g_hGUI, "", $iPic1) $iDX = Abs(MouseGetPos(0) - $aCtrlPos[0]) $iDY = Abs(MouseGetPos(1) - $aCtrlPos[1]) While GUIGetCursorInfo($g_hGUI)[2] ControlMove($g_hGUI, "", $iPic1, MouseGetPos(0) - $iDX, MouseGetPos(1) - $iDY) Sleep(20) WEnd Case $iPic2 $aCtrlPos = ControlGetPos($g_hGUI, "", $iPic2) $iDX = Abs(MouseGetPos(0) - $aCtrlPos[0]) $iDY = Abs(MouseGetPos(1) - $aCtrlPos[1]) While GUIGetCursorInfo($g_hGUI)[2] ControlMove($g_hGUI, "", $iPic2, MouseGetPos(0) - $iDX, MouseGetPos(1) - $iDY) Sleep(20) WEnd Case $iPic3 $aCtrlPos = ControlGetPos($g_hGUI, "", $iPic3) $iDX = Abs(MouseGetPos(0) - $aCtrlPos[0]) $iDY = Abs(MouseGetPos(1) - $aCtrlPos[1]) While GUIGetCursorInfo($g_hGUI)[2] ControlMove($g_hGUI, "", $iPic3, MouseGetPos(0) - $iDX, MouseGetPos(1) - $iDY) Sleep(20) WEnd Case $iPic4 $aCtrlPos = ControlGetPos($g_hGUI, "", $iPic4) $iDX = Abs(MouseGetPos(0) - $aCtrlPos[0]) $iDY = Abs(MouseGetPos(1) - $aCtrlPos[1]) While GUIGetCursorInfo($g_hGUI)[2] ControlMove($g_hGUI, "", $iPic4, MouseGetPos(0) - $iDX, MouseGetPos(1) - $iDY) Sleep(20) WEnd EndSwitch Until Not Sleep(50) EndFunc ;==>Example Func _Exit() _WinAPI_DeleteObject($g_hGDIBitmap) _GDIPlus_ImageDispose($g_hImage) _GDIPlus_Shutdown() GUIDelete($g_hGUI) Exit EndFunc ;==>_Exit There is room for optimizations! JohnOne and Xandy 2 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
nitekram Posted June 15, 2015 Author Share Posted June 15, 2015 Sorry, busy weekend.That is exactly what I was looking for, thanks. Most of it I understand, but could never of been able to figure it out on my own. There is one part of the code, that I do not really understand what it is doing. Can you give me a brief description (longer if you want) what would this part is doing?For $i = 1 To 4 _WinAPI_DeleteObject(GUICtrlSendMsg(Execute("$iPic" & $i), 0x0172, $IMAGE_BITMAP, $g_hGDIBitmap)) ;$STM_SETIMAGE = 0x0172 Next Thanks very much for this great example. 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
UEZ Posted June 15, 2015 Share Posted June 15, 2015 Sorry, busy weekend.That is exactly what I was looking for, thanks. Most of it I understand, but could never of been able to figure it out on my own. There is one part of the code, that I do not really understand what it is doing. Can you give me a brief description (longer if you want) what would this part is doing?For $i = 1 To 4 _WinAPI_DeleteObject(GUICtrlSendMsg(Execute("$iPic" & $i), 0x0172, $IMAGE_BITMAP, $g_hGDIBitmap)) ;$STM_SETIMAGE = 0x0172 Next Thanks very much for this great example.This is the result of my laziness. Instead of writing these lines_WinAPI_DeleteObject(GUICtrlSendMsg($iPic1, 0x0172, $IMAGE_BITMAP, $g_hGDIBitmap)) ;$STM_SETIMAGE = 0x0172 _WinAPI_DeleteObject(GUICtrlSendMsg($iPic2, 0x0172, $IMAGE_BITMAP, $g_hGDIBitmap)) ;$STM_SETIMAGE = 0x0172 _WinAPI_DeleteObject(GUICtrlSendMsg($iPic3, 0x0172, $IMAGE_BITMAP, $g_hGDIBitmap)) ;$STM_SETIMAGE = 0x0172 _WinAPI_DeleteObject(GUICtrlSendMsg($iPic4, 0x0172, $IMAGE_BITMAP, $g_hGDIBitmap)) ;$STM_SETIMAGE = 0x0172which will copy the GDI bitmap to the picture control, I had chosen the For/Next loop version.Is it clear now for you? Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
nitekram Posted June 15, 2015 Author Share Posted June 15, 2015 I guess I should have asked, what the function (_WinAPI_DeleteObject) is doing. I do not understand the creation of a control, and then deleting it - if that is what it is doing, I am still not sure.Also, while trying to further the example, I came across a strange issue. When I create another control, say a label, and the image is dragged across certain areas of the screen, then something happens.The image is no longer able to move, and then sometimes it is - depending on how many times you try to move it (most of the times less than 5).expandcollapse popup#include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> AutoItSetOption("MouseCoordMode", 2) Global $g_hGUI, $g_hImage, $g_hGDIBitmap Example() Func Example() AutoItSetOption("GUIOnEventMode", 1) ; X64 running support Local $sWow64 = "" If @AutoItX64 Then $sWow64 = "\Wow6432Node" ;get AutoIt install dir Local $sRegPath = "HKLM\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt" Local $sFile = RegRead($sRegPath, "InstallDir") & "\Examples\GUI\logo4.gif" If Not FileExists($sFile) Then MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", $sFile & " not found!", 30) Exit EndIf $g_hGUI = GUICreate("GDI+", 800, 600) Local $iPic1 = GUICtrlCreatePic("", 20, 20, 169, 68) Local $iPic2 = GUICtrlCreatePic("", 200, 200, 169, 68) Local $iPic3 = GUICtrlCreatePic("", 400, 400, 169, 68) Local $iPic4 = GUICtrlCreatePic("", 500, 500, 169, 68) $lMarker = GUICtrlCreateLabel('*', 325, 30, 169, 68) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetState(@SW_SHOW) _GDIPlus_Startup() $g_hImage = _GDIPlus_ImageLoadFromFile($sFile) $g_hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($g_hImage) Local $i For $i = 1 To 4 _WinAPI_DeleteObject(GUICtrlSendMsg(Execute("$iPic" & $i), 0x0172, $IMAGE_BITMAP, $g_hGDIBitmap)) ;$STM_SETIMAGE = 0x0172 Next Local $aMChk, $aCtrlPos, $iDX, $iDY Do $aMChk = GUIGetCursorInfo($g_hGUI) Switch $aMChk[4] Case $iPic1 $aCtrlPos = ControlGetPos($g_hGUI, "", $iPic1) $iDX = Abs(MouseGetPos(0) - $aCtrlPos[0]) $iDY = Abs(MouseGetPos(1) - $aCtrlPos[1]) While GUIGetCursorInfo($g_hGUI)[2] ControlMove($g_hGUI, "", $iPic1, MouseGetPos(0) - $iDX, MouseGetPos(1) - $iDY) Sleep(20) WEnd Case $iPic2 $aCtrlPos = ControlGetPos($g_hGUI, "", $iPic2) $iDX = Abs(MouseGetPos(0) - $aCtrlPos[0]) $iDY = Abs(MouseGetPos(1) - $aCtrlPos[1]) While GUIGetCursorInfo($g_hGUI)[2] ControlMove($g_hGUI, "", $iPic2, MouseGetPos(0) - $iDX, MouseGetPos(1) - $iDY) Sleep(20) WEnd Case $iPic3 $aCtrlPos = ControlGetPos($g_hGUI, "", $iPic3) $iDX = Abs(MouseGetPos(0) - $aCtrlPos[0]) $iDY = Abs(MouseGetPos(1) - $aCtrlPos[1]) While GUIGetCursorInfo($g_hGUI)[2] ControlMove($g_hGUI, "", $iPic3, MouseGetPos(0) - $iDX, MouseGetPos(1) - $iDY) Sleep(20) WEnd Case $iPic4 $aCtrlPos = ControlGetPos($g_hGUI, "", $iPic4) $iDX = Abs(MouseGetPos(0) - $aCtrlPos[0]) $iDY = Abs(MouseGetPos(1) - $aCtrlPos[1]) While GUIGetCursorInfo($g_hGUI)[2] ControlMove($g_hGUI, "", $iPic4, MouseGetPos(0) - $iDX, MouseGetPos(1) - $iDY) Sleep(20) WEnd EndSwitch Until Not Sleep(50) EndFunc ;==>Example Func _Exit() _WinAPI_DeleteObject($g_hGDIBitmap) _GDIPlus_ImageDispose($g_hImage) _GDIPlus_Shutdown() GUIDelete($g_hGUI) Exit EndFunc ;==>_Exit Not sure if by using GDI, does that cancel other parts of basic GUI management? 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
nitekram Posted June 16, 2015 Author Share Posted June 16, 2015 (edited) I have another question. I have done some searches, and have ran a few examples of what I thought the function name might be, but is there a way, that these images cannot overlap. One reason is that when they go over each other, the image is not always the same. Two, for what I am attempting to do, I do not want them to overlap, but snap in place (sort of), but a least keep a minimum space between images.Also, with the above post, since it may not be possible to work with normal GUI controls, is there a way, to keep the images contained to an area of the GUI? Sorry for all the questions, but this, along with COM Objects and a few other items in AutoIt, really confuse me. EDITOr maybe there is already an example - I am still looking EDIT 2This might lead somewhere, after the link in the last post is update? Edited June 16, 2015 by nitekram 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
UEZ Posted June 16, 2015 Share Posted June 16, 2015 (edited) I guess I should have asked, what the function (_WinAPI_DeleteObject) is doing. I do not understand the creation of a control, and then deleting it - if that is what it is doing, I am still not sure.GUICtrlSendMsg returns in this case afaik a GDI bitmap handle which needs to be released to avoid memory leak. What you can do also is to clean up the resources when closing the script. Also, while trying to further the example, I came across a strange issue. When I create another control, say a label, and the image is dragged across certain areas of the screen, then something happens.Also all controls have a sort on the z-axis thus who is on the top depends on the creation of the controls. Last control seems to win and will be topmost.Just put GUICtrlSetBkColor(-1, 0x808080) just after the $lMarker = GUICtrlCreateLabel line and you will see what happens.I discovered another odd thing: after moved some of the controls, minimized the GUI and restored it again all controls we moved to their initial positions. Of course you can check during the movement that a control is not moving outside a defined area.Something like this here:expandcollapse popup#include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> AutoItSetOption("MouseCoordMode", 2) Global $g_hGUI, $g_hImage, $g_hGDIBitmap, $g_aCtrls[4][7] Example() Func Example() AutoItSetOption("GUIOnEventMode", 1) ; X64 running support Local $sWow64 = "" If @AutoItX64 Then $sWow64 = "\Wow6432Node" ;get AutoIt install dir Local $sRegPath = "HKLM\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt" Local $sFile = RegRead($sRegPath, "InstallDir") & "\Examples\GUI\logo4.gif" If Not FileExists($sFile) Then MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", $sFile & " not found!", 30) Exit EndIf Local $i _GDIPlus_Startup() $g_hImage = _GDIPlus_ImageLoadFromFile($sFile) $g_hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($g_hImage) $g_hGUI = GUICreate("GDI+", 800, 600) Local $iPic1 = GUICtrlCreatePic("", 20, 50, 169, 68) For $i = 0 To UBound($g_aCtrls) - 1 $g_aCtrls[$i][1] = 100 + $i * 150 ;x pos $g_aCtrls[$i][2] = 100 + $i * 120 ;y pos $g_aCtrls[$i][0] = GUICtrlCreatePic("", $g_aCtrls[$i][1], $g_aCtrls[$i][2], 169, 68) ;ctrl id $g_aCtrls[$i][3] = 50 ;min x pos $g_aCtrls[$i][4] = $g_aCtrls[$i][2] - 20 ;min y pos $g_aCtrls[$i][5] = 600 ;max x pos $g_aCtrls[$i][6] = $g_aCtrls[$i][2] + 20 ;max y pos GUICtrlCreateLabel("", 0, $g_aCtrls[$i][4], 800, 1) GUICtrlSetBkColor(-1, 0x0000FF) GUICtrlCreateLabel("", 0, $g_aCtrls[$i][4] + 107, 800, 1) GUICtrlSetBkColor(-1, 0x0000FF) _WinAPI_DeleteObject(GUICtrlSendMsg($g_aCtrls[$i][0], 0x0172, $IMAGE_BITMAP, $g_hGDIBitmap)) ;$STM_SETIMAGE = 0x0172 Next $lMarker = GUICtrlCreateLabel('***********', 325, 30, 169, 68) GUICtrlSetBkColor(-1, 0xA0A0A0) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetState(@SW_SHOW) Local $aMChk Do $aMChk = GUIGetCursorInfo($g_hGUI) Switch $aMChk[4] Case $g_aCtrls[0][0] CtrlMove($g_aCtrls, 0, $g_hGUI) Case $g_aCtrls[1][0] CtrlMove($g_aCtrls, 1, $g_hGUI) Case $g_aCtrls[2][0] CtrlMove($g_aCtrls, 2, $g_hGUI) Case $g_aCtrls[3][0] CtrlMove($g_aCtrls, 3, $g_hGUI) EndSwitch Until Not Sleep(50) EndFunc ;==>Example Func CtrlMove(ByRef $g_aCtrls, $iCtrl, $g_hGUI) Local $aCtrlPos = ControlGetPos($g_hGUI, "", $g_aCtrls[$iCtrl][0]) Local $iDX = Abs(MouseGetPos(0) - $aCtrlPos[0]) Local $iDY = Abs(MouseGetPos(1) - $aCtrlPos[1]) Local $bIsPressed = False, $iX, $iY While GUIGetCursorInfo($g_hGUI)[2] $iX = MouseGetPos(0) - $iDX $iY = MouseGetPos(1) - $iDY GUICtrlSetPos($g_aCtrls[$iCtrl][0], ($iX < $g_aCtrls[$iCtrl][3]) ? $g_aCtrls[$iCtrl][3] : ($iX > $g_aCtrls[$iCtrl][5]) ? $g_aCtrls[$iCtrl][5] : $iX, _ ($iY < $g_aCtrls[$iCtrl][4]) ? $g_aCtrls[$iCtrl][4] : ($iY > $g_aCtrls[$iCtrl][6]) ? $g_aCtrls[$iCtrl][6] : $iY) ;~ $bIsPressed = True Sleep(10) WEnd ;~ If $bIsPressed Then _WinAPI_RedrawWindow($g_hGUI) EndFunc ;==>CtrlMove Func _Exit() _WinAPI_DeleteObject($g_hGDIBitmap) _GDIPlus_ImageDispose($g_hImage) _GDIPlus_Shutdown() GUIDelete($g_hGUI) Exit EndFunc ;==>_Exit Edited June 30, 2015 by UEZ JohnOne 1 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
nitekram Posted June 17, 2015 Author Share Posted June 17, 2015 Ha, wish I had an update for edits...I had created my own function for this, but after tweaking yours, I decided to use yours, as it looked a lot cleaner (and I will use it as a black box)I do have some more questions. I want to be able to pull the image from the left side (or where ever I decide) and that is working now, but I want to refresh the screen with the new images (being located where I want, and the right size). It only refreshes the screen after I run the mouse over them - maybe a function call will work? expandcollapse popup#include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> AutoItSetOption("MouseCoordMode", 2) Global $g_hGUI, $g_hImage, $g_hGDIBitmap, $g_aCtrls[4][9] Global $ci_MainWidth = 1000, $ci_MainHeight = 800 Example() Func Example() AutoItSetOption("GUIOnEventMode", 1) ; X64 running support Local $sWow64 = "" If @AutoItX64 Then $sWow64 = "\Wow6432Node" ;get AutoIt install dir Local $sRegPath = "HKLM\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt" Local $sFile = RegRead($sRegPath, "InstallDir") & "\Examples\GUI\logo4.gif" If Not FileExists($sFile) Then MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", $sFile & " not found!", 30) Exit EndIf ;$sFile = 'bulb0.jpg' If FileExists('logo4.gif') Then $sFile = 'logo4.gif' Local $i _GDIPlus_Startup() ;$g_hImage = _GDIPlus_ImageLoadFromFile($sFile) ;$g_hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($g_hImage) $g_hGUI = GUICreate("GDI+", $ci_MainWidth, $ci_MainHeight) ;Local $iPic1 = GUICtrlCreatePic("", 20, 50, 169, 68) For $i = 0 To UBound($g_aCtrls) - 1 $g_aCtrls[$i][1] = 0 ;100 + $i * 150 ;x pos (Starting Position) $g_aCtrls[$i][2] = 250 + $i * 120 ;y pos $g_aCtrls[$i][0] = GUICtrlCreatePic("", $g_aCtrls[$i][1], $g_aCtrls[$i][2], 169, 68) ;, $SS_BITMAP) ;ctrl id $g_aCtrls[$i][3] = 100 ;min x pos $g_aCtrls[$i][4] = 250 ; $g_aCtrls[$i][2] - 20 ;min y pos Local $aImagePos = ControlGetPos($g_hGUI, '', $g_aCtrls[$i][0]) $g_aCtrls[$i][5] = $ci_MainWidth - $aImagePos[2] - 10; $ci_MainHeight ;max x pos $g_aCtrls[$i][6] = $ci_MainHeight - $aImagePos[3] - 10 ; $g_aCtrls[$i][2] + 20 ;max y pos ;GUICtrlCreateLabel("", 0, $g_aCtrls[$i][4], $ci_MainWidth, 1) ;GUICtrlSetBkColor(-1, 0x0000FF) ;GUICtrlCreateLabel("", 0, $g_aCtrls[$i][4] + 107, $ci_MainWidth, 1) ;GUICtrlSetBkColor(-1, 0x0000FF) $g_aCtrls[$i][7] = _GDIPlus_ImageLoadFromFile($sFile) $g_aCtrls[$i][8] = _GDIPlus_BitmapCreateHBITMAPFromBitmap($g_aCtrls[$i][7]) _WinAPI_DeleteObject(GUICtrlSendMsg($g_aCtrls[$i][0], 0x0172, $IMAGE_BITMAP, $g_aCtrls[$i][8])) ;$STM_SETIMAGE = 0x0172 Next ;$lMarker = GUICtrlCreateLabel('***********', 325, 30, 169, 68) ;GUICtrlSetBkColor(-1, 0xA0A0A0) _WinAPI_RedrawWindow($g_hGUI, 0, 0, $RDW_UPDATENOW) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetState(@SW_SHOW) ; ScreenUpdate CtrlMove($g_aCtrls, 0, $g_hGUI) Local $aMChk Do $aMChk = GUIGetCursorInfo($g_hGUI) Switch $aMChk[4] Case $g_aCtrls[0][0] CtrlMove($g_aCtrls, 0, $g_hGUI) Case $g_aCtrls[1][0] CtrlMove($g_aCtrls, 1, $g_hGUI) Case $g_aCtrls[2][0] CtrlMove($g_aCtrls, 2, $g_hGUI) Case $g_aCtrls[3][0] CtrlMove($g_aCtrls, 3, $g_hGUI) EndSwitch Until Not Sleep(50) EndFunc ;==>Example Func CtrlMove(ByRef $g_aCtrls, $iCtrl, $g_hGUI) Local $aCtrlPos = ControlGetPos($g_hGUI, "", $g_aCtrls[$iCtrl][0]) Local $iDX = Abs(MouseGetPos(0) - $aCtrlPos[0]) Local $iDY = Abs(MouseGetPos(1) - $aCtrlPos[1]) Local $iX, $iY Static $bRan = False If Not $bRan Then MsgBox('','','splash screen - starting') For $x = 0 To UBound($g_aCtrls) - 1 $aCtrlPos = ControlGetPos($g_hGUI, "", $g_aCtrls[$x][0]) ;#cs ;Remove Current Image and replace with smaller one... _WinAPI_DeleteObject(GUICtrlSendMsg($g_aCtrls[$x][0], 0x0172, $IMAGE_BITMAP, $g_aCtrls[$x][8])) ;$STM_SETIMAGE = 0x0172 Sleep(20) Local $hBitmap_Scaled = _GDIPlus_ImageResize($g_aCtrls[$x][7], 50, 50) If @error Then MsgBox('', '_GDIPlus_ImageResize ' & @error, $hBitmap_Scaled) Sleep(20) ; Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ;create a graphics object from a window handle If @error Then MsgBox('', '_GDIPlus_GraphicsCreateFromHWND ' & @error, $hGraphics) Sleep(20) ; _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap_Scaled, $aCtrlPos[0], $aCtrlPos[1]) ;$g_aCtrls[$iCtrl][3], $g_aCtrls[$iCtrl][4]) ;MouseGetPos(0), MouseGetPos(1)) ; $aCtrlPos[0], $aCtrlPos[1]) ;$iDX, $iDY) Sleep(20) $g_aCtrls[$x][8] = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_Scaled) ; handle to a HBITMAP (a handle to a bitmap from a bitmap object) Sleep(20) $iPic_W = _GDIPlus_ImageGetWidth($hBitmap_Scaled) $iPic_H = _GDIPlus_ImageGetHeight($hBitmap_Scaled) ;#ce _WinAPI_RedrawWindow($g_hGUI, 0, 0, $RDW_UPDATENOW) Next _WinAPI_RedrawWindow($g_hGUI, 0, 0, $RDW_UPDATENOW) $bRan = True Else ConsoleWrite($aCtrlPos[0] & ',' & $aCtrlPos[1] & @CRLF) ;#cs ;Remove Current Image and replace with smaller one... _WinAPI_DeleteObject(GUICtrlSendMsg($g_aCtrls[$iCtrl][0], 0x0172, $IMAGE_BITMAP, $g_aCtrls[$iCtrl][8])) ;$STM_SETIMAGE = 0x0172 Sleep(20) Local $hBitmap_Scaled = _GDIPlus_ImageResize($g_aCtrls[$iCtrl][7], 50, 50) If @error Then MsgBox('', '_GDIPlus_ImageResize ' & @error, $hBitmap_Scaled) Sleep(20) ; Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ;create a graphics object from a window handle If @error Then MsgBox('', '_GDIPlus_GraphicsCreateFromHWND ' & @error, $hGraphics) Sleep(20) ; _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap_Scaled, $aCtrlPos[0], $aCtrlPos[1]) ;$g_aCtrls[$iCtrl][3], $g_aCtrls[$iCtrl][4]) ;MouseGetPos(0), MouseGetPos(1)) ; $aCtrlPos[0], $aCtrlPos[1]) ;$iDX, $iDY) Sleep(20) $g_aCtrls[$iCtrl][8] = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_Scaled) ; handle to a HBITMAP (a handle to a bitmap from a bitmap object) Sleep(20) $iPic_W = _GDIPlus_ImageGetWidth($hBitmap_Scaled) $iPic_H = _GDIPlus_ImageGetHeight($hBitmap_Scaled) $g_aCtrls[$iCtrl][5] = $ci_MainWidth - $iPic_W - 10 ; width $g_aCtrls[$iCtrl][6] = $ci_MainHeight - $iPic_H - 10 ; height ;#ce ; Border - would like to be able to extend a virtual boarder both to the right and down of the main window, to allow further expansion within the GDI+ window ;_GDIPlus_RectFCreate ($g_aCtrls[0][3], $g_aCtrls[0][4], $ci_MainWidth - 20, $ci_MainHeight - 20) $hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ;$hGraphics = _GDIPlus_ImageGetGraphicsContext($g_hGUI) ; Draw a frame around the inserted image _GDIPlus_GraphicsDrawRect($hGraphics, $g_aCtrls[0][3], $g_aCtrls[0][4], $ci_MainWidth - 110, $ci_MainHeight - 260) ;_GDIPlus_GraphicsDrawRect($hGraphics, 300, 300, 300, 300) ;_WinAPI_DrawLine ( $g_hGUI, $g_aCtrls[0][3], $g_aCtrls[0][4], $ci_MainWidth - 20, $ci_MainHeight - 20 ) EndIf While GUIGetCursorInfo($g_hGUI)[2] $iX = MouseGetPos(0) - $iDX $iY = MouseGetPos(1) - $iDY $aCtrlPos = ControlGetPos($g_hGUI, "", $g_aCtrls[$iCtrl][0]) $iX_ = $aCtrlPos[0] $iY_ = $aCtrlPos[1] ConsoleWrite(' ' & $iX & ' ' & $iY & @CRLF) ; ternary operator ; GUICtrlSetPos($g_aCtrls[$iCtrl][0], ($iX < $g_aCtrls[$iCtrl][3]) ? $g_aCtrls[$iCtrl][3] : ($iX > $g_aCtrls[$iCtrl][5]) ? $g_aCtrls[$iCtrl][5] : $iX, _ ($iY < $g_aCtrls[$iCtrl][4]) ? $g_aCtrls[$iCtrl][4] : ($iY > $g_aCtrls[$iCtrl][6]) ? $g_aCtrls[$iCtrl][6] : $iY) Sleep(10) _WinAPI_RedrawWindow($g_hGUI, 0, 0, $RDW_UPDATENOW) Sleep(10) WEnd EndFunc ;==>CtrlMove ; Func _Exit() _WinAPI_DeleteObject($g_hGDIBitmap) _GDIPlus_ImageDispose($g_hImage) _GDIPlus_Shutdown() GUIDelete($g_hGUI) Exit EndFunc ;==>_ExitI may not see this until tonight. 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
nitekram Posted June 18, 2015 Author Share Posted June 18, 2015 Any ideas on how to change/resize the image? I have even changed the width and height when creating the control - still no luck. I have moved the mouse over the controls, and until I do it manually, there is no change? I am unsure how to do this, and it is stopping me from understanding these types of functions. I have cleared/deleted objects, and still until the mouse is moved by my hand, over the images, there is no change.Also, I was wondering if there is any documentation on the process of creating these types of GUI controls and using the functions, i.e. You have to create an object to a GUI window, then you have to create a image/graphic object, then you have to ...I find the help file description for these lacking, though the examples are really interesting. Some of the descriptions are exactly the same as the naming convention of the function - great names, but descriptions could describe the process or functions use? I am not complaining, just trying to understand how these functions are used to draw the screen - maybe that is it, I have to draw the screen, but I have tried that too. 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
nitekram Posted June 19, 2015 Author Share Posted June 19, 2015 I am still stuck on how to remove the old image from the GUI, and replace it with what I want and where I want. Am I missing something? 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
UEZ Posted June 19, 2015 Share Posted June 19, 2015 If the image isn't a transparent image you can send another image to the control to replace the current image with the new one. Or you can sent 0 to clean the image.For example:_WinAPI_DeleteObject(GUICtrlSendMsg($g_aCtrls[$i][0], 0x0172, $IMAGE_BITMAP, 0))It will flicker if you animate something and using this method. Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
nitekram Posted June 19, 2015 Author Share Posted June 19, 2015 (edited) Not sure where to put that. I put it in the loop when creating the controls...but there is also one in there that is deleting the object. If you run the example below, you will see that the larger image is under the smaller (resized the same image and placed it) - but it will not go away, until after the mouse is moved over. I can see how, writing a blank image over the image would in fact remove it. Is there a mask that I can use, to create a blank image, the same size as the one that I want to get rid of, or do I have to create a blank image, and then overwrite the old image?Sorry, still trying to understand the process that is need to draw a simple object - seems harder than it should be lol Here is the code, with your line, but everything is basically your code:expandcollapse popup#include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> AutoItSetOption("MouseCoordMode", 2) Global $g_hGUI, $g_hImage, $g_hGDIBitmap, $g_aCtrls[4][9] Global $ci_MainWidth = 1000, $ci_MainHeight = 800 Example() Func Example() AutoItSetOption("GUIOnEventMode", 1) ; X64 running support Local $sWow64 = "" If @AutoItX64 Then $sWow64 = "\Wow6432Node" ;get AutoIt install dir Local $sRegPath = "HKLM\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt" Local $sFile = RegRead($sRegPath, "InstallDir") & "\Examples\GUI\logo4.gif" If Not FileExists($sFile) Then MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", $sFile & " not found!", 30) Exit EndIf ;$sFile = 'bulb0.jpg' If FileExists('logo4.gif') Then $sFile = 'logo4.gif' Local $i _GDIPlus_Startup() ;$g_hImage = _GDIPlus_ImageLoadFromFile($sFile) ;$g_hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($g_hImage) $g_hGUI = GUICreate("GDI+", $ci_MainWidth, $ci_MainHeight) ;Local $iPic1 = GUICtrlCreatePic("", 20, 50, 169, 68) For $i = 0 To UBound($g_aCtrls) - 1 $g_aCtrls[$i][1] = 0 ;100 + $i * 150 ;x pos (Starting Position) $g_aCtrls[$i][2] = 250 + $i * 120 ;y pos $g_aCtrls[$i][0] = GUICtrlCreatePic("", $g_aCtrls[$i][1], $g_aCtrls[$i][2], 169, 68) ;, $SS_BITMAP) ;ctrl id $g_aCtrls[$i][3] = 100 ;min x pos $g_aCtrls[$i][4] = 250 ; $g_aCtrls[$i][2] - 20 ;min y pos Local $aImagePos = ControlGetPos($g_hGUI, '', $g_aCtrls[$i][0]) $g_aCtrls[$i][5] = $ci_MainWidth - $aImagePos[2] - 10; $ci_MainHeight ;max x pos $g_aCtrls[$i][6] = $ci_MainHeight - $aImagePos[3] - 10 ; $g_aCtrls[$i][2] + 20 ;max y pos ;GUICtrlCreateLabel("", 0, $g_aCtrls[$i][4], $ci_MainWidth, 1) ;GUICtrlSetBkColor(-1, 0x0000FF) ;GUICtrlCreateLabel("", 0, $g_aCtrls[$i][4] + 107, $ci_MainWidth, 1) ;GUICtrlSetBkColor(-1, 0x0000FF) $g_aCtrls[$i][7] = _GDIPlus_ImageLoadFromFile($sFile) $g_aCtrls[$i][8] = _GDIPlus_BitmapCreateHBITMAPFromBitmap($g_aCtrls[$i][7]) _WinAPI_DeleteObject(GUICtrlSendMsg($g_aCtrls[$i][0], 0x0172, $IMAGE_BITMAP, $g_aCtrls[$i][8])) ;$STM_SETIMAGE = 0x0172 _WinAPI_DeleteObject(GUICtrlSendMsg($g_aCtrls[$i][0], 0x0172, $IMAGE_BITMAP, 0)) Next ;$lMarker = GUICtrlCreateLabel('***********', 325, 30, 169, 68) ;GUICtrlSetBkColor(-1, 0xA0A0A0) _WinAPI_RedrawWindow($g_hGUI, 0, 0, $RDW_UPDATENOW) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetState(@SW_SHOW) ; ScreenUpdate CtrlMove($g_aCtrls, 0, $g_hGUI) Local $aMChk Do $aMChk = GUIGetCursorInfo($g_hGUI) Switch $aMChk[4] Case $g_aCtrls[0][0] CtrlMove($g_aCtrls, 0, $g_hGUI) Case $g_aCtrls[1][0] CtrlMove($g_aCtrls, 1, $g_hGUI) Case $g_aCtrls[2][0] CtrlMove($g_aCtrls, 2, $g_hGUI) Case $g_aCtrls[3][0] CtrlMove($g_aCtrls, 3, $g_hGUI) EndSwitch Until Not Sleep(50) EndFunc ;==>Example Func CtrlMove(ByRef $g_aCtrls, $iCtrl, $g_hGUI) Local $aCtrlPos = ControlGetPos($g_hGUI, "", $g_aCtrls[$iCtrl][0]) Local $iDX = Abs(MouseGetPos(0) - $aCtrlPos[0]) Local $iDY = Abs(MouseGetPos(1) - $aCtrlPos[1]) Local $iX, $iY Static $bRan = False If Not $bRan Then ;MsgBox('','','splash screen - starting') For $x = 0 To UBound($g_aCtrls) - 1 $aCtrlPos = ControlGetPos($g_hGUI, "", $g_aCtrls[$x][0]) ;#cs ;Remove Current Image and replace with smaller one... _WinAPI_DeleteObject(GUICtrlSendMsg($g_aCtrls[$x][0], 0x0172, $IMAGE_BITMAP, $g_aCtrls[$x][8])) ;$STM_SETIMAGE = 0x0172 Sleep(20) Local $hBitmap_Scaled = _GDIPlus_ImageResize($g_aCtrls[$x][7], 50, 50) If @error Then MsgBox('', '_GDIPlus_ImageResize ' & @error, $hBitmap_Scaled) Sleep(20) ; Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ;create a graphics object from a window handle If @error Then MsgBox('', '_GDIPlus_GraphicsCreateFromHWND ' & @error, $hGraphics) Sleep(20) ; _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap_Scaled, $aCtrlPos[0], $aCtrlPos[1]) ;$g_aCtrls[$iCtrl][3], $g_aCtrls[$iCtrl][4]) ;MouseGetPos(0), MouseGetPos(1)) ; $aCtrlPos[0], $aCtrlPos[1]) ;$iDX, $iDY) Sleep(20) $g_aCtrls[$x][8] = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_Scaled) ; handle to a HBITMAP (a handle to a bitmap from a bitmap object) Sleep(20) $iPic_W = _GDIPlus_ImageGetWidth($hBitmap_Scaled) $iPic_H = _GDIPlus_ImageGetHeight($hBitmap_Scaled) ;#ce _WinAPI_RedrawWindow($g_hGUI, 0, 0, $RDW_UPDATENOW) Next _WinAPI_RedrawWindow($g_hGUI, 0, 0, $RDW_UPDATENOW) $bRan = True Else ConsoleWrite($aCtrlPos[0] & ',' & $aCtrlPos[1] & @CRLF) ;#cs ;Remove Current Image and replace with smaller one... _WinAPI_DeleteObject(GUICtrlSendMsg($g_aCtrls[$iCtrl][0], 0x0172, $IMAGE_BITMAP, $g_aCtrls[$iCtrl][8])) ;$STM_SETIMAGE = 0x0172 Sleep(20) Local $hBitmap_Scaled = _GDIPlus_ImageResize($g_aCtrls[$iCtrl][7], 50, 50) If @error Then MsgBox('', '_GDIPlus_ImageResize ' & @error, $hBitmap_Scaled) Sleep(20) ; Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ;create a graphics object from a window handle If @error Then MsgBox('', '_GDIPlus_GraphicsCreateFromHWND ' & @error, $hGraphics) Sleep(20) ; _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap_Scaled, $aCtrlPos[0], $aCtrlPos[1]) ;$g_aCtrls[$iCtrl][3], $g_aCtrls[$iCtrl][4]) ;MouseGetPos(0), MouseGetPos(1)) ; $aCtrlPos[0], $aCtrlPos[1]) ;$iDX, $iDY) Sleep(20) $g_aCtrls[$iCtrl][8] = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_Scaled) ; handle to a HBITMAP (a handle to a bitmap from a bitmap object) Sleep(20) $iPic_W = _GDIPlus_ImageGetWidth($hBitmap_Scaled) $iPic_H = _GDIPlus_ImageGetHeight($hBitmap_Scaled) $g_aCtrls[$iCtrl][5] = $ci_MainWidth - $iPic_W - 10 ; width $g_aCtrls[$iCtrl][6] = $ci_MainHeight - $iPic_H - 10 ; height ;#ce ; Border - would like to be able to extend a virtual boarder both to the right and down of the main window, to allow further expansion within the GDI+ window ;_GDIPlus_RectFCreate ($g_aCtrls[0][3], $g_aCtrls[0][4], $ci_MainWidth - 20, $ci_MainHeight - 20) $hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ;$hGraphics = _GDIPlus_ImageGetGraphicsContext($g_hGUI) ; Draw a frame around the inserted image _GDIPlus_GraphicsDrawRect($hGraphics, $g_aCtrls[0][3], $g_aCtrls[0][4], $ci_MainWidth - 110, $ci_MainHeight - 260) ;_GDIPlus_GraphicsDrawRect($hGraphics, 300, 300, 300, 300) ;_WinAPI_DrawLine ( $g_hGUI, $g_aCtrls[0][3], $g_aCtrls[0][4], $ci_MainWidth - 20, $ci_MainHeight - 20 ) EndIf While GUIGetCursorInfo($g_hGUI)[2] $iX = MouseGetPos(0) - $iDX $iY = MouseGetPos(1) - $iDY $aCtrlPos = ControlGetPos($g_hGUI, "", $g_aCtrls[$iCtrl][0]) $iX_ = $aCtrlPos[0] $iY_ = $aCtrlPos[1] ConsoleWrite(' ' & $iX & ' ' & $iY & @CRLF) ; ternary operator ; GUICtrlSetPos($g_aCtrls[$iCtrl][0], ($iX < $g_aCtrls[$iCtrl][3]) ? $g_aCtrls[$iCtrl][3] : ($iX > $g_aCtrls[$iCtrl][5]) ? $g_aCtrls[$iCtrl][5] : $iX, _ ($iY < $g_aCtrls[$iCtrl][4]) ? $g_aCtrls[$iCtrl][4] : ($iY > $g_aCtrls[$iCtrl][6]) ? $g_aCtrls[$iCtrl][6] : $iY) Sleep(10) _WinAPI_RedrawWindow($g_hGUI, 0, 0, $RDW_UPDATENOW) Sleep(10) WEnd EndFunc ;==>CtrlMove ; Func _Exit() _WinAPI_DeleteObject($g_hGDIBitmap) _GDIPlus_ImageDispose($g_hImage) _GDIPlus_Shutdown() GUIDelete($g_hGUI) Exit EndFunc ;==>_Exit . Edited June 20, 2015 by nitekram fixed some wording 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
nitekram Posted June 20, 2015 Author Share Posted June 20, 2015 I have found this example, and maybe it is me, but he screen turns black and it almost like it hangs the computer? Can someone verify this as a way to delete a GDI line? Do you have to destroy everything, expect the GUI controls?expandcollapse popup#include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <Array.au3> #cs https://www.autoitscript.com/forum/topic/133711-delete-a-line-in-gdi/ You would need to have some way to redraw all the lines except the line you want to delete, or you save a copy of every new version and have an UNDO/REDO otion. You can store the picture as a bitmap, and have the lines drawn on another bitmap. You could have another bitmap for another layer. When a change is made you change the relevant layer(bitmap) and then recombine them all again and redraw the result. #ce Example() Func Example() #include <GuiConstantsEx.au3> #include <GDIPlus.au3> Local $hGUI, $hGraphic, $hPen _GDIPlus_Startup() $hGUI = GUICreate("GDI+ test", 400, 300) $make = GUICtrlCreateButton("Make line", 10, 10, 100, 20) $delete = GUICtrlCreateButton("Delete line", 120, 10, 100, 20) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $make $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) $hPen = _GDIPlus_PenCreate() _GDIPlus_GraphicsDrawLine($hGraphic, 10, 150, 390, 150, $hPen) Case $delete _GDIPlus_GraphicsClear($hGraphic) MsgBox('','','') Case $GUI_EVENT_CLOSE _GDIPlus_PenDispose($hPen) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() Exit EndSwitch Sleep(20) WEnd EndFunc . 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
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