-
Posts
292 -
Joined
-
Last visited
-
Days Won
1
Everything posted by matwachich
-
Hi! I have a specific need: my app will have to display many (MANY) data on a tree view. So I want to dynamically populate it on expand. I first populate root elements, that I want that on double clique (expand), while responding to TVN_EXPANDING, this item will have it's children. The problem is that when an item has no children, impossible to expand it! The [+] button doesn't appear. What's the best solution to this? I think I will test to add to each item a dummy child that will be deleted in TVN_EXPANDING.
-
Hello, Any idea about https://www.autoitscript.com/trac/autoit/ticket/3767 ? Will/can it be implemented? What do devs think about it?
-
Help needed: image viewer (with zoom and translate)
matwachich replied to matwachich's topic in AutoIt GUI Help and Support
Ok, I think I got it! Here is my actual experimental code #NoTrayIcon #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <WinAPI.au3> #include <GDIPlus.au3> #include <Math.au3> #include <Memory.au3> Enum _ $__WM_GUIPICEX_INIT = $WM_USER _GDIPlus_Startup() OnAutoItExitRegister(_GDIPlus_Shutdown) $hImage = _GDIPlus_ImageLoadFromFile("testHD.png") $hBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _GDIPlus_ImageDispose($hImage) $hGUI = GUICreate("Test", 640 + 16, 420 + 16, -1, -1, $WS_OVERLAPPEDWINDOW) $Pic = GUICtrlCreatePic("", 8, 8, 640, 420) GUICtrlSetResizing($Pic, $GUI_DOCKBORDERS) ; $GUI_DOCKALL _WinAPI_SetWindowSubclass(GUICtrlGetHandle($Pic), DllCallbackGetPtr(DllCallbackRegister(_wmHandler, "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr")), 0) _SendMessage(GUICtrlGetHandle($Pic), $__WM_GUIPICEX_INIT) GUISetState() Do Until GUIGetMsg() = -3 _WinAPI_DeleteObject($hBITMAP) Func _wmHandler($hWnd, $iMsg, $wParam, $lParam, $iSubclassID, $pUserData) Static $s_tagGUIPICEX = "handle bitmap; double zoom; int wheelAccum; double offsetX; double offsetY; int dragOrigX; int dragOrigY" Switch $iMsg Case $__WM_GUIPICEX_INIT Local $pData = _MemGlobalAlloc(DllStructGetSize(DllStructCreate($s_tagGUIPICEX)), $GPTR) ; zero inited Local $tData = DllStructCreate($s_tagGUIPICEX, $pData) $tData.zoom = 1 $tData.offsetX = 0.5 $tData.offsetY = 0.5 _WinAPI_SetProp($hWnd, "DATA", $pData) Case $WM_DESTROY Local $pData = _WinAPI_RemoveProp($hWnd, "DATA") Local $tData = DllStructCreate($s_tagGUIPICEX, $pData) ;~ If $tData.image Then _GDIPlus_ImageDispose($tData.image) _MemGlobalFree($pData) Case $WM_PAINT Local $tData = __guiCtrlPicEx_getInternalData($hWnd, $s_tagGUIPICEX) ; begin paint Local $tPS = DllStructCreate($tagPAINTSTRUCT) Local $hDC = _WinAPI_BeginPaint($hWnd, $tPS) ; to keep quality when stretching _WinAPI_SetStretchBltMode($hDC, $HALFTONE) ; create memory DC Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC) _WinAPI_SelectObject($hMemDC, $hBITMAP) ; get DC and BITMAP sizes Local $iDcW, $iDcH, $iBmpW, $iBmpH __guiCtrlPicEx_getDcSize($hDC, $iDcW, $iDcH) __guiCtrlPicEx_getBitmapSize($hBITMAP, $iBmpW, $iBmpH) ; this is the base display ratio ; used when the image is not zoomed Local $fBaseRatio = _Max($iBmpW / $iDcW, $iBmpH / $iDcH) ; the actual display ratio is calculated like this Local $fRatio = $fBaseRatio / $tData.zoom ; when zoom = 1, then ratio = baseRatio => image is not stretched ; now, calculate drawOffset ; between 0 and 1 Local $fDrawOffsetX, $fDrawOffsetY If $fRatio = $fBaseRatio Then ; center the image when not zoomed $fDrawOffsetX = 0.5 $fDrawOffsetY = 0.5 Else $fDrawOffsetX = $tData.offsetX $fDrawOffsetY = $tData.offsetY EndIf ; calculate virtual viewport size (will condition the zooming level) Local $iVpW = $iDcW * $fRatio Local $iVpH = $iDcH * $fRatio ; actual draw _WinAPI_StretchBlt( _ $hDC, 0, 0, $iDcW, $iDcH, _ ; always draw the entire DC $hMemDC, $fDrawOffsetX * ($iBmpW - $iVpW), $fDrawOffsetY * ($iBmpH - $iVpH), $iVpW, $iVpH, _ ; draw at offset, with viewport size $SRCCOPY _ ) ; cleanum _WinAPI_DeleteObject($hMemDC) _WinAPI_EndPaint($hWnd, $tPS) Case $WM_LBUTTONDOWN _WinAPI_SetCapture($hWnd) ; reset drag calculation Local $tData = __guiCtrlPicEx_getInternalData($hWnd, $s_tagGUIPICEX) $tData.dragOrigX = __guiCtrlPicEx_getXParam($lParam) $tData.dragOrigY = __guiCtrlPicEx_getYParam($lParam) Case $WM_LBUTTONUP _WinAPI_ReleaseCapture() Case $WM_MOUSEMOVE If DllCall("user32.dll", "hwnd", "GetCapture")[0] = $hWnd Then Local $tData = __guiCtrlPicEx_getInternalData($hWnd, $s_tagGUIPICEX) ; get movement delta Local $iPosX = __guiCtrlPicEx_getXParam($lParam), $iPosY = __guiCtrlPicEx_getYParam($lParam) Local $iDeltaX = $iPosX - $tData.dragOrigX, $iDeltaY = $iPosY - $tData.dragOrigY $tData.dragOrigX = $iPosX $tData.dragOrigY = $iPosY ; update display offset $tData.offsetX += -$iDeltaX / _WinAPI_GetClientWidth($hWnd) $tData.offsetY += -$iDeltaY / _WinAPI_GetClientHeight($hWnd) $tData.offsetX = __guiCtrlPicEx_trapNumber($tData.offsetX, 0, 1) $tData.offsetY = __guiCtrlPicEx_trapNumber($tData.offsetY, 0, 1) ; redraw _WinAPI_InvalidateRect($hWnd) EndIf Case $WM_MOUSEWHEEL Local $tData = __guiCtrlPicEx_getInternalData($hWnd, $s_tagGUIPICEX) ; get wheel delta Local $iDelta = __guiCtrlPicEx_getWheelDelta($wParam) ; if rotation direction is changed before reaching threeshold (WHEEL_DELTA = 120), then reset If $iDelta > 0 And $tData.wheelAccum < 0 Or $iDelta < 0 And $tData.wheelAccum > 0 Then $tData.wheelAccum = 0 ; accumulate current delta $tData.wheelAccum += $iDelta ; when delta reaches threeshold, update zoom level If Abs($tData.wheelAccum) >= 120 Then $tData.zoom += ($tData.wheelAccum > 0 ? 0.5 : -0.5) $tData.zoom = __guiCtrlPicEx_trapNumber($tData.zoom, 1, 10) _WinAPI_InvalidateRect($hWnd) $tData.wheelAccum = 0 EndIf EndSwitch Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndFunc Func __guiCtrlPicEx_getDcSize($hDC, ByRef $iWidth, ByRef $iHeight) Local $hWnd = _WinAPI_WindowFromDC($hDC) $iWidth = _WinAPI_GetClientWidth($hWnd) $iHeight = _WinAPI_GetClientHeight($hWnd) EndFunc Func __guiCtrlPicEx_getBitmapSize($hBITMAP, ByRef $iWidth, ByRef $iHeight) Local $tBITMAP = DllStructCreate($tagBITMAP) _WinAPI_GetObject($hBITMAP, DllStructGetSize($tBITMAP), $tBITMAP) $iWidth = $tBITMAP.bmWidth $iHeight = $tBITMAP.bmHeight EndFunc Func __guiCtrlPicEx_trapNumber($vNum, $vMin, $vMax) If $vNum < $vMin Then $vNum = $vMin If $vNum > $vMax Then $vNum = $vMax Return $vNum EndFunc ; we must use these functions and not HiWord/LoWord because mouse pos are signed Func __guiCtrlPicEx_getXParam($lParam) $t = DllStructCreate("dword XY") $t.XY = $lParam $t2 = DllStructCreate("short X; short Y", DllStructGetPtr($t)) Return $t2.X EndFunc Func __guiCtrlPicEx_getYParam($lParam) $t = DllStructCreate("dword XY") $t.XY = $lParam $t2 = DllStructCreate("short X; short Y", DllStructGetPtr($t)) Return $t2.Y EndFunc Func __guiCtrlPicEx_getWheelDelta($wParam) $t = DllStructCreate("dword DW") $t.DW = $wParam $t2 = DllStructCreate("short keystate; short delta", DllStructGetPtr($t)) Return $t2.delta EndFunc Func __guiCtrlPicEx_getInternalData($hWnd, $sTag) Return DllStructCreate($sTag, _WinAPI_GetProp($hWnd, "DATA")) EndFunc Func _WinAPI_SetProp($hWnd, $sProp, $pData) Return DllCall("user32.dll", "bool", "SetPropW", "hwnd", $hWnd, "wstr", $sProp, "ptr", $pData)[0] EndFunc Func _WinAPI_GetProp($hWnd, $sProp) Return DllCall("user32.dll", "ptr", "GetPropW", "hwnd", $hWnd, "wstr", $sProp)[0] EndFunc Func _WinAPI_RemoveProp($hWnd, $sProp) Return DllCall("user32.dll", "ptr", "RemovePropW", "hwnd", $hWnd, "wstr", $sProp)[0] EndFunc Every essentials work as expected. Some polish is needed (better translation speed, getting rid of the black background...), and I will make a UDF. -
_WinAPI_HiWord and LoWord: signing mismatch?
matwachich replied to danielkza's topic in AutoIt General Help and Support
The feature request would be to add functions: _WinAPI_GetXParam and _WinAPI_GetYParam Here is my attempt Func _WinAPI_GetXParam($lParam) $t = DllStructCreate("dword XY") $t.XY = $lParam $t2 = DllStructCreate("short X; short Y", DllStructGetPtr($t)) Return $t2.X EndFunc Func _WinAPI_GetYParam($lParam) $t = DllStructCreate("dword XY") $t.XY = $lParam $t2 = DllStructCreate("short X; short Y", DllStructGetPtr($t)) Return $t2.Y EndFunc -
Help needed: image viewer (with zoom and translate)
matwachich replied to matwachich's topic in AutoIt GUI Help and Support
OK, so I dropped GDI+ and now I'm with plain GDI (way smoother!) Here is my code so far #NoTrayIcon #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <WinAPI.au3> #include <GDIPlus.au3> _GDIPlus_Startup() OnAutoItExitRegister(_GDIPlus_Shutdown) $hImage = _GDIPlus_ImageLoadFromFile("testHD.png") $hBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _GDIPlus_ImageDispose($hImage) Global $fOffsetX = 0.5, $fOffsetY = 0.5 $hGUI = GUICreate("Test", 640 + 16, 420 + 16, -1, -1, $WS_OVERLAPPEDWINDOW) $Pic = GUICtrlCreatePic("", 8, 8, 640, 420) GUICtrlSetResizing($Pic, $GUI_DOCKBORDERS) ; $GUI_DOCKALL _WinAPI_SetWindowSubclass(GUICtrlGetHandle($Pic), DllCallbackGetPtr(DllCallbackRegister(_wmHandler, "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr")), 0) GUISetState() Do Until GUIGetMsg() = -3 _WinAPI_DeleteObject($hBITMAP) Func _wmHandler($hWnd, $iMsg, $wParam, $lParam, $iSubclassID, $pUserData) Switch $iMsg Case $WM_PAINT Local $tPS = DllStructCreate($tagPAINTSTRUCT) Local $hDC = _WinAPI_BeginPaint($hWnd, $tPS) ; to keep quality when stretching _WinAPI_SetStretchBltMode($hDC, $HALFTONE) ; create memory DC Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC) _WinAPI_SelectObject($hMemDC, $hBITMAP) ; get DC and BITMAP sizes Local $iDcW, $iDcH, $iBmpW, $iBmpH __guiCtrlPicEx_getDcSize($hDC, $iDcW, $iDcH) __guiCtrlPicEx_getBitmapSize($hBITMAP, $iBmpW, $iBmpH) ; adjuste ;~ _WinAPI_SetGraphicsMode($hDC, $GM_ADVANCED) ;~ Local $tXFORM = _WinAPI_CreateTransform(1, 0, 0, 1,);, -(($iBmpW/2) - ($iDcW/2)), -(($iBmpH/2) - ($iDcH/2))) ;~ _WinAPI_SetWorldTransform($hDC, $tXFORM) ; draw _WinAPI_StretchBlt( _ $hDC, 0, 0, $iDcW, $iDcH, _ $hMemDC, $fOffsetX * ($iBmpW - $iDcW), $fOffsetY * ($iBmpH - $iDcH), $iDcW, $iDcH, _ $SRCCOPY _ ) ; cleanum _WinAPI_DeleteObject($hMemDC) _WinAPI_EndPaint($hWnd, $tPS) EndSwitch Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndFunc Func __guiCtrlPicEx_getDcSize($hDC, ByRef $iWidth, ByRef $iHeight) Local $hWnd = _WinAPI_WindowFromDC($hDC) $iWidth = _WinAPI_GetClientWidth($hWnd) $iHeight = _WinAPI_GetClientHeight($hWnd) EndFunc Func __guiCtrlPicEx_getBitmapSize($hBITMAP, ByRef $iWidth, ByRef $iHeight) Local $tBITMAP = DllStructCreate($tagBITMAP) _WinAPI_GetObject($hBITMAP, DllStructGetSize($tBITMAP), $tBITMAP) $iWidth = $tBITMAP.bmWidth $iHeight = $tBITMAP.bmHeight EndFunc Now, next step is to correctly handle zooming (scaling) and paning (translating) of the picture, just like any image viewer software. I just figure out how to make it correctly with all image possibilities (bigger/smaller than the viewport (DC), different aspect ratios...). I have no experience in this, so I refer to you're help guys! Thanks PS: I use the attached images for simple developpement process -
Help needed: image viewer (with zoom and translate)
matwachich replied to matwachich's topic in AutoIt GUI Help and Support
didn't remember this one. It exactly what I want to implement in my project! Thanks I see that I liked a post asking for a simpler version, understandable by beginers. Hope I will understand it better now with my 7 years experience Edit: it seems after first look that the script is too much complexe for what it does ; exemple: using raw calculations for zooming and image navigation. I'm sure that this can be done simply with GDI+ matrix, but without any experience with them, I'm totally stuck! -
Hello, for my project, I need to display pictures stored on a centralized MySQL DB. There could be multiple display windows opened at the same time, si I try to make a custom static control to do this. Here is my code: #NoTrayIcon #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <Math.au3> #include <GDIPlus.au3> #include <WinAPI.au3> #include <WinAPIRes.au3> #include <Memory.au3> Enum _ $WM_USER_PIC_INIT = $WM_USER, _ $WM_USER_PIC_SETIMAGE, _ $WM_USER_PIC_GETIMAGE _GDIPlus_Startup() OnAutoItExitRegister(_GDIPlus_Shutdown) $hGUI = GUICreate("Test", 657, 521, -1, -1, $WS_OVERLAPPEDWINDOW) $iStatic = GUICtrlCreateLabel("", 8, 32, 640, 480) $hStatic = GUICtrlGetHandle(-1) GUICtrlSetResizing(-1, $GUI_DOCKBORDERS) ConsoleWrite($hGUI & " > " & _WinAPI_GetClientWidth($hGUI) & "," & _WinAPI_GetClientHeight($hGUI) & @CRLF) ConsoleWrite($hStatic & " > " & _WinAPI_GetClientWidth($hStatic) & "," & _WinAPI_GetClientHeight($hStatic) & @CRLF) $B_rotL = GUICtrlCreateButton("RG", 8, 0, 35, 25) GUICtrlSetResizing(-1, $GUI_DOCKTOP+$GUI_DOCKLEFT+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) $B_rotR = GUICtrlCreateButton("RD", 48, 0, 35, 25) GUICtrlSetResizing(-1, $GUI_DOCKTOP+$GUI_DOCKLEFT+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) $B_flipH = GUICtrlCreateButton("MH", 96, 0, 35, 25) GUICtrlSetResizing(-1, $GUI_DOCKTOP+$GUI_DOCKLEFT+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) $B_flipV = GUICtrlCreateButton("MV", 136, 0, 35, 25) GUICtrlSetResizing(-1, $GUI_DOCKTOP+$GUI_DOCKLEFT+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) $B_cropR = GUICtrlCreateButton("CR", 184, 0, 35, 25) GUICtrlSetResizing(-1, $GUI_DOCKTOP+$GUI_DOCKLEFT+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) $B_cropF = GUICtrlCreateButton("CF", 224, 0, 35, 25) GUICtrlSetResizing(-1, $GUI_DOCKTOP+$GUI_DOCKLEFT+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) _WinAPI_SetWindowSubclass($hStatic, DllCallbackGetPtr(DllCallbackRegister(_wmHandler, "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr")), 0) _SendMessage($hStatic, $WM_USER_PIC_INIT) GUISetState() _SendMessage($hStatic, $WM_USER_PIC_SETIMAGE, _GDIPlus_ImageLoadFromFile("test image.jpg"), 1) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $B_rotL $hImg = _SendMessage($hStatic, $WM_USER_PIC_GETIMAGE) $hNewImg = _GDIPlus_ImageClone($hImg) _GDIPlus_ImageRotateFlip($hNewImg, 3) _SendMessage($hStatic, $WM_USER_PIC_SETIMAGE, $hNewImg, 1) Case $B_rotR $hImg = _SendMessage($hStatic, $WM_USER_PIC_GETIMAGE) $hNewImg = _GDIPlus_ImageClone($hImg) _GDIPlus_ImageRotateFlip($hNewImg, 1) _SendMessage($hStatic, $WM_USER_PIC_SETIMAGE, $hNewImg, 1) Case $B_flipH $hImg = _SendMessage($hStatic, $WM_USER_PIC_GETIMAGE) $hNewImg = _GDIPlus_ImageClone($hImg) _GDIPlus_ImageRotateFlip($hNewImg, 4) _SendMessage($hStatic, $WM_USER_PIC_SETIMAGE, $hNewImg, 1) Case $B_flipV $hImg = _SendMessage($hStatic, $WM_USER_PIC_GETIMAGE) $hNewImg = _GDIPlus_ImageClone($hImg) _GDIPlus_ImageRotateFlip($hNewImg, 6) _SendMessage($hStatic, $WM_USER_PIC_SETIMAGE, $hNewImg, 1) EndSwitch WEnd Func _getData($hWnd, $sTag) Return DllStructCreate($sTag, _WinAPI_GetProp($hWnd, "DATA")) EndFunc Func _wmHandler($hWnd, $iMsg, $wParam, $lParam, $iSubclassID, $pUserData) Static $s_tagCUSTOMPIC = "handle image;" ; will contain other control internal state Switch $iMsg Case $WM_USER_PIC_INIT Local $pData = _MemGlobalAlloc(DllStructGetSize(DllStructCreate($s_tagCUSTOMPIC)), $GPTR) Local $tData = DllStructCreate($s_tagCUSTOMPIC, $pData) $tData.zoom = 1 GUICtrlSetCursor(_WinAPI_GetDlgCtrlID($hWnd), 0) _WinAPI_SetProp($hWnd, "DATA", $pData) Case $WM_DESTROY Local $pData = _WinAPI_RemoveProp($hWnd, "DATA") Local $tData = DllStructCreate($s_tagCUSTOMPIC, $pData) If $tData.image Then _GDIPlus_ImageDispose($tData.image) _MemGlobalFree($pData) Case $WM_USER_PIC_SETIMAGE ; HIMAGE, FreeOld (bool) Local $tData = _getData($hWnd, $s_tagCUSTOMPIC) Local $hOldImg = $tData.image $tData.image = $wParam _WinAPI_RedrawWindow($hWnd) If $hOldImg And $lParam Then _GDIPlus_ImageDispose($hOldImg) Return 0 Else Return $hOldImg EndIf Case $WM_USER_PIC_GETIMAGE Return _getData($hWnd, $s_tagCUSTOMPIC).image ; ========================================================================================= Case $WM_PAINT Local $tData = _getData($hWnd, $s_tagCUSTOMPIC) Local $tPS = DllStructCreate($tagPAINTSTRUCT) Local $hDC = _WinAPI_BeginPaint($hWnd, $tPS) Local $hGfx = _GDIPlus_GraphicsCreateFromHDC($hDC) _drawImage( _ $hGfx, $tData.image, _ _WinAPI_GetClientWidth($hWnd), _WinAPI_GetClientHeight($hWnd) _ ) _GDIPlus_GraphicsDispose($hGfx) _WinAPI_EndPaint($hWnd, $tPS) EndSwitch Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndFunc Func _drawImage($hGfx, $hImg, $iGfxW, $iGfxH) If Not $hImg Then _GDIPlus_GraphicsClear($hGfx, 0xFFFFFFFF) Return EndIf Local $iImgW = _GDIPlus_ImageGetWidth($hImg), $iImgH = _GDIPlus_ImageGetHeight($hImg) Local $iScaleX = $iGfxW / $iImgW, $iScaleY = $iGfxH / $iImgH Local $iBaseScale = _Min($iScaleX, $iScaleY) ConsoleWrite("ScaleX = " & $iGfxW & " / " & $iImgW & " = " & $iScaleX & @CRLF) ConsoleWrite("ScaleX = " & $iGfxH & " / " & $iImgH & " = " & $iScaleY & @CRLF) $hMtx = _GDIPlus_MatrixCreate() _GDIPlus_MatrixScale($hMtx, $iBaseScale, $iBaseScale) If $iScaleX > $iScaleY Then _GDIPlus_MatrixTranslate($hMtx, ($iGfxW / 2) - (($iImgW * $iBaseScale) / 2), 0) ElseIf $iScaleY > $iScaleX Then _GDIPlus_MatrixTranslate($hMtx, 0, $iGfxH / 2) EndIf _GDIPlus_GraphicsSetTransform($hGfx, $hMtx) _GDIPlus_GraphicsDrawImageRectRect($hGfx, $hImg, 0, 0, $iImgW, $iImgH, 0, 0, $iImgW, $iImgH) _GDIPlus_MatrixDispose($hMtx) Return EndFunc Func _WinAPI_SetProp($hWnd, $sProp, $pData) Return DllCall("user32.dll", "bool", "SetPropW", "hwnd", $hWnd, "wstr", $sProp, "ptr", $pData)[0] EndFunc Func _WinAPI_GetProp($hWnd, $sProp) Return DllCall("user32.dll", "ptr", "GetPropW", "hwnd", $hWnd, "wstr", $sProp)[0] EndFunc Func _WinAPI_RemoveProp($hWnd, $sProp) Return DllCall("user32.dll", "ptr", "RemovePropW", "hwnd", $hWnd, "wstr", $sProp)[0] EndFunc For now, I'm stuck in the _drawImage function: I want to use the Matrix to display the image centered in the control, event when the window is resized. next, I will try to make some zooming capability and translating the zoomed image. Any help will be much appreciated. Other option: if someone knows about some already existing library to do this (with WinAPI), I will not reinvent the wheel.
-
Extended Message Box - New Version: 16 Feb 24
matwachich replied to Melba23's topic in AutoIt Example Scripts
Just a little suggestion: Do not show again checkbox should not be part of the configuration, but a parameter of _ExtMsgBox (to set it on a per-msgbox basis, not globaly on the application) Cheers Note: I know it's big work... not really a request, just a suggestion -
Extended Message Box - New Version: 16 Feb 24
matwachich replied to Melba23's topic in AutoIt Example Scripts
Hi! Just a little feature suggestion: Because we can choose the text of the buttons, it would be nice to be able to stack the buttons vertically to fit some long text. Being able to set horizontal alignment is also nice. Thanks -
Thanks for the great hard work! I wanted to ask about this feature request. Any hope it will be implemented on the next release? What do you guys think about it?
-
Multiline String frome a txt file
matwachich replied to AnnoyingClown's topic in AutoIt General Help and Support
FileRead("file.txt") ? -
BinaryToString cant convert 0xB4 to utf8
matwachich replied to Invicore's topic in AutoIt GUI Help and Support
Dont forget to set SciTE's console to display UTF8 chars. -
I want to discuss the resizing of UDF created (CreateWindowEx) controls. These controls are "excluded" from GUICtrlSetResizing internal processing, so we need to resize them manually. Since this is (I think) a "little" complicated to keep the good controls layout, the often used solution is an invisible label (static control) positioned exactly as the UDF control, that will be resized with GUICtrlSetResizing, and then we handle WM_SIZE to resize our UDF control followin the invisible label (ControlGetPos/ControlMove). The problem is that, it seems that the label is also internally resized in response the WM_SIZE. So the default internal AutoIt WM_SIZE handler is called AFTER our custom handler. So when we resize the UDF control, it is imperfectly fited to the invisible label. One solution was to in WM_SIZE handler, AdLibRegister the resize function so it will be called after the default WM_SIZE handler, but what is the correct delay? 5ms seems good (as in _GUICtrlSetResizingEx 1.4), but I encoutered a situation where the resizing takes more time, and my controls layout was screwed! Isn't there a betted solution to this problem? Why not a new feature to let us just GUICtrlSetResizing on custom UDF controls?
-
Extended Message Box - New Version: 16 Feb 24
matwachich replied to Melba23's topic in AutoIt Example Scripts
Hi, just a small idea I had while developping a program using my UDF GuiUtils I needed that dynamically created dialogs to have the same font as the main GUI (parent). Why not doing this with ExtMsgBox? I mean, the msgBox should by default have the same font as it's parent. See this function I made for this purpose. -
I dived deep into IUP for one of my projects, at first I loved it so much that I made a Golang wrapper for it. But the big drawback is that it lacks ListView control! There is the Matrix control but it didn't well suited for my needs. Also, I never get used to layout GUI composition, but I must be the problem here...
-
A simple and powerfull UDF to convert markdown to HTML, using the excellent md4c library. the code is simple and straight forward, just look at the example. There is the simple function _md_Html, and a more advanced _md_Parse function (only for advanced uses, to convert something other than HTML). au3markdown.zip
-
Hi! Would it be possible to provide a way to set resizing of UDF GUI controls just like standard AutoIt controls??? This would absolutly great! It will be possible to use custom controls and make them follow GUI size just like standard ones. This idea came to me because I'm currently making a wrapper for https://www.mctrl.org/ In a desesperate move, I tried to create a dummy label with resizing flags I needed, then creating a custom control with the same CtrlID of the label 😛 But, it seems there have to be a way to make the AutoIt WindowProcedure recognizes the custom control...
-
Hi! Sometimes, you have multiple GUIs in your project. Even more, you don't know how many GUIs you have in advance (dynamically managed GUIs). And you want to be able to have a different message handler for every GUI and/or message. This small function is for you! It lets you register/unregister message handlers that will be specific to every GUI/message. Drawbacks: you can not use standard GUIRegisterMsg in your script anymore. [not really a proble] you must unregister message handler when a GUI is destroyed. #include-once #include <GUIConstantsEx.au3> Global $__gMGRM_oGUIs = ObjCreate("Scripting.Dictionary") ; obj["0xHWND:MSGID"] = sFuncName Global $__gMGRM_oMSGs = ObjCreate("Scripting.Dictionary") ; obj[iMsgID] = NumGUIs Func _MultiGUIRegisterMsg($hGUI, $iMsg, $vFunc = Null) If IsString($iMsg) Then $iMsg = StringSplit($iMsg, " ,-|;.") For $i = 1 To $iMsg[0] _MultiGUIRegisterMsg($hGUI, Int($iMsg[$i]), $vFunc) Next Return EndIf If IsFunc($vFunc) Or IsString($vFunc) Then ; register message dispatcher, and increment message counter If Not $__gMGRM_oMSGs.Exists($iMsg) Or $__gMGRM_oMSGs.Item($iMsg) <= 0 Then GUIRegisterMsg($iMsg, __multiGUIRegisterMsg_dispatcher) $__gMGRM_oMSGs.Item($iMsg) = 1 Else $__gMGRM_oMSGs.Item($iMsg) = $__gMGRM_oMSGs.Item($iMsg) + 1 EndIf ; register message handler for this GUI $__gMGRM_oGUIs.Item(String($hGUI) & ":" & String($iMsg)) = IsFunc($vFunc) ? FuncName($vFunc) : $vFunc Else ; decrement message counter, unregister message dispatcher if counter reaches 0 $__gMGRM_oMSGs.Item($iMsg) = $__gMGRM_oMSGs.Item($iMsg) - 1 If $__gMGRM_oMSGs.Item($iMsg) <= 0 Then GUIRegisterMsg($iMsg, "") $__gMGRM_oMSGs.Remove($iMsg) EndIf ; unregister message handler for this GUI $__gMGRM_oGUIs.Remove(String($hGUI) & ":" & String($iMsg)) EndIf EndFunc ; ------------------------------------------------------------------------------------------------- ; Internals Func __multiGUIRegisterMsg_dispatcher($hWnd, $iMsg, $wParam, $lParam) Local $sFunc = $__gMGRM_oGUIs.Item(String($hWnd) & ":" & String($iMsg)) If $sFunc Then Return Call($sFunc, $hWnd, $iMsg, $wParam, $lParam) Return $GUI_RUNDEFMSG EndFunc
-
AutoIt3 Lua Wrapper This is an AutoIt3 wrapper for the Lua scripting language. Consider it beta software, but since I will be using it in commercial product, expect it to evolve. It has been developped with Lua 5.3.5. Updates will come for new Lua version. Everything works just fine, except one (big) limitation: Anything that throws a Lua error (using C setjmp/longjmp functionality) will crash your AutoIt program. That means that it is impossible to use throw errors from an AutoIt function called by Lua (luaL_check*, lua_error...). It is hosted in Github: https://github.com/matwachich/au3lua Simple example #include <lua.au3> #include <lua_dlls.au3> ; Initialize library _lua_Startup(_lua_ExtractDll()) OnAutoItExitRegister(_lua_Shutdown) ; create new execution state $pState = _luaL_newState() _luaopen_base($pState) ; needed for the lua's print function $iRet = _luaL_doString($pState, 'print("Hello, world!")') If $iRet <> $LUA_OK Then ; read the error description on top of the stack ConsoleWrite("!> Error: " & _lua_toString($pState, -1) & @CRLF) Exit EndIf ; close the state to free memory (you MUST call this function, this is not AutoIt's automatic memory management, it's a C library) _lua_close($pState)
-
Hello! I was wondering why when I call DllCallbackRegister 2 times on the same function with the same return and parameters types, the function gets registered 2 times? I think in order to avoid memory leak (in case you cannot or forget to call DllCallbackFree), in this case, we should not have a 2'nd registration. This behaviour could be usefull in some UDFs that are wrappers for C libraries when you need to passe callback functions. This will permit to the user of the UDF to passe directly functions, then the function is registered inside the UDF. So event if recalling the same function again and again, the callback is registered only once. Example: ; this function could be called many times with the same AutoIt function as $pfnCFunction parameter Func _lua_pushCClosure($pState, $pfnCFunction, $iN) ; calling DllCallbackRegister again and again on the same function and with same return and parameters type should register the function only once Local $hCallback = DllCallbackRegister(IsFunc($pfnCFunction) ? FuncName($pfnCFunction) : $pfnCFunction, "int:cdecl", "ptr") DllCall($__gLua_hDLL, "none:cdecl", "lua_pushcclosure", "ptr", $pState, "ptr", DllCallbackGetPtr($hCallback), "int", $iN) If @error Then Return SetError(@error, 0, False) Return True EndFunc Any thoughts? Edit: as for now, in order to let the UDFs user pass any value he wants, I'm using this function Func __lua_helper_regFunc($vFunc, $sReturn, $sParams) Local Static $oReg = ObjCreate("Scripting.Dictionary") Switch VarGetType($vFunc) Case "String", "UserFunction" $vFunc = IsString($vFunc) ? $vFunc : FuncName($vFunc) Local $sKey = $vFunc & "|" & $sReturn & "|" & $sParams If $oReg.Exists($sKey) Then Return DllCallbackGetPtr($oReg.Item($sKey)) Else Local $hReg = DllCallbackRegister($vFunc, $sReturn, $sParams) $oReg.Item($sKey) = $hReg Return DllCallbackGetPtr($hReg) EndIf Case "Int32" Return DllCallbackGetPtr($vFunc) Case "Ptr" Return $vFunc EndSwitch Return Null EndFunc