Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/16/2021 in all areas

  1. GUICreate("My GUI get time", 200, 200, 800, 200, $WS_CLIPCHILDREN) ; or GUISetBkColor($bActive ? $COLOR_GREEN : $COLOR_RED) _WinAPI_InvalidateRect(GUICtrlGetHandle($idDate)) ; Global $idDate
    2 points
  2. I think it's some bug, probably in AutoIt. I tried this workaround in several ways but with no luck, ;~ #include "<SendMessage.au3>" #include <WindowsConstants.au3> #include <WinAPIGDIInternals.au3> ;~ #include "<GUIDateTimePicker.au3>" ;~ #include "<DateTimeConstants.au3>" #include <ColorConstants.au3> #include <DateTimeConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Global $idDate, $hDate Example() Func Example() GUICreate("My GUI get time", 200, 200, 800, 200) ToggleColour() $idDate = GUICtrlCreateDate("", 20, 20, 100, 20, $DTS_TIMEFORMAT) $hDate = GUICtrlGetHandle($idDate) GUICtrlSetBkColor(-1, $COLOR_WHITE) GUISetState(@SW_SHOW) AdlibRegister(ToggleColour, 2000) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete() EndFunc ;==>Example Func ToggleColour() Local Static $bActive = False GUISetBkColor($bActive ? $COLOR_GREEN : $COLOR_RED) $bActive = Not $bActive ;~ GUICtrlSendMsg($idDate, $DTM_SETFORMATW, 0, 'HH:mm:ss') ;~ _SendMessage($hDate, $WM_SETREDRAW, True) GUICtrlSendMsg($idDate, $WM_SETREDRAW, 1, 0) ;~ GUICtrlSendMsg($hDate, $WM_SETREDRAW, 1, 0) ;~ _WinAPI_RedrawWindow($hDate) EndFunc princip is to invoke redraw of DateTime picker control after GUISetBkColor() I think it have to be changed/improved by getting handle to UpDown control (Inside DateTime control) by DTM_GETDATETIMEPICKERINFO message see HWND hwndUD (A handle to the up/down control) in struct tagDATETIMEPICKERINFO https://docs.microsoft.com/en-us/windows/win32/controls/dtm-getdatetimepickerinfo https://docs.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-datetimepickerinfo then try GUICtrlSendMsg($hUpDown, $WM_SETREDRAW, 1, 0) or _WinAPI_RedrawWindow($hUpDown) Hardest part is creating AutoIt's declaration of structure tagDATETIMEPICKERINFO
    1 point
  3. Sure, this is fair swipe at my staid work. But no such criticism can be lodged against @mikell‘s creation. Take a look at the self-mulching action of the $res array! Capped off with the delightfully unexpected, if trenchant truncation: ReDim $res[$i+1][2] Bravissimi to you both!
    1 point
  4. Try this: ;Coded by UEZ build 2021-05-14 beta #include <GDIPlus.au3> #include <WinAPIFiles.au3> Global $sImageFile = FileOpenDialog("Select an GDI+ supported image", "", "Images (*.jpg;*.bmp;*.png;*.gif;*.tif;*.tiff)") If @error Then Exit _GDIPlus_Startup() Global $hImage = _GDIPlus_ImageLoadFromFile($sImageFile) $sImageFile = StringMid($sImageFile, StringInStr($sImageFile, "\", 0, -1) + 1) $sImageFile = @ScriptDir & "\" & StringMid($sImageFile, 1, StringLen($sImageFile) - 4) & ".cur" _GDIPlus_CreateCursorFileFromImage($hImage, $sImageFile, 32, 32) If @error Then MsgBox($MB_ICONERROR, "Error", "Something went wrong!", 10) Else MsgBox($MB_ICONINFORMATION, "Information", "Cursor file has been created. Check out: " & $sImageFile, 10) EndIf _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GDIPlus_CreateCursorFileFromImage ; Version .......: v0.15 build 2021-05-14 beta ; Description ...: Converts a GDI+ support image to a windows cursor format and saves it to disk. ; Syntax ........: _GDIPlus_CreateCursorFileFromImage($hImage[, $sFilename = ""[, $iWidth = 32[, $iHeight = 32]]]) ; Parameters ....: $hImage - a handle value. ; $sFilename - [optional] a string value. Default is "". ; $iWidth - [optional] an integer value. Default is 32. ; $iHeight - [optional] an integer value. Default is 32. ; $iSpotX - [optional] an integer value. Default is 0. ; $iSpotY - [optional] an integer value. Default is 0. ; Return values .: True if file has been created ; Author ........: UEZ ; Modified ......: ; Remarks .......: If $sFilename is empty then the handle of the cursor will be returned instead. No animated cursor possible yet! ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _GDIPlus_CreateCursorFileFromImage($hImage, $sFilename = "", $iWidth = 32, $iHeight = 32, $iSpotX = 0, $iSpotY = 0) If $hImage = 0 Then Return SetError(1, 0, 0) Local $aDim = _GDIPlus_ImageGetDimension($hImage) If @error Then Return SetError(2, 0, 0) ;create image with scaled size $iWidth = $iWidth > 255 ? 255 : $iWidth < 1 ? 1 : $iWidth $iHeight = $iHeight > 255 ? 255 : $iHeight < 1 ? 1 : $iHeight Local Const $hImage_scaled = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $GDIP_PXF32ARGB) Local Const $hCanvas = _GDIPlus_ImageGetGraphicsContext($hImage_scaled) _GDIPlus_GraphicsSetInterpolationMode($hCanvas, $GDIP_INTERPOLATIONMODE_HIGHQUALITYBICUBIC) _GDIPlus_GraphicsDrawImageRect($hCanvas, $hImage, 0, 0, $iWidth, $iHeight) Local Const $hIcon = _GDIPlus_HICONCreateFromBitmap($hImage_scaled) _GDIPlus_GraphicsDispose($hCanvas) _GDIPlus_ImageDispose($hImage_scaled) If $hIcon = 0 Then Return SetError(3, 0, 0) Local $iErr = 0 If $sFilename <> "" Then If _WinAPI_SaveHICONToFile($sFilename, $hIcon) = 0 Then $iErr += 1 _WinAPI_DestroyIcon($hIcon) If $iErr Then Return SetError(4, $iErr, 0) Else Local $aIcon = _WinAPI_GetIconInfo($hIcon) Local $hCursor = _WinAPI_CreateIconIndirect($aIcon[5], $aIcon[4], $iSpotX, $iSpotY, False) If $hCursor = 0 Then $iErr += 1 _WinAPI_DestroyIcon($hIcon) If $iErr Then Return SetError(5, $iErr, 0) Return $hCursor EndIf Local $tagCur = "align 1;word;word ImageType;word NumberOfImgs;", $tagImgHeader = "byte Width;byte Height;byte PaletteColors;byte;word Format1;word Format2;dword Size;dword OffsetImg;" Local $tHeader = DllStructCreate($tagCur & $tagImgHeader), $iSize = DllStructGetSize($tHeader) ;read the header to the struct Local $nBytes Local $hFile = _WinAPI_CreateFile($sFilename, 2, 2) _WinAPI_ReadFile($hFile, $tHeader, $iSize, $nBytes) _WinAPI_CloseHandle($hFile) If $nBytes <> $iSize Then Return SetError(6, 0, 0) ;generate the file $nBytes = 0 $tHeader.ImageType = 2 $tHeader.Format1 = $iSpotX $tHeader.Format2 = $iSpotY $hFile = _WinAPI_CreateFile($sFilename, 2, 4) _WinAPI_SetFilePointer($hFile, 0) _WinAPI_WriteFile($hFile, $tHeader, $iSize, $nBytes) _WinAPI_CloseHandle($hFile) If $nBytes <> $iSize Then Return SetError(7, 0, 0) Return 1 EndFunc ;==>_GDIPlus_CreateCursorFileFromImage Almost, you must change 1 entry within the header of the cursor struct to become a cursor file.
    1 point
  5. The caret moves but $GUI_FOCUS re-focuses the caret back to the start. I can't seem to come up with a workaround.
    1 point
×
×
  • Create New...