Jump to content

Search the Community

Showing results for tags 'scrollbar'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • Forum FAQ
  • AutoIt

Calendars

  • Community Calendar

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 9 results

  1. #include <GUIConstants.au3> #include <WinAPI.au3> ; for _WinAPI_CreateWindowEx() Opt("MustDeclareVars", 1) ; example from "https://www.autoitscript.com/forum/topic/178961-resize-control/?do=findComment&comment=1336645" Global Const $SBS_SIZEBOX = 0x08 Global Const $SBS_SIZEGRIP = 0x10 Global $hGui, $hSizebox Example() Func Example() Local $iW = 250, $iH = 50 $hGui = GUICreate("Resize corner", $iW, $iH, -1, -1, $WS_OVERLAPPEDWINDOW) GUISetBkColor(0x00FF) Local $idResizeLabel = GUICtrlCreateLabel("", $iW - 20, $iH - 20, 22, 22) GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKBOTTOM + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) GUICtrlSetCursor(-1, 12) $hSizebox = _WinAPI_CreateWindowEx(0, "Scrollbar", "", $WS_CHILD + $WS_VISIBLE + $SBS_SIZEBOX, $iW - 20, $iH - 20, 20, 20, $hGui) ; $SBS_SIZEBOX or $SBS_SIZEGRIP GUIRegisterMsg($WM_SIZE, "WM_SIZE") GUISetState() Local $iResize = 0 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_PRIMARYUP If $iResize Then $iResize = 0 ; restore the default mouse behaviour GUISetCursor(2, 0, $hGui) GUICtrlSetState($idResizeLabel, $GUI_SHOW) EndIf Case $idResizeLabel $iResize = 1 GUICtrlSetState($idResizeLabel, $GUI_HIDE) GUISetCursor(12, 1, $hGui) MouseDown("MAIN") ; ..now that the Ctrl is hidden, nothing is held down, so we fake it ;) EndSwitch WEnd GUIDelete($hGui) Exit EndFunc ;==>Example Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam) Local $aSize = WinGetClientSize($hGui) WinMove($hSizebox, "", $aSize[0] - 20, $aSize[1] - 20) EndFunc ;==>WM_SIZE The question is: how do I color that CreateWindowEx ? Thanks
  2. Under program control is there an easy way to move a slider (thumb) to the top or bottom? I am aware of Melba23's GUIScrollbars_Ex UDF (https://www.autoitscript.com/forum/topic/113723-scrollbars-made-easy-bugfix-version-2-may-21/) but I believe it's overkill for my simple needs. In a listview with a vertical scrollbar when the window is active one can hit Ctrl+Home to move the scrollbar slider (thumb) to the top and Ctrl+End to the bottom. One can also right click the slider and choose Scroll Here, Top, Bottom, Page UP, Page Down, Scroll Up, and Scroll Down. I must be doing something basically wrong but am stuck. Move the thumb to the middle before clicking the Top button to test the code below (Bottom is not coded). I've commented out other trys. try #3 is a strange fail. Any comments on what I'm missing greatly appreciated as I'm stuck #AutoIt3Wrapper_run_debug_mode=Y #include <Debug.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <GuiScrollBars.au3> AutoItSetOption("MustDeclareVars", 1) ;v1b - cut out extraneous code Example() Exit Func Example() Local $i, $j, $x, $hGUI, $idListView, $bTop, $bBottom $hGUI = GUICreate("Scrollbar Question", 300, 400) ;get handle in case we need it later $idListView = GUICtrlCreateListView("Col 0", 10, 10, 280, 300) $bTop = GUICtrlCreateButton("Top", 10, 350, 60, 25) $bBottom = GUICtrlCreateButton("Bottom", 120, 350, 60, 25) ;Pause("$hGUI = '" & $hGUI &"'"& @CRLF & "$idListView = '" & $idListView &"'") For $i = 1 to 100 _GUICtrlListView_AddItem($idListView, $i) Next GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $bTop ;drag thumb to middle of scrollbar before clicking Top button ;try #1 - FAILS Opt("WinTitleMatchMode", 2) ;2 = Match any substring in the title $x = WinActivate("Scrollbar Question") ;not $idListview but main GUI $hGUI - neither working If $x <> $hGUI Then Pause("WinActivate FAILED") Send("^{HOME}") ;Ctrl+home ;try#2 - FAILS ;~ $x = WinActivate($hGUI) ;try Main GUI ;~ If $x <> $hGUI Then Pause("WinActivate FAILED") ;~ Send("^{HOME}") ;Ctrl+home ;try#3 - strange FAILS ;~ $x = WinActivate($idListview) ;try $idListview ;~ If $x <> $idListview Then Pause("WinActivate FAILED") ;strange it works BUT if I comment out this line it fails ;~ ;Sleep(1000) ;it's not a time delay issue ;~ Send("^{HOME}") ;Ctrl+home ;try#4 - same strange fail as #3 ;~ $x = WinActivate($idListview) ;try $idListview ;~ If $x <> $idListview Then Pause("WinActivate FAILED") ;~ Send("{UP 100}") ;try#5 - what the heck is going on? same strange fail as #3 ;$x = WinActivate($idListview) ;try $idListview ;~ $x = WinActivate($hGUI) ;try Main GUI ;~ If $x <> $idListview Then Pause("WinActivate FAILED") ;~ MouseWheel($MOUSE_WHEEL_UP, 100) ;_GUIScrollBars_ScrollWindow($hGUI, 0, 100) ;NO - moves the ListView window in the $hGUI ;_GUIScrollBars_ScrollWindow($idListview, 0, 100) ;does not seem to work ;_GUIScrollBars_SetScrollInfoPos($hGUI, $SB_VERT, 30) ;does not work ;_GUIScrollBars_SetScrollInfoPos($idListview, $SB_VERT, 30) ;does not work ;I'm doing something very basic wrong. I need help. Pause("Scrollbar thumb should be at Top") Case $bBottom Pause("In: Case $bBottom") Pause("Scroll bar should be at BOttom") EndSwitch WEnd GUIDelete($idListView) EndFunc ;Func Example() Func Pause($text="") MsgBox(262144, "DEBUG", "Paused: " & $text) EndFunc
  3. Hi, I have a problem with the scrollbar in edit control. In my case I use richedit, but it appears also in the "normal" editcontrol. The problem ONLY appears, when working with my program (including editcontrol) and another program like notpad on the other screen. It appears when using the scrollbar of notepad, then my scroll bar and so on ... (vertical scrollbars only) and then suddenly the area behind my scrollbar gets highlighted (black) like selected, above and below, if i move the mouse to the left during pressing, the whole area behind the scrollbar gets highlighted in black. When my program is loaded alone the problem NEVER happens. I have made two screenshots, 1st one when the problem appears, and the second one showing when moving to the left. I really have no idea and there is nothing special in my editcontrol. I would be really thankful, if someone could help me further to get this issue solved. thanks in advance cheers mike
  4. Following script shows a parent GUI with a child GUI initialized as MDICHILD. #include <Constants.au3> #include <GUIConstantsEx.au3> #include <GuiReBar.au3> #include <GuiScrollBars.au3> #include <GuiToolbar.au3> #include <ScreenCapture.au3> #include <ScrollBarConstants.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() Global Enum $idNew = 1000, $idOpen, $idSave, $idHelper Global Const $iImageW = @DesktopWidth, $iImageH = @DesktopHeight Global Const $hBMP_ScreenCapture = _ScreenCapture_Capture("", 0, 0, $iImageW, $iImageH, False) Global Const $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP_ScreenCapture) Sleep(50) Global Const $iW = 1500, $iH = 700, $SC_DRAGMOVE = 0xF012 Global Const $hGUI = GUICreate("Move child GUI within GUI", $iW, $iH) Global Const $hToolbar = _GUICtrlToolbar_Create($hGUI) Global Const $hReBar = _GUICtrlRebar_Create($hGUI, BitOR($CCS_TOP, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS)) Global Const $height_delta = 37 Global Const $idPic = GUICtrlCreatePic("", 0, $height_delta + 2, $iW, $iH) Global $hBitmap_tmp, $hHBitmap_tmp $hBitmap_tmp = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Global $hGfx_Context = _GDIPlus_ImageGetGraphicsContext($hBitmap_tmp) _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR) _GUICtrlToolbar_AddButton($hToolbar, $idNew, $STD_FILENEW) _GUICtrlToolbar_AddButton($hToolbar, $idOpen, $STD_FILEOPEN) _GUICtrlToolbar_AddButton($hToolbar, $idSave, $STD_FILESAVE) _GUICtrlToolbar_AddButtonSep($hToolbar) _GUICtrlToolbar_AddButton($hToolbar, $idHelper, $STD_HELP) _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0) Global Const $iVSscroll = _WinAPI_GetSystemMetrics(2) Global Const $iHSscroll = _WinAPI_GetSystemMetrics(3) Global Const $iYCaption = _WinAPI_GetSystemMetrics(4) Global Const $iYFixedFrame = _WinAPI_GetSystemMetrics(8) Global Const $iXFixedFrame = _WinAPI_GetSystemMetrics(7) Global Const $iMetricsSumX = $iVSscroll + $iXFixedFrame * 2 Global Const $iMetricsSumY = $iHSscroll + $iYCaption + $iYFixedFrame _GUIScrollBars_Init($hGUI) _GUIScrollBars_SetScrollInfoMin($hGUI, $SB_HORZ, 0) _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_HORZ, $iImageW - $iW + 61 + $iMetricsSumX) _GUIScrollBars_SetScrollInfoMin($hGUI, $SB_VERT, 0) _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_VERT, $iImageH - $iH + $iMetricsSumY + $height_delta - 1) GUISetState(@SW_SHOW, $hGUI) Global Const $STM_SETIMAGE = 0x0172 _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBMP_ScreenCapture)) Global $IE_offset_x = 0, $IE_offset_y = 0 DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH) GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL_IE") GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL_IE") Global $iPosX_Crop = 0, $iPosY_Crop = 0, $iW_crop = 200, $iH_crop = 200, $bMove_Crop = True Global $hGUI_IE_Crop = GUICreate("", $iW_crop, $iH_crop, $iPosX_Crop, $iPosY_Crop) GUISetStyle(BitOR($WS_BORDER, $WS_POPUP), $WS_EX_MDICHILD) _WinAPI_SetParent($hGUI_IE_Crop, $hGUI) WinSetTrans($hGUI_IE_Crop, "", 0xA0) Global $iLable_CropMove = GUICtrlCreateLabel("", 0, 0, $iW_crop, $iH_crop, -1, $GUI_WS_EX_PARENTDRAG) GUISetState(@SW_SHOW, $hGUI_IE_Crop) GUIRegisterMsg($WM_MOVE, "WM_MOVE_IE_GUI_Crop") ;~ GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN") Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch Until False GUIRegisterMsg($WM_HSCROLL, "") GUIRegisterMsg($WM_VSCROLL, "") GUIRegisterMsg($WM_MOVE, "") GUIRegisterMsg($WM_LBUTTONDOWN, "") _WinAPI_DeleteObject($hBMP_ScreenCapture) _GDIPlus_BitmapDispose($hBitmap_tmp) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGfx_Context) _GDIPlus_Shutdown() Exit Func WM_HSCROLL_IE($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $lParam Local $Min, $Max, $Page, $TrackPos ; Get all the horizontal scroll bar information Local $tSCROLLINFO_X = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ) $Min = DllStructGetData($tSCROLLINFO_X, "nMin") $Max = DllStructGetData($tSCROLLINFO_X, "nMax") $Page = DllStructGetData($tSCROLLINFO_X, "nPage") ; Save the position for comparison later on $IE_offset_x = DllStructGetData($tSCROLLINFO_X, "nPos") $TrackPos = DllStructGetData($tSCROLLINFO_X, "nTrackPos") #forceref $Min, $Max Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Switch $nScrollCode Case $SB_LINELEFT ; user clicked left arrow DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x - 1) Case $SB_LINERIGHT ; user clicked right arrow DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x + 1) Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x - $Page) Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x + $Page) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO_X, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO_X, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO_X) $IE_offset_x = DllStructGetData($tSCROLLINFO_X, "nPos") DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH) $hHBitmap_tmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_tmp) _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap_tmp)) _WinAPI_DeleteObject($hHBitmap_tmp) $bMove_Crop = False ConsoleWrite($iPosX_Crop & ", " & $iPosY_Crop & " / " & $IE_offset_x & ", " & $IE_offset_y & @CRLF) WinMove($hGUI_IE_Crop, "", -$IE_offset_x + $iPosX_Crop, -$IE_offset_y + $iPosY_Crop) ;~ DllCall("user32.dll", "bool", "MoveWindow", "hwnd", $hGUI_IE_Crop, "int", -$IE_offset_x + $iPosX_Crop, "int", -$IE_offset_y + $iPosY_Crop, "int", $iW_crop, "int", $iH_crop, "bool", True) $bMove_Crop = True Return "GUI_RUNDEFMSG" EndFunc ;==>WM_HSCROLL_IE Func WM_VSCROLL_IE($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $lParam Local $Min, $Max, $Page, $TrackPos ;~ ; Get all the horizontal scroll bar information Local $tSCROLLINFO_Y = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $Min = DllStructGetData($tSCROLLINFO_Y, "nMin") $Max = DllStructGetData($tSCROLLINFO_Y, "nMax") $Page = DllStructGetData($tSCROLLINFO_Y, "nPage") ; Save the position for comparison later on $IE_offset_y = DllStructGetData($tSCROLLINFO_Y, "nPos") $TrackPos = DllStructGetData($tSCROLLINFO_Y, "nTrackPos") #forceref $Min, $Max Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Switch $nScrollCode Case $SB_LINELEFT ; user clicked left arrow DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y - 1) Case $SB_LINERIGHT ; user clicked right arrow DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y + 1) Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y - $Page) Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y + $Page) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO_Y, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO_Y, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO_Y) $IE_offset_y = DllStructGetData($tSCROLLINFO_Y, "nPos") DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH) $bMove_Crop = False ConsoleWrite($iPosX_Crop & ", " & $iPosY_Crop & " / " & $IE_offset_x & ", " & $IE_offset_y & @CRLF) WinMove($hGUI_IE_Crop, "", -$IE_offset_x + $iPosX_Crop, -$IE_offset_y + $iPosY_Crop) ;~ DllCall("user32.dll", "bool", "MoveWindow", "hwnd", $hGUI_IE_Crop, "int", -$IE_offset_x + $iPosX_Crop, "int", -$IE_offset_y + $iPosY_Crop, "int", $iW_crop, "int", $iH_crop, "bool", True) $bMove_Crop = True Return "GUI_RUNDEFMSG" EndFunc ;==>WM_VSCROLL_IE Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) _SendMessage($hGUI_IE_Crop, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndFunc ;==>_WM_LBUTTONDOWN Func WM_MOVE_IE_GUI_Crop($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam If $hWnd = $hGUI_IE_Crop And $bMove_Crop Then $iPosX_Crop = _WinAPI_LoWord($lParam) $iPosY_Crop = _WinAPI_HiWord($lParam) EndIf Return "GUI_RUNDEFMSG" EndFunc ;==>WM_MOVE_IE_GUI_Crop Func WM_SIZE_IE_GUI_Crop($hWnd, $iMsg, $wParam, $lParam) Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE_IE_GUI_Crop Func DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH) _GDIPlus_GraphicsDrawImageRectRect($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH, 0, 0, $iW, $iH) $hHBitmap_tmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_tmp) _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap_tmp)) _WinAPI_DeleteObject($hHBitmap_tmp) EndFunc My problem: if you move the child window at left upper corner to another place and move either H or V scrollbar the child GUI will be moved properly. BUT if you have scrolled the scrollbars to the right bottom of the image and move the child GUI to that corner, too then the child GUI jumps if you click on one of the scrollbars. Is there something that I didn't consider?
  5. Let's say a script has to do something that may or may not shift the page a fair bit in a general DTP program, browser, ... In other words, the scrollbar was moved. (1) Can the original scrollbar position be saved and restored? I can think of a rough workaround or two, but I mean, more precisely...? (2) If so, is it for example a different control for every program? (3) Let's say for a workaround you might use the help of ... MouseWheel ( "direction" [, clicks = 1] ) Is there an absolute relationship of clicks to pixels? Or does the amount of scroll from these 'clicks' depend on how much movement was defined for the scroll wheel in Windows or Mouse driver software? Thank You
  6. Hi guys, I have a GUI which requires scrolling, however resizing is a bit of a problem because any time you scroll down/up and then resize, the controls move down/up and blank space is created within the scrollable area. Any help with maintaining scrollable area size to be fixed would be great. Here is a reproducer: To achieve the undesirable effect I described, simply run the script, scroll down and then resize window. You will notice that new blank space is created either on top or on bottom of the window depending on scrolling/resizing direction. Easiest way to see how bad it is, is to scroll down the page about half-way and then maximise the window. You will notice now a whole bunch of blank space is added to the top of the window and scrolling up simply shows nothing, scrolling down shows controls but they are cut off because of the blank space created on top of the page. This is all happening within the yellow bg child gui. I need to make it so that even if the GUI is resized the contents of the yellow bg child gui do not move and the scrollable area within the child gui remains the same. #NoTrayIcon #include-once #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIScroll.au3> #include <SendMessage.au3> Opt("GUIResizeMode", 802) Global $parentgui_w = 880, $parentgui_h = 810, $childgui_w = $parentgui_w - 2, $childgui_h = $parentgui_h - 292 $parentgui = GUICreate("Scrollbar resize problem", $parentgui_w, $parentgui_h, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SIZEBOX)) GUISetBkColor(0xFFFFFF, $parentgui) $childgui = GUICreate("", $childgui_w, $childgui_h, -5, 263, $WS_POPUP, $WS_EX_MDICHILD, $parentgui) GUISetBkColor(0xFFF123, $childgui) Dim $buttons[25] For $i = 0 to 24 If $i > 0 Then $cPos = ControlGetPos($childgui, "", $buttons[$i - 1]) $buttons[$i] = GUICtrlCreateButton("Button " & $i + 1, ($childgui_w - 200) / 2, $cPos[1] + $cPos[3] + 50, 200, 80) Else $buttons[$i] = GUICtrlCreateButton("Button " & $i + 1, ($childgui_w - 200) / 2, 20, 200, 80) EndIf Next Scrollbar_Create($childgui, $SB_VERT, 130 * 25) Scrollbar_Step(15, $childgui, $SB_VERT) GUIRegisterMsg($WM_SIZE, "WM_SIZE") GUIRegisterMsg($WM_NCACTIVATE, "WM_NCACTIVATE") GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL") GUISetState(@SW_SHOW, $parentgui) GUISetState(@SW_SHOWNOACTIVATE, $childgui) While 1 $msg = GUIGetMsg(1) Switch $msg[1] Case $parentgui Switch $msg[0] Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_RESTORE $pPos = WinGetPos($parentgui) WinMove($parentgui, "", Default, Default, $pPos[2]+1, $pPos[3]+1) WinMove($parentgui, "", Default, Default, $pPos[2]-1, $pPos[3]-1) EndSwitch EndSwitch WEnd Func WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam) Local $iMw = BitShift($wParam, 16) $scroll_lines = 5 If $iMw > 0 Then For $i = 0 to $scroll_lines _SendMessage($childgui, $WM_VSCROLL, $SB_LINEUP) Next Else For $i = 0 to $scroll_lines _SendMessage($childgui, $WM_VSCROLL, $SB_LINEDOWN) Next EndIf Return $GUI_RUNDEFMSG EndFunc Func WM_SIZE($hwnd, $uMsg, $wParam, $lParam) If $hwnd = $parentgui Then $wPos = WinGetPos($parentgui) $pgui_wdiff = ($wPos[2] - $parentgui_w) / 2 $pgui_hdiff = ($wPos[3] - $parentgui_h) / 2 If $pgui_wdiff > 7 Then If $pgui_hdiff <> 0 Then If $wPos[2] > $parentgui_w Then WinMove($childgui, "", $wPos[0] + 2 + $pgui_wdiff, Default, $parentgui_w - 2, $wPos[3] - 306) Else WinMove($childgui, "", $wPos[0] + 2 + $pgui_wdiff, Default, $wPos[2] - 16, $wPos[3] - 306) EndIf Else WinMove($childgui, "", $wPos[0] + 2 + $pgui_wdiff, Default) EndIf ElseIf $pgui_wdiff < 7 Then If $wPos[0] <> -32000 Then WinMove($childgui, "", $wPos[0] + 8, Default, $wPos[2] - 16, $wPos[3] - 306) EndIf ElseIf $pgui_hdiff > 42 Then WinMove($childgui, "", Default, Default, Default, $wPos[3] - 306) EndIf EndIf Return 0 EndFunc Func WM_NCACTIVATE($hwnd, $imsg, $wparam) If $hwnd = $parentgui Then If NOT $wparam Then Return 1 EndIf Return $gui_rundefmsg EndFunc
  7. I have a list (GUICtrlCreateList) tall enough to display 7 items. A scrollbar appears when the list had more than 7 items, which is the desired behavior. However, if the list is showing the last 7 items, not the first 7. In other words, the scrollbar is scrolled to the end by default instead of the top of the list. Is there any way to change this behavior? Here's what I have: Local $List_Queue = GUICtrlCreateList("", 2, 60, 400, 100, BitOR($LBS_MULTIPLESEL,$WS_HSCROLL,$WS_VSCROLL,$WS_BORDER)) GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling
  8. I have already made a regarding the same issue. But its old enough to start the discussion again there. I wanted to have a custom scrollbar for an edit control. This is the script, it works as required. CScrollBar #include-once #include <GDIP.au3> ;http://www.autoitscript.com/forum/topic/106021-gdipau3/ #include <WinAPIEx.au3> #include <GuiConstantsEx.au3> #include <Constants.au3> #include <WindowsConstants.au3> #include <ScrollBarConstants.au3> #include <Misc.au3> #include <GUIEdit.au3> #include <Array.au3> Global $iWidth_VSCROLL = _WinAPI_GetSystemMetrics($SM_CXVSCROLL) Global $hGraphic, $hGraphicGUI, $hBMPBuff ;Double-Click Global $iDoubleClickTime = DllCall("user32.dll", "uint", "GetDoubleClickTime") $iDoubleClickTime = $iDoubleClickTime[0] ;User-Custom Messages Global $WM_UPDATETHUMB = $WM_APP + 11 ;Called when the height of the thumb has to be changed. Global $WM_THUMBMOVE = $WM_APP + 12 ;Called when the Thumb has been clicked Global $WM_ARROWDOWN = $WM_APP + 13 ;Called when the Arrow buttons have been clicked. Global $WM_PAINTSCROLLBAR = $WM_APP + 14 ;Implements the painting of the scroll bar over the NC area of the EditBox. Global Const $tagNCCALCSIZE_PARAMS = $tagRECT & ";" & $tagRECT & ";" & $tagRECT & ";ptr PWINDOWPOS" ; Register callback function and obtain handle to _New_WndProc Global $___hNew_WndProc = DllCallbackRegister("_New_WndProc", "int", "hwnd;uint;wparam;lparam") ; Get pointer to _New_WndProc Global $___pNew_WndProc = DllCallbackGetPtr($___hNew_WndProc) Global $___cEdit ; Handle of the Edit Global $___pOld_WndProc ; Old Window Procedure's Address _GDIPlus_Startup() Global $hPen = _GDIPlus_PenCreate(0xAAFCD667, 2), _ $hBrush = _GDIPlus_BrushCreateSolid(0xAAFCD667), _ $hFormat = _GDIPlus_StringFormatCreate(), _ $hFamily = _GDIPlus_FontFamilyCreate("Wingdings"), _ $hPath = _GDIPlus_PathCreate() Func Startup_CustomScrollBar($hEdit) $___cEdit = $hEdit ;get the handle of the edit $___pOld_WndProc = _SubClass($hEdit, $___pNew_WndProc) ;store the old WndProc ;post a WM_NCCALCSIZE msg. _WinAPI_SetWindowPos($hEdit, Default, Default, Default, Default, Default, $SWP_FRAMECHANGED) EndFunc ;==>Startup_CustomScrollBar Func Shutdown_CustomScrollBar();Mem Release ;unsubclass the control _SubClass($___cEdit, $___pOld_WndProc) ;dispose the resources _Gdiplus_PathDispose($hPath) _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrush) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_FontFamilyDispose($hFamily) DllCallbackFree($___hNew_WndProc) EndFunc ;==>Shutdown_CustomScrollBar ;The path of the Top Arrow button ;This could be rotated to obtain the Bottom Arrow button's path. Func TopBtn_Path(ByRef $hPath, $iX, $iY, $iSide) ;* Not required when the path is in order. _GDIPlus_PathStartFigure($hPath) ;* _GDIPlus_PathAddLine($hPath, $iX + $iSide, $iY + $iSide, $iX + $iSide, $iY) _GDIPlus_PathAddLine($hPath, $iX + $iSide, $iY, $iX, $iY) _GDIPlus_PathAddLine($hPath, $iX, $iY, $iX, $iY + $iSide) _GDIPlus_PathAddArc($hPath, $iX, $iY + $iSide / 2, $iSide, $iSide, 180, 180) _GDIPlus_PathCloseFigure($hPath) ;* EndFunc ;==>TopBtn_Path ;The Path of the Thumb Func ThumbBtn_Path(ByRef $hPath, $iX, $iY, $iHeight, $iSide) ;* Not required when the path is in order. _GDIPlus_PathStartFigure($hPath) ;* _GDIPlus_PathAddLine($hPath, $iX, $iY, $iX, $iY + $iHeight) _GDIPlus_PathAddArc($hPath, $iX, $iY + $iHeight - $iSide / 2, $iSide, $iSide, 180, -180) _GDIPlus_PathAddLine($hPath, $iX + $iSide, $iY + $iHeight, $iX + $iSide, $iY) _GDIPlus_PathAddArc($hPath, $iX, $iY - $iSide / 2, $iSide, $iSide, -180, 180) _GDIPlus_PathCloseFigure($hPath) ;* EndFunc ;==>ThumbBtn_Path Func _SubClass($hWnd, $pNew_WindowProc) Local $iRes = _WinAPI_SetWindowLong($hWnd, -4, $pNew_WindowProc) If @error Then Return SetError(1, 0, 0) If $iRes = 0 Then Return SetError(1, 0, 0) Return SetError(0, 0, $iRes) EndFunc ;==>_SubClass ;The new window procedure of the edit control. Func _New_WndProc($hWnd, $iMsg, $wParam, $lParam) Static $aRegion[3], $i_Thumb_Height = -1, $i_TrackHeight, $iY_Thumb = -1, $iPixel_Per_Line_Scale = 1, $iThumb_Pic = 0, $iTrack_Pic = 0 Static $hDC, $hGfx Switch $iMsg Case $WM_NCCALCSIZE $tNCCALCSIZE_PARAMS = DllStructCreate($tagNCCALCSIZE_PARAMS, $lParam) DllStructSetData($tNCCALCSIZE_PARAMS, 1, DllStructGetData($tNCCALCSIZE_PARAMS, 1) + 2) DllStructSetData($tNCCALCSIZE_PARAMS, 2, DllStructGetData($tNCCALCSIZE_PARAMS, 2) + 2) DllStructSetData($tNCCALCSIZE_PARAMS, 3, DllStructGetData($tNCCALCSIZE_PARAMS, 3) - 2 - $iWidth_VSCROLL) ;Space for VSCROLL Bar DllStructSetData($tNCCALCSIZE_PARAMS, 4, DllStructGetData($tNCCALCSIZE_PARAMS, 4) - 2) Return 0 Case $WM_NCPAINT ;the first draw. If $i_Thumb_Height = -1 Then _SendMessage($hWnd, $WM_UPDATETHUMB, 0, 0) Case $WM_PAINTSCROLLBAR $iRet = _WinAPI_CallWindowProc($___pOld_WndProc, $hWnd, $iMsg, _ $wParam, $lParam) $iWidth = _WinAPI_GetWindowWidth($hWnd) - _WinAPI_GetClientWidth($hWnd) - 4 $iHeight = _WinAPI_GetClientHeight($hWnd) ;Set the Range SetInRange($i_Thumb_Height, 15, $i_TrackHeight) SetInRange($iY_Thumb, 0, $i_TrackHeight - $i_Thumb_Height) $hHbmp = hHbmp_ScrollButtons_And_Track($iWidth, $iHeight, 0xFF000000 + GUICtrlGetBkColor($hWnd, _WinAPI_GetClientWidth($hWnd), $iHeight), $aRegion, _Iif($iY_Thumb < 0, 0, $iY_Thumb), $i_Thumb_Height) ; GUICtrlSendMsg($iTrack_Pic, 370, $IMAGE_BITMAP, $hHbmp) ;370 = $STM_SETBITMAP _WinAPI_DeleteObject($hHbmp) _WinAPI_EmptyWorkingSet() Return $iRet Case $WM_NCHITTEST $tPoint = DllStructCreate($tagPoint) DllStructSetData($tPoint, 1, _WinAPI_LoWord($lParam)) DllStructSetData($tPoint, 2, _WinAPI_HiWord($lParam)) _WinAPI_ScreenToClient($hWnd, $tPoint) $tRect = Return_CLientRect($hWnd) If _WinAPI_PtInRect($tRect, $tPoint) Then Return $HTBORDER Case $WM_NCLBUTTONDOWN $tPoint = _WinAPI_GetMousePos(True, $hWnd) If _GDIPlus_RegionIsVisiblePoint($aRegion[0], DllStructGetData($tPoint, 1) - _WinAPI_GetClientWidth($hWnd) - 2, DllStructGetData($tPoint, 2) - 2, $hGfx) Then _WinAPI_PostMessage($hWnd, $WM_ARROWDOWN, $SB_LINEUP, 0) ElseIf _GDIPlus_RegionIsVisiblePoint($aRegion[1], DllStructGetData($tPoint, 1) - _WinAPI_GetClientWidth($hWnd) - 2, DllStructGetData($tPoint, 2) - 2, $hGfx) Then _WinAPI_PostMessage($hWnd, $WM_ARROWDOWN, $SB_LINEDOWN, 1) ElseIf _GDIPlus_RegionIsVisiblePoint($aRegion[2], DllStructGetData($tPoint, 1) - _WinAPI_GetClientWidth($hWnd) - 2, DllStructGetData($tPoint, 2) - 2, $hGfx) Then _WinAPI_PostMessage($hWnd, $WM_THUMBMOVE, 0, 0) Else $tRect = Return_CLientRect($hWnd) If _WinAPI_PtInRect($tRect, $tPoint) Then $iY_Thumb = DllStructGetData($tPoint, 2) - (($i_Thumb_Height / 2) + ($iWidth_VSCROLL - 2)) $iLine_Scroll = Floor(($iY_Thumb / $iPixel_Per_Line_Scale)) $iLine_Scroll_Count = $iLine_Scroll - _GUICtrlEdit_GetFirstVisibleLine($hWnd) _SendMessage($hWnd, $EM_LINESCROLl, 0, $iLine_Scroll_Count) _SendMessage($hWnd, $WM_PAINTSCROLLBAR, 0, 0) EndIf EndIf Case $WM_CHAR, $WM_UNDO, $EM_UNDO, $WM_HOTKEY _WinAPI_PostMessage($hWnd, $WM_UPDATETHUMB, 0, 0) Case $WM_SIZE, $WM_SIZING $iRet = _WinAPI_CallWindowProc($___pOld_WndProc, $hWnd, $iMsg, _ $wParam, $lParam) $aPos = ControlGetPos("", "", $hWnd) If $iTrack_Pic Then GUICtrlSetPos($iTrack_Pic, $aPos[0] + 2 + _WinAPI_GetClientWidth($hWnd), $aPos[1] + 2, $iWidth_VSCROLL, _WinAPI_GetClientHeight($hWnd)) Else $iTrack_Pic = GUICtrlCreatePic("", $aPos[0] + 2 + _WinAPI_GetClientWidth($hWnd), $aPos[1] + 2, $iWidth_VSCROLL, _WinAPI_GetClientHeight($hWnd)) GUICtrlSetBkColor(-1, 0) EndIf _SendMessage($hWnd, $WM_UPDATETHUMB) If $hDC Then ;release the old ones _GDIPlus_GraphicsDispose($hGfx) _WinAPI_ReleaseDC($hDC, $hWnd) EndIf ;update the new graphics and DC $hDC = _WinAPI_GetWindowDC($hWnd) $hGfx = _GDIPlus_GraphicsCreateFromHDC($hDC) Return $iRet Case $WM_KEYDOWN Switch $wParam Case $VK_DOWN, $VK_UP, $VK_PRIOR, $VK_NEXT ;Down $iRet = _WinAPI_CallWindowProc($___pOld_WndProc, $hWnd, $iMsg, _ $wParam, $lParam) _SendMessage($hWnd, $WM_UPDATETHUMB) Return $iRet Case $VK_END, $VK_HOME If _IsPressed("11") Then ;CTRL Pressed _SendMessage($hWnd, $WM_VSCROLL, _WinAPI_MakeLong($SB_BOTTOM + $VK_END - $wParam, 0)) $iY_Thumb = _Iif($wParam = $VK_END, $i_TrackHeight - $i_Thumb_Height, 0) ;Redraw the window, _Winapi_RedrawWindow didn't work _SendMessage($hWnd, $WM_PAINTSCROLLBAR) EndIf EndSwitch Case $WM_MOUSEWHEEL $iDelta = _WinAPI_HiWord($wParam) $iCount = Abs($iDelta) / 120 For $i = 1 To $iCount _SendMessage($hWnd, $WM_ARROWDOWN, _Iif($iDelta > 0, $SB_LINEUP, $SB_LINEDOWN), -$iDelta) Next Case $WM_UPDATETHUMB ;Calculate the required vars $i_LineCount = _GUICtrlEdit_GetLineCount($hWnd) $i_ScrollBarHeight = _WinAPI_GetClientHeight($hWnd) $i_LineHeight = GetLineHeight($hWnd) $iMax_LineVisible = Floor($i_ScrollBarHeight / $i_LineHeight) $i_PageHeight = $i_LineCount * $i_LineHeight $i_TrackHeight = $i_ScrollBarHeight - (2 * ($iWidth_VSCROLL - 2)) $i_CurLine = _GUICtrlEdit_GetFirstVisibleLine($hWnd) ;Set the Thumb size $i_Thumb_Height = $i_TrackHeight * ($iMax_LineVisible * $i_LineHeight / $i_PageHeight) ;Set the Scale $iPixel_Per_Line_Scale = ($i_TrackHeight - $i_Thumb_Height) / ($i_LineCount - $iMax_LineVisible) ;Set the Thumb Pos $iY_Thumb = (($i_CurLine / ($i_LineCount - $iMax_LineVisible)) * ($i_TrackHeight - $i_Thumb_Height)) ;Redraw the window, _Winapi_RedrawWindow didn't work _SendMessage($hWnd, $WM_PAINTSCROLLBAR, 0, 0) Case $WM_THUMBMOVE $iLine_InPage = _WinAPI_GetClientHeight($hWnd) / GetLineHeight($hWnd) $Y_Offset = _WinAPI_GetMousePosY(True, $hWnd) - $iY_Thumb $iY_Thumb_Prev = $iY_Thumb Local $iOutofBounds = False While _IsPressed("01") $Mouse_Y = _WinAPI_GetMousePosY(True, $hWnd) #cs - need to be improved Select ;halt if out of bounds Case $Mouse_Y < $Y_Offset Or $Mouse_Y - $Y_Offset > $i_TrackHeight - $i_Thumb_Height Switch $iOutofBounds Case True Sleep(10) ContinueLoop Case False $iOutofBounds = True EndSwitch EndSelect #ce Switch $Mouse_Y - $Y_Offset ;pause if mouse isn't moved Case $iY_Thumb Sleep(10) ContinueLoop Case Else $iY_Thumb = $Mouse_Y - $Y_Offset $iOutofBounds = True $iLine_Scroll = Floor(($iY_Thumb / $iPixel_Per_Line_Scale)) $iLine_Scroll_Count = $iLine_Scroll - _GUICtrlEdit_GetFirstVisibleLine($hWnd) _SendMessage($hWnd, $EM_LINESCROLl, 0, $iLine_Scroll_Count) _SendMessage($hWnd, $WM_PAINTSCROLLBAR) Sleep(20) EndSwitch WEnd Case $WM_ARROWDOWN ;lParam = +ve : Down Arrow lParam = -ve : Up Arrow Local $iDirection = $wParam If $wParam = 0 Then $iDirection = _Iif($lParam > 0, $SB_LINEDOWN, $SB_LINEUP) _GUICtrlEdit_Scroll($hWnd, $iDirection) $iY_Thumb = _Iif($lParam > 0, $iY_Thumb + $iPixel_Per_Line_Scale, $iY_Thumb - $iPixel_Per_Line_Scale) _SendMessage($hWnd, $WM_PAINTSCROLLBAR, 0, 0) ;Continuous dragging Static $i_Start_Drag = False If _IsPressed("01") And $i_Start_Drag = False Then $iTimer = TimerInit() While _IsPressed("01") If TimerDiff($iTimer) >= $iDoubleClickTime Then $i_Start_Drag = True ExitLoop EndIf WEnd EndIf If _IsPressed("01") Then Sleep(15) _WinAPI_PostMessage($hWnd, $WM_ARROWDOWN, $wParam, $lParam) Else $i_Start_Drag = False EndIf EndSwitch ; Pass to the Original Window Procedure. Return _WinAPI_CallWindowProc($___pOld_WndProc, $hWnd, $iMsg, _ $wParam, $lParam) EndFunc ;==>_New_WndProc Func hHbmp_ScrollButtons_And_Track($iWidth, $iHeight, $iBkColor, ByRef $aRegion, $iThumb_Y, $iThumb_Height) If $iHeight < 2 * ($iWidth_VSCROLL - 2) Then Return 0 Local $hFont = _GDIPlus_FontCreate($hFamily, $iWidth_VSCROLL / 2 - 1, 2) ;Image Containing the Scroll Bar $hBmp = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight) $hGfx_Bmp = _GDIPlus_ImageGetGraphicsContext($hBmp) _GDIPlus_GraphicsSetSmoothingMode($hGfx_Bmp, 2) _GDIPlus_GraphicsClear($hGfx_Bmp, $iBkColor) ;Set Bkcolor of the Bmp to that of the Edit #cs - Doesn't work as expected ;Invalidate and erase the part of the edit containing ScrollBar. $tRect = Return_CLientRect($hWnd, $iX, $iY, $iX + $iWidth, $iY + $iHeight) _WinAPI_RedrawWindow($hWnd, $tRect, 0, BitOR($RDW_INVALIDATE, $RDW_ERASE)) #ce _Gdiplus_PathReset($hPath) ;Top Button TopBtn_Path($hPath, 0, 1, $iWidth_VSCROLL - 2) $aRegion[0] = _GDIPlus_RegionCreateFromPath($hPath) _Gdiplus_GraphicsFillPath($hGfx_Bmp, $hPath) ;The Curve part _Gdiplus_PathReset($hPath) ;Bottom Button TopBtn_Path($hPath, 0, $iHeight - $iWidth_VSCROLL + 1, $iWidth_VSCROLL - 2) _PathRotate($hPath, 180) $aRegion[1] = _GDIPlus_RegionCreateFromPath($hPath) _Gdiplus_GraphicsFillPath($hGfx_Bmp, $hPath) _Gdiplus_PathReset($hPath) ;Thumb ThumbBtn_Path($hPath, 0, $iWidth_VSCROLL - 2 + $iThumb_Y, $iThumb_Height, $iWidth_VSCROLL - 2) $aRegion[2] = _GDIPlus_RegionCreateFromPath($hPath) _Gdiplus_GraphicsFillPath($hGfx_Bmp, $hPath) ;Draw something more $iSide = $iWidth / 2 - 2 _GDIPlus_GraphicsDrawArc($hGfx_Bmp, $iWidth / 2 - $iSide, $iWidth_VSCROLL - 2 + $iThumb_Y + $iThumb_Height / 2 - $iSide, 2 * $iSide, 2 * $iSide, 51, 180, $hPen) $iSide = $iWidth / 3 - 2 _GDIPlus_GraphicsDrawArc($hGfx_Bmp, $iWidth / 2 - $iSide, $iWidth_VSCROLL - 2 + $iThumb_Y + $iThumb_Height / 2 - $iSide, 2 * $iSide, 2 * $iSide, 230, 110, $hPen) ;Arrows $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0) $aInfo = _GDIPlus_GraphicsMeasureString($hGfx_Bmp, ChrW(217), $hFont, $tLayout, $hFormat) _GDIPlus_GraphicsDrawStringEx($hGfx_Bmp, ChrW(217), $hFont, $aInfo[0], $hFormat, $hBrush) ;Up Arrow $tLayout = _GDIPlus_RectFCreate(0, $iHeight - ($iWidth_VSCROLL - 2) / 2, 0, 0) $aInfo = _GDIPlus_GraphicsMeasureString($hGfx_Bmp, ChrW(218), $hFont, $tLayout, $hFormat) _GDIPlus_GraphicsDrawStringEx($hGfx_Bmp, ChrW(218), $hFont, $aInfo[0], $hFormat, $hBrush) ;Down Arrow ;Draw the image on the GUI $hHbmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp) ;Mem Release _GDIPlus_FontDispose($hFont) _GDIPlus_GraphicsDispose($hGfx_Bmp) _GDIPlus_ImageDispose($hBmp) Return $hHbmp EndFunc ;==>hHbmp_ScrollButtons_And_Track #cs Func hHbmp_ScrollThumb($iWidth, $iHeight, $iBkColor, ByRef $aRegion, $iThumb_Y, $iThumb_Height) _Gdiplus_PathReset($hPath) ;Thumb ThumbBtn_Path($hPath, 0, $iWidth_VSCROLL - 2 + $iThumb_Y, $iThumb_Height, $iWidth_VSCROLL - 2) $aRegion[2] = _GDIPlus_RegionCreateFromPath($hPath) _Gdiplus_GraphicsFillPath($hGfx_Bmp, $hPath) ;Draw something more $iSide = $iWidth / 2 - 2 _GDIPlus_GraphicsDrawArc($hGfx_Bmp, $iWidth / 2 - $iSide, $iWidth_VSCROLL - 2 + $iThumb_Y + $iThumb_Height / 2 - $iSide, 2 * $iSide, 2 * $iSide, 51, 180, $hPen) $iSide = $iWidth / 3 - 2 _GDIPlus_GraphicsDrawArc($hGfx_Bmp, $iWidth / 2 - $iSide, $iWidth_VSCROLL - 2 + $iThumb_Y + $iThumb_Height / 2 - $iSide, 2 * $iSide, 2 * $iSide, 230, 110, $hPen) EndFunc ;==>hHbmp_ScrollThumb #ce Func SetInRange(ByRef $iVar, $iMin, $iMax) $iVar = _Iif($iVar < $iMin, $iMin, $iVar) $iVar = _Iif($iVar > $iMax, $iMax, $iVar) EndFunc ;==>SetInRange Func Return_CLientRect($hWnd, $iX = -1, $iY = -1, $iWidth = -1, $iHeight = -1) $tRect = DllStructCreate($tagRECT) If $iX = -1 And $iY = -1 And $iWidth = -1 And $iHeight = -1 Then DllStructSetData($tRect, 1, _WinAPI_GetClientWidth($hWnd) + 2) DllStructSetData($tRect, 2, 2) DllStructSetData($tRect, 3, _WinAPI_GetWindowWidth($hWnd) - 2) DllStructSetData($tRect, 4, _WinAPI_GetClientHeight($hWnd)) Else DllStructSetData($tRect, 1, $iX) DllStructSetData($tRect, 2, $iY) DllStructSetData($tRect, 3, $iX + $iWidth) DllStructSetData($tRect, 4, $iY + $iHeight) EndIf Return $tRect EndFunc ;==>Return_CLientRect Func GetCurLineIndex($hEdit) $aSel = _GUICtrlEdit_GetSel($hEdit) If $aSel[0] = $aSel[1] Then Return _GUICtrlEdit_LineFromChar($hEdit) Else _GUICtrlEdit_SetSel($hEdit, -1, -1) $iRet = _GUICtrlEdit_LineFromChar($hEdit) _GUICtrlEdit_SetSel($hEdit, $aSel[0], $aSel[1]) Return $iRet EndIf EndFunc ;==>GetCurLineIndex ;Thanks to Guinness - http://www.autoitscript.com/forum/topic/125684-guictrlgetbkcolor-get-the-background-color-of-a-control/ Func GUICtrlGetBkColor($hWnd, $iX = 0, $iY = 0) ;Modified - PXL If IsHWnd($hWnd) = 0 Then $hWnd = GUICtrlGetHandle($hWnd) Local $hDC = _WinAPI_GetDC($hWnd) Local $iColor = _WinAPI_GetPixel($hDC, $iX, $iY) _WinAPI_ReleaseDC($hWnd, $hDC) Return $iColor EndFunc ;==>GUICtrlGetBkColor ;Thanks to UEZ - http://www.autoitscript.com/forum/topic/150160-solved-gdi-path-transform-rotate/#entry1072071 Func _PathRotate($hPath, $iAngle) ;Modified - PXL $aBounds = _GdiPLus_PathGetWorldBounds($hPath) $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixTranslate($hMatrix, $aBounds[0] + $aBounds[2] / 2, $aBounds[1] + $aBounds[3] / 2) _GDIPlus_MatrixRotate($hMatrix, $iAngle) _GDIPlus_MatrixTranslate($hMatrix, -($aBounds[0] + $aBounds[2] / 2), -($aBounds[1] + $aBounds[3] / 2)) _GDIPlus_PathTransform($hPath, $hMatrix) _GDIPlus_MatrixDispose($hMatrix) EndFunc ;==>_PathRotate Func GetLineHeight($hEdit) ; Create DC $hDC = _WinAPI_GetDC($hEdit) $hFont = _SendMessage($hEdit, $WM_GETFONT) ; $WM_GetFont $hPrev_Font = _WinAPI_SelectObject($hDC, $hFont) Local $tSize = DllStructCreate("int;int") DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", "ยค", "int", 1, "ptr", DllStructGetPtr($tSize)) _WinAPI_SelectObject($hDC, $hPrev_Font) _WinAPI_ReleaseDC($hEdit, $hDC) Return DllStructGetData($tSize, 2) EndFunc ;==>GetLineHeight Func MapWindowPoints($hWndFrom, $hWndTo, $lpPoints, $cPoints) $aRet = DllCall("user32.dll", "int", "MapWindowPoints", "hwnd", $hWndFrom, "hwnd", $hWndTo, "ptr", $lpPoints, "int", $cPoints) If @error Or $aRet[0] = 0 Then Return SetError(@error, 0, -1) Return $aRet[0] EndFunc ;==>MapWindowPoints Test #include <CScrollBar.au3> ;What ever name you give to the UDF $hGui = GUICreate("Paths", 400, 400, -1, -1, $WS_SIZEBOX + $WS_MINIMIZEBOX) Local $String For $i = 1 To 50 ;No. of lines For $j = Random(33, 127, 1) To Random(33, 127, 1) ;No of chars in a line $String &= Chr($j) Next $String &= @CRLF Next GUICtrlCreateEdit($String, 5, 5, 200, 300, BitOR($ES_WANTRETURN, $ES_AUTOVSCROLL)) Startup_CustomScrollBar(GUICtrlGetHandle(-1)) GUISetState() Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Shutdown_CustomScrollBar() Exit EndSwitch Until 0 The CPU consumed upon moving the thumb is approx 12-18. So is it much enough to stop this project in Autoit. I just want some reviews and what users think about this script. The above is just implemented with Vertical Scrollbar. Thanks for you time
  9. Hello, I'm new to GUI autoit programming, and so far I have checked several threads with solutions that would fit my need, but none using a scrollbar like I wish... Please let me explain what I'm trying to do : I want a simple GUI, this GUI shall contain a zone with a vertical scrollbar. In this zone, I want to display several pictures all in 1 column. Since I won't have enough place to display them all, I'd like to have the scrollbar to help me... well... scroll the pictures as I want. I don't know yet how to create a specific zone, so I have created a scrollbar on the main GUI : GUICreate(..., $WS_VSCROLL)I have also managed to display several pictures in my GUI using GUICtrlCreatePic, including pictures located outside the GUI lower boundary. I thought it would "activate" the scrollbar, but no, it doesn't work.So I'm a bit stucked at this point. Is what I'm trying to do even possible ? Thank you so much for your help ! Cheers !
×
×
  • Create New...