yuser Posted October 26, 2014 Posted October 26, 2014 Hey, can anyone help me with adding checkboxes on a movable picture? No gui on that, only picture moves in the full screen freely. I want to add checkboxes on that which will move with the picture. Thank you
Belini Posted October 26, 2014 Posted October 26, 2014 Maybe this code can help you: My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ
qwert Posted October 26, 2014 Posted October 26, 2014 Here's one option: '?do=embed' frameborder='0' data-embedContent>> “This also works for buttons on Pic fields” . It should have stated “also works for controls on Pic controls”.
yuser Posted October 26, 2014 Author Posted October 26, 2014 No, i'm searching something which will work on moveable picture. I will use it with this kind of code. Checkboxes need to stuck to the picture sth like that expandcollapse popup#include-once #include <GUIConstantsEx.au3> #Include <Misc.au3> #include <WinAPI.au3> #include <GDIPlus.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <Middle.au3> Opt("GUIOnEventMode",1) Opt("MouseCoordMode", 2) $sPictureLocation=@ScriptDir&'\Logo.png' Global $hMain=GUICreate("Smooth Move",@DesktopWidth-6,(@DesktopWidth-6)/2,0,0,BitOR($WS_MINIMIZEBOX,$WS_POPUP,$WS_GROUP)) WinSetTrans("Smooth Move","","230") GUISetBkColor(0xFFFFFF,$hMain) GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit") GUISetState(@SW_SHOW,$hMain) ; create pic control last _GDIPlus_Startup() $hImage1 = _GDIPlus_ImageLoadFromFile($sPictureLocation) $hPic=GUICtrlCreatePic('',100,25,_GDIPlus_ImageGetWidth($hImage1),_GDIPlus_ImageGetHeight($hImage1)) GUICtrlSetOnEvent(-1,"_PicClick") $hBMP1=_GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage1) _WinAPI_DeleteObject(GUICtrlSendMsg($hPic, 0x0172, 0, $hBMP1)) _GDIPlus_ImageDispose($hImage1) _GDIPlus_Shutdown() While 1 Sleep(10) WEnd Func _PicClick() _SmoothMove(@GUI_CtrlId) $bChange=False $arPos=ControlGetPos($hMain,'',@GUI_CtrlId) If $arPos[0]<0 Then $arPos[0]=0 $bChange=True EndIf If $arPos[1]<0 Then $arPos[1]=0 $bChange=True EndIf If $arPos[0]+$arPos[2]>@DesktopWidth-6 Then $arPos[0]=@DesktopWidth-6-$arPos[2] $bChange=True EndIf If $arPos[1]+$arPos[3]>(@DesktopWidth-6)/2 Then $arPos[1]=(@DesktopWidth-6)/2-$arPos[3] $bChange=True EndIf If $bChange Then GUICtrlSetPos(@GUI_CtrlId,$arPos[0],$arPos[1]) EndFunc Func _ControlMove($nCID) $arPos=MouseGetPos() $arPieceInfo=ControlGetPos($hMain,"",$nCID) $nXOffset=$arPos[0]-$arPieceInfo[0] $nYOffset=$arPos[1]-$arPieceInfo[1] While _IsPressed("01") $arPos=MouseGetPos() ControlMove($hMain,'',$nCID,$arPos[0]-$nXOffset,$arPos[1]-$nYOffset) Sleep(10) WEnd EndFunc Func _SetPositionmove($nCID) $arPos=MouseGetPos() $arPieceInfo=ControlGetPos($hMain,"",$nCID) $nXOffset=$arPos[0]-$arPieceInfo[0] $nYOffset=$arPos[1]-$arPieceInfo[1] While _IsPressed("01") $arPos=MouseGetPos() GUICtrlSetPos($nCID,$arPos[0]-$nXOffset,$arPos[1]-$nYOffset) Sleep(10) WEnd EndFunc Func _SmoothMove($nCID) $arPos=MouseGetPos() Opt("MouseCoordMode",1) $Temp=MouseGetPos() Opt("MouseCoordMode",2) Local $nGlobalYOffset=$Temp[1]-$arPos[1] Local $nGlobalXOffset=$Temp[0]-$arPos[0] $arPieceInfo=ControlGetPos($hMain,"",$nCID) $nXOffset=$arPos[0]-$arPieceInfo[0] $nYOffset=$arPos[1]-$arPieceInfo[1] Local $hTempWin=GUICreate('temp',$arPieceInfo[2],$arPieceInfo[3],$arPieceInfo[0]+$nGlobalXOffset,$arPieceInfo[1]+$nGlobalYOffset, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD,$WS_EX_TOPMOST),$hMain) _GDIPlus_Startup() $hImage1 = _GDIPlus_ImageLoadFromFile($sPictureLocation) _SetBitmap($hTempWin,$hImage1,255) _GDIPlus_ImageDispose($hImage1) GUISetState(@SW_SHOWNA,$hTempWin) GUICtrlSetState($nCID,$GUI_HIDE) While _IsPressed("01") $arPos=MouseGetPos() WinMove($hTempWin,'',$arPos[0]-$nXOffset+$nGlobalXOffset,$arPos[1]-$nYOffset+$nGlobalYOffset) WEnd $arPos=WinGetPos($hTempWin) GUICtrlSetPos($nCID,$arPos[0]-$nGlobalXOffset,$arPos[1]-$nGlobalYOffset) GUICtrlSetState($nCID,$GUI_SHOW) GUIDelete($hTempWin) GUISwitch($hMain) EndFunc Func _SetBitmap($hGUI, $hImage, $iOpacity) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend Local $AC_SRC_ALPHA=1 $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc Func _Exit() GUIDelete($hMain) Exit EndFunc
qwert Posted October 26, 2014 Posted October 26, 2014 You are technically correct. I hadn't noticed that $WS_CLIPSIBLINGS isn't an option for Pic controls. However, with a little slight of hand, you can gain a workable result. I have used the more complex approach you've outlined in your example, but have learned to avoid the complexity it entails whenever possible. Here's a working example that's based on the post I referred to: ; ; Example of checkbox on movable picture ; #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> $GUI = GuiCreate("Test GUI" , 200 , 200, -1, -1, $WS_POPUP) $close = GUICtrlCreateLabel(" Close ", 120, 30 , 40, 14) ; unseen "functional" button GUICtrlSetColor(-1 , 0xCC0000) GUICtrlSetTip(-1, "Click to close") $check = GUICtrlCreateCheckbox("Active checkbox", 40, 80 , 100, 14) GUICtrlSetColor(-1 , 0xCC0000) GUICtrlSetTip(-1, "Click to check") GUICtrlCreatePic("C:\AutoIt3\Examples\Helpfile\Extras\Tech.bmp", 0, 0, 200, 200, -1, $GUI_WS_EX_PARENTDRAG) GUICtrlSetBkColor(-1 , 0xBBBBBB) $closeShow = GUICtrlCreateLabel(" Close ", 120, 30 , 40, 14) ; visible "display" button GUICtrlSetColor(-1 , 0xCC0000) $checkShow = GUICtrlCreateCheckbox("Active checkbox", 40, 80 , 100, 14) GUICtrlSetColor(-1 , 0xCC0000) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $close Exit EndSwitch WEnd . I hope this helps.
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