Jump to content

active slider border


mac1
 Share

Recommended Posts

Thanks, I looked at that, but wanted to stay away from it because of all the extra stuff I would have to do with show and hide because of the labels between the different windows/guis. But I guess I'll look at it again.

Link to comment
Share on other sites

The subclassing that Siao explained very well in post #14 is put together in the following example (tested with current autoit beta v 3.2.11.10)

#include <GuiConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <GuiSlider.au3>

$Gui = GUICreate("Subclassed Slider without Focus Border", 300, 200)
$Vertical_Label = GUICtrlCreateLabel("Vertical Slider Read: 0", 20, 20, 200)
$Horizontal_Label = GUICtrlCreateLabel("Horizontal Slider Read: 0", 80, 120, 200)
$Vertical_Slider = GUICtrlCreateSlider(20, 50, 30, 120, BitOr($GUI_SS_DEFAULT_SLIDER, $TBS_VERT))
$Horizontal_Slider = GUICtrlCreateSlider(60, 150, 160, 30)

; Register callback function and obtain a handle to the new slider WindowProc
$hNewSliderProc = DllCallbackRegister("_NoFocusBorderWindowProc", "int", "hwnd;uint;wparam;lparam")
; Get a pointer to the new WindowProc
$pNewSliderProc = DllCallbackGetPtr($hNewSliderProc)

; Subclass horizontal slider and retrieve a pointer to the original slider WindowProc
$pOriginalSliderProc = _WinSubclass(GUICtrlGetHandle($Horizontal_Slider), $pNewSliderProc)


; Subclass vertical slider
_WinSubclass(GUICtrlGetHandle($Vertical_Slider), $pNewSliderProc)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GuiDelete($Gui)
            ; Free 
            DllCallBackFree($hNewSliderProc)
            Exit
    EndSwitch
WEnd


Func _NoFocusBorderWindowProc($hWnd, $uiMsg, $wParam, $lParam)
    ;handle setfocus
    If $uiMsg = $WM_SETFOCUS Then Return 0
    
    ;other messages are handled with the original slider proc
    Return _WinAPI_CallWindowProc($pOriginalSliderProc, $hWnd, $uiMsg, $wParam, $lParam)
EndFunc

Func _WinSubclass($hWnd, $pNewWindowProc)
    Local $a_res
   ;$GWL_WNDPROC = -4
    $a_res = DllCall("user32.dll", "ptr", "SetWindowLong", "hwnd", $hWnd, "int", -4, "ptr", $pNewWindowProc)

    If @error Then Return SetError(1, 0, 0)
    If $a_res[0] = 0 Then Return SetError(1, 0, 0)
    Return $a_res[0]
EndFunc
Edited by aec
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...