Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/24/2025 in all areas

  1. CYCho

    Simulated Title Bar

    I simulated a title bar for my zPlayer in order to utilize the empty space in the title bar. That was necessary because I wanted to keep the size of the GUI to the minimum. In the case of zPlayer, the GUI was not resizable, so It did not not need the UpdateCoverPosition( ) function. I added it as an idea if it is necessary. Edit: One may ask why I did not use a popup window for the entire GUI. Because I liked the 3-D like effect and the drop shadow of GUIs created in Windows 11. and a popup window does not have these features. #include <GUIConstants.au3> #include <WinAPIGdi.au3> Global $guiWidth = 320, $guiHeight = 100, $barColor = 0x198CFF Global $hGUI, $borderWidth, $barHeight, $GUIPos, $ClientPos Global $hCover, $idMinimize, $ctrlClose, $hRgn, $aMsg, $sMsg $hGUI = GUICreate("", $guiWidth, $guiHeight, -1, -1, $WS_OVERLAPPEDWINDOW) $GUIPos = WinGetPos($hGUI) $ClientPos = WinGetClientSize($hGUI) $borderWidth = ($GUIPos[2] - $ClientPos[0])/2 $barHeight = $GUIPos[3] - $ClientPos[1] - $borderWidth $hCover = GUICreate("", $ClientPos[0]+1, $barHeight, $GUIPos[0]+$borderWidth, $GUIPos[1]+1, $WS_POPUP, -1, $hGUI) GUISetBkColor($barColor, $hCover) GUISetFont(12, 400, 0, "Arial") GUICtrlCreateIcon("user32.dll", 101, 5, 5, 20, 20) GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKSIZE) GUICtrlCreateLabel("Colored Bar Example", 30, 7, 160, 20) GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKSIZE) $ctrlClose = GUICtrlCreateLabel("X", $guiWidth-40, 1, 40, $barHeight, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, $barColor) GUICtrlSetColor(-1, 0x404040) GUICtrlSetResizing(-1, $GUI_DOCKRIGHT+$GUI_DOCKSIZE) GUISetState(@SW_SHOW, $hCover) GUISetState(@SW_SHOW, $hGUI) If @OSVersion = "WIN_11" Then ; Create round corners for $hCover $hRgn = _WinAPI_CreateRoundRectRgn(0, 0, $ClientPos[0]+1, $barHeight+10, 13, 13) _WinAPI_SetWindowRgn($hCover, $hRgn) _WinAPI_DeleteObject($hRgn) EndIf GUIRegisterMsg($WM_WINDOWPOSCHANGED, "WM_WINDOWPOSCHANGED") AdlibRegister("_ColorButton", 100) While 1 $aMsg = GUIGetMsg(1) $sMsg = $aMsg[0] Switch $aMsg[1] Case $hCover Switch $sMsg Case $ctrlClose ExitLoop Case $GUI_EVENT_PRIMARYDOWN ; Click and drag $hCover DllCall("user32.dll", "int", "SendMessageW", "hwnd", $hCover, "uint", $WM_NCLBUTTONDOWN, "wparam", $HTCAPTION, "lparam", 0) EndSwitch EndSwitch WEnd Func WM_WINDOWPOSCHANGED($hWnd, $MsgID, $wParam, $lParam) ; Sync movement of $hGUI and $hCover #forceref $MsgID, $wParam, $lParam Switch $hWnd Case $hCover Local $aPos = WinGetPos($hCover) WinMove($hGUI, "", $aPos[0]-$borderWidth, $aPos[1]-1) Case $hGUI UpdateCoverPosition() EndSwitch Return $GUI_RUNDEFMSG EndFunc Func _ColorButton() ; Change background color of buttons when the mouse is over them Local $aArray = GUIGetCursorInfo($hCover) If $aArray[4] = $ctrlClose Then GUICtrlSetBkColor($ctrlClose, 0xC42B1C) GUICtrlSetColor(-1, 0xFFFFFF) Else GUICtrlSetBkColor($ctrlClose, $barColor) GUICtrlSetColor(-1, 0x404040) EndIf EndFunc Func UpdateCoverPosition() $GUIPos = WinGetPos($hGUI) $ClientPos = WinGetClientSize($hGUI) WinMove($hCover, "", $GUIPos[0]+$borderWidth, $GUIPos[1]+1, $ClientPos[0]+1, $barHeight) If @OSVersion = "WIN_11" Then ; Update round corners for $hCover $hRgn = _WinAPI_CreateRoundRectRgn(0, 0, $ClientPos[0]+1, $barHeight+10, 13, 13) _WinAPI_SetWindowRgn($hCover, $hRgn) _WinAPI_DeleteObject($hRgn) EndIf EndFunc
    1 point
  2. That’s my mistake, I apologize. Every single snippet of code examples on the forum that have helped me were runnable code in nice, small examples. So I understand. It wastes more time if it’s not readily runnable. I will try your example after dinner and also post a small, runnable example of the issue.
    1 point
  3. I see. You could use something like this instead of creating 2 listviews : #include <WindowsConstants.au3> #include <GUIListView.au3> #include <GUIConstants.au3> GUICreate("Example", 300, 300) Local $idListView = GUICtrlCreateListView("Test", 10, 10, 280, 280, $LVS_NOCOLUMNHEADER + $LVS_SINGLESEL, $LVS_EX_CHECKBOXES) _GUICtrlListView_SetView($idListView, 3) Local $aTest[5] = ["test1", "test2", "test3", "test4", "test5"] For $i = 0 To UBound($aTest) - 1 GUICtrlCreateListViewItem($aTest[$i], $idListView) Next GUISetState() While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd ps. Next time, please provide runable code, not just a part of a script. You need to help us to help you...
    1 point
  4. water

    excel pagebreak add com

    You are correct. The thread is very, very old. It would have been better to create a new thread and - if needed - refer to this thread I have been able to translate this VBA solution to AutoIt: #include <Excel.au3> ; XlDirection enumeration - Specifies the direction in which to move. Global Const $xlUp = -4162 ; Up. ; XlPageBreak-Enumeration - Specifies page break location on the worksheet. Global Const $xlPageBreakManual = -4135 ; Page breaks are manually inserted. Global $oExcel, $oWorkbook, $oWorksheet, $iLastRow $oExcel = _Excel_Open() $oWorkbook = _Excel_BookAttach("Mappe1") ; Change the name of the already opened workbook _AddPageBreaks($oExcel, $oWorkbook.Sheets(1)) Exit Func _AddPageBreaks($oExcel, $oWorksheet) Local $iLastRow = $oWorksheet.Cells($oWorksheet.Rows.Count, "A").End($xlUp).Row ; find last used row in column A For $iRow = 10 To $iLastRow Step 8 $oWorksheet.HPageBreaks.Add($oWorksheet.Rows($iRow)) $oWorksheet.Rows($iRow).PageBreak = $xlPageBreakManual Next EndFunc ;==>_AddPageBreaks
    1 point
  5. Nine

    AutoIt Snippets

    Following this previous snippet, I was playing with the idea of drawing stuff within MsgBox. So here it is : #include <WindowsConstants.au3> #include <WinAPISys.au3> #include <WinAPIGdi.au3> Opt("MustDeclareVars", True) Example() Func Example() Local $hForm = GUICreate("") GUIRegisterMsg(_WinAPI_RegisterWindowMessage('SHELLHOOK'), WM_SHELLHOOK) _WinAPI_RegisterShellHookWindow($hForm) Local $iRet = MsgBox($MB_OK, "MsgBox", "Message") ConsoleWrite("Returned = " & $iRet & @CRLF) _WinAPI_DeregisterShellHookWindow($hForm) EndFunc ;==>Example Func WM_SHELLHOOK($hWnd, $iMsg, $wParam, $lParam) If $wParam <> $HSHELL_WINDOWCREATED Then Return If _WinAPI_GetClassName($lParam) = "#32770" And _WinAPI_GetDlgItem($lParam, 0xFFFF) Then ; means dialog box ControlSetText($lParam, "", "Button1", "Cool") Local $aSize = WinGetClientSize($lParam) Local $hDC = _WinAPI_GetDC($lParam) Local $hPen = _WinAPI_CreatePen($PS_SOLID, 3, 0xFF) Local $oCurr = _WinAPI_SelectObject($hDC, $hPen) _WinAPI_DrawLine($hDC, 0, 0, $aSize[0], 0) ; top _WinAPI_DrawLine($hDC, 0, 0, 0, $aSize[1]) ; left _WinAPI_DrawLine($hDC, $aSize[0], 0, $aSize[0], $aSize[1]) ; right _WinAPI_DrawLine($hDC, 0, $aSize[1], $aSize[0], $aSize[1]) ; bottom _WinAPI_SelectObject($hDC, $oCurr) _WinAPI_DeleteObject($hPen) _WinAPI_ReleaseDC($lParam, $hDC) EndIf EndFunc ;==>WM_SHELLHOOK
    1 point
×
×
  • Create New...