Jump to content
Sign in to follow this  
isolation

Indipendent scrollbar

Recommended Posts

isolation

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?

Share this post


Link to post
Share on other sites
Valuater

Welcome to the Forums isolation.

That is not a great first post. We can help. but we don't like to guess and.. we don't read minds ( Well, I can't )

you need to post code for us to see the direction and make reasonable efforts to assist you

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
isolation

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

Share this post


Link to post
Share on other sites
isolation

Should I use WM_LBUTTONDOWN and WM_LBUTTONUP for registering mouse up and down?

Share this post


Link to post
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
Sign in to follow this  

×