Jump to content

Indipendent scrollbar


isolation
 Share

Recommended Posts

Hi there

I've a BIG problem:I have to create an indipendent scrollbar(it musn't be attached with a control or with the gui)

I created 3 pic controls and I used GuiRegisterMsg

http://img440.imageshack.us/img440/5817/scrolleb0.th.png

the 2 buttons(up and down) works... they move the scroll...

The problem is ... how can I move the scroll with the mouse and get/set its position?

Link to comment
Share on other sites

Sorry

This is my code:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
HotKeySet("{Esc}", "Esc")
Opt("GUICoordMode",1)
Opt("GUIOnEventMode",1)
Global $scroll[2]
Global $edown,$eup,$ecl=0
global $enum=7
Global $E_gui=GUICreate("Scrollabr",400,300,200,300)
createdw()
createup()
createscr()
GUISetState()
GUIRegisterMsg($WM_COMMAND ,"MY_WM_COMMAND")
while 1
    
WEnd

Func esc()
    Exit
EndFunc
Func createup()
    $up=guictrlcreatepic("scrollu.bmp",200,25,16,16)
    Assign("eup",$up)
EndFunc
Func createdw()
    $dw=guictrlcreatepic("scrolld.bmp",200,270,16,16)
    Assign("edown",$dw)
EndFunc
Func deletescr()
    GUICtrlDelete($scroll[0])
    $scroll[0]=0
    $scroll[0]=0
EndFunc
Func createscr()
    $dw=guictrlcreatepic("scroll.bmp",200,41,16,(229*2)/$enum)
    Dim $h[2]
    $h[0]=$dw
    $h[1]=0
    Assign("scroll",$h)
EndFunc

Func updater($msg="")
    Select
    case $msg="d"
        if $enum <=1 then return 0
        if $ecl=$enum-2 then return 0
        $ecl=$ecl+1
        $cicon=10
        $r=229-(229*2/$enum)
        $e=($r/($enum-2))
        GUICtrlSetPos($scroll[0],200,($e*$ecl)+41,16,(229*2)/$enum)
        $scroll[1]=$e
    case $msg="u"
        if $ecl=0 then return 0
        $ecl=$ecl-1
        $r=229-(229*2/$enum)
        $e=($r/($enum-2))
        GUICtrlSetPos($scroll[0],200,($e*$ecl)+41,16,(229*2)/$enum)
        $scroll[1]=$e
        $cicon=10
    EndSelect   
EndFunc

Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    $nNotifyCode    = BitShift($wParam, 16)
    $nID            = BitAnd($wParam, 0x0000FFFF)
    $hCtrl          = $lParam
    If $nID <> 2 And $nNotifyCode = 0 Then 
        If $nID = 1 Then
            $hFocus = DllCall("user32.dll", "hwnd", "GetFocus")
            $nCtrlID = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $hFocus[0])
            PostButtonclick($hFocus[0], $nCtrlID[0])
        Else
            if $nID=$edown then updater("d")

            if  $nID=$eup then updater("u")
        EndIf
        Return 0 
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc
Func PostButtonclick($hWnd, $nCtrlID)
    DllCall("user32.dll", "int", "PostMessage", _
                                    "hwnd", $E_gui, _
                                    "int", $WM_COMMAND, _
                                    "int", BitAnd($nCtrlID, 0x0000FFFF), _
                                    "hwnd", GUICtrlGetHandle($nCtrlid))
EndFunc

I use pics for the scollbar up and down

but I want to move the scrollbar, too

Please, help me

scroll.rar

Edited by isolation
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...