AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Scroll test and picture

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
viciouskinid



Joined: 23 Jun 2007
Posts: 136

PostPosted: Sun Jul 13, 2008 3:39 pm    Post subject: Scroll test and picture Reply with quote

I would like to have text and images scrolling in my help tab. I have the basics of it working but when I scroll the images go over the tab bar.

Can anyone help?

Code:

#SingleInstance force
   Gui,  +LastFound
   hwnd := WinExist()
   
   TransColour=FFFFFE
   
   Gui,1: Color, %TransColour%, %TransColour%
   Gui,1: Add, Tab2,-Wrap x0 y0 w300 h20 vMainTabs gTabHandler AltSubmit, main||Settings|Help

Gui,1: Tab,Help
   
   Logo1y=25
   gui,1: add,Picture,x0 y%Logo1y% w40 h40  BackgroundTrans vLogo1,Logo4.png
   gui,1: add,Text,x100 y%Logo1y% w40 h40   vTxt1,ffffffffffffffffffffffffff
   Logo2y=75
   gui,1: add,Picture,x0 y%Logo2y% w40 h40  BackgroundTrans vLogo2,Logo4.png
   gui,1: add,Text,x100 y%Logo2y% w40 h40   vTxt2,ffffffffffffffffffffffffff
   Logo3y=125
   gui,1: add,Picture,x0 y%Logo3y% w40 h40  BackgroundTrans vLogo3,Logo4.png
   gui,1: add,Text,x100 y%Logo3y% w40 h40   vTxt3,ffffffffffffffffffffffffff
   
   ;gui,1: add,Text,x0 y0 w400 h40 vTransCover  -BackgroundTrans,
   
   
   hVBar := ScrollBar_Add(hwnd, 280, 10, -1,  290, "OnScroll", "style=ver", "pos=10")
   ScrollBar_Show(hVBar, false)
   Gui, show, h300 w300, ScrollBar Test
   ;WinSet, TransColor, %TransColour% 255 ,ScrollBar Test
return

TabHandler:
GuiControlGet,MainTabs
if MainTabs=3
ScrollBar_Show(hVBar, true)
else
ScrollBar_Show(hVBar, false)
Return


OnScroll:
; if (ScrollBar_HWND = hVBar)
       ; s := "vertical"
      
       Logo1y2:=Logo1y-ScrollBar_POS
       Logo2y2:=Logo2y-ScrollBar_POS
       Logo3y2:=Logo3y-ScrollBar_POS
      
GuiControl, Move, Logo1, y%Logo1y2%
GuiControl, Move, Logo2, y%Logo2y2%
GuiControl, Move, Logo3, y%Logo3y2%
GuiControl, Move, Txt1, y%Logo1y2%
GuiControl, Move, Txt2, y%Logo2y2%
GuiControl, Move, Txt3, y%Logo3y2%

;GuiControl, Move, TransCover, y0

return


;mapping wheel to scroll bar example
   #IfWinActive, SBar Test
   WheelDown::
      ScrollBar_Set(hVBar, ScrollBar_Get(hVBar)+ScrollBar_Get(hVBar, "page"))
      DllCall("InvalidateRect", "uint", hVBar, "uint", 0, "uint", 0)   ;!!!
   return

   WheelUp::
      ScrollBar_Set(hVBar, ScrollBar_Get(hVBar)-ScrollBar_Get(hVBar, "page"))
      DllCall("InvalidateRect", "uint", hVBar, "uint", 0, "uint", 0)   ;!!!
   return


#include ScrollBar.ahk



This code requires ScrollBar.ahk

http://www.autohotkey.com/forum/ptopic18913.html&sid=a7516b6108a3a7ac555ecde18928dbf5
Back to top
View user's profile Send private message
ahklerner



Joined: 26 Jun 2006
Posts: 1249
Location: USA

PostPosted: Sun Jul 13, 2008 3:43 pm    Post subject: Reply with quote

here is another scroll post that is very good [see lexikos post]
http://www.autohotkey.com/forum/viewtopic.php?p=177673#177673
_________________

ʞɔпɟ əɥʇ ʇɐɥʍ
Back to top
View user's profile Send private message
viciouskinid



Joined: 23 Jun 2007
Posts: 136

PostPosted: Mon Jul 14, 2008 10:22 am    Post subject: Reply with quote

Still having trouble.
is there a way to fix the tab bar?
Code:

#NoEnv



OnMessage(0x115, "OnScroll") ; WM_VSCROLL
OnMessage(0x114, "OnScroll") ; WM_HSCROLL


   Gui,1: Add, Tab2,-Wrap x0 y0 w300 h20 vMainTabs  AltSubmit, main||Settings|Help

Gui,1: Tab,Help
Gui, +Resize +0x300000 ; WS_VSCROLL | WS_HSCROLL

Loop 8
    Gui, Add, Edit, R5 W400, Edit %A_Index%
Gui, Add, Button,, Do absolutely nothing
Gui, Show, W200 H200

Gui, +LastFound
GroupAdd, MyGui, % "ahk_id " . WinExist()

return

GuiSize:
    UpdateScrollBars(A_Gui, A_GuiWidth, A_GuiHeight)
   
return

GuiClose:
ExitApp

#IfWinActive ahk_group MyGui
WheelUp::
WheelDown::
+WheelUp::
+WheelDown::
    ; SB_LINEDOWN=1, SB_LINEUP=0, WM_HSCROLL=0x114, WM_VSCROLL=0x115
    OnScroll(InStr(A_ThisHotkey,"Down") ? 1 : 0, 0, GetKeyState("Shift") ? 0x114 : 0x115, WinExist())
return
#IfWinActive

UpdateScrollBars(GuiNum, GuiWidth, GuiHeight)
{


    static SIF_RANGE=0x1, SIF_PAGE=0x2, SIF_DISABLENOSCROLL=0x8, SB_HORZ=0, SB_VERT=1
   
    Gui, %GuiNum%:Default
    Gui, +LastFound
   
    ; Calculate scrolling area.
    Left := Top := 9999
    Right := Bottom := 0
    WinGet, ControlList, ControlList
    Loop, Parse, ControlList, `n
    {
        GuiControlGet, c, Pos, %A_LoopField%
        if (cX < Left)
            Left := cX
        if (cY < Top)
            Top := cY
        if (cX + cW > Right)
            Right := cX + cW
        if (cY + cH > Bottom)
            Bottom := cY + cH
    }
    Left -= 8
    Top -= 8
    Right += 8
    Bottom += 8
    ScrollWidth := Right-Left
    ScrollHeight := Bottom-Top
   
    ; Initialize SCROLLINFO.
    VarSetCapacity(si, 28, 0)
    NumPut(28, si) ; cbSize
    NumPut(SIF_RANGE | SIF_PAGE, si, 4) ; fMask
   
    ; Update horizontal scroll bar.
    NumPut(ScrollWidth, si, 12) ; nMax
    NumPut(GuiWidth, si, 16) ; nPage
    DllCall("SetScrollInfo", "uint", WinExist(), "uint", SB_HORZ, "uint", &si, "int", 1)
   
    ; Update vertical scroll bar.
;     NumPut(SIF_RANGE | SIF_PAGE | SIF_DISABLENOSCROLL, si, 4) ; fMask
    NumPut(ScrollHeight, si, 12) ; nMax
    NumPut(GuiHeight, si, 16) ; nPage
    DllCall("SetScrollInfo", "uint", WinExist(), "uint", SB_VERT, "uint", &si, "int", 1)
   
    if (Left < 0 && Right < GuiWidth)
        x := Abs(Left) > GuiWidth-Right ? GuiWidth-Right : Abs(Left)
    if (Top < 0 && Bottom < GuiHeight)
        y := Abs(Top) > GuiHeight-Bottom ? GuiHeight-Bottom : Abs(Top)
    if (x || y)
        DllCall("ScrollWindow", "uint", WinExist(), "int", x, "int", y, "uint", 0, "uint", 0)
}

OnScroll(wParam, lParam, msg, hwnd)
{
    static SIF_ALL=0x17, SCROLL_STEP=10
   
    bar := msg=0x115 ; SB_HORZ=0, SB_VERT=1
   
    VarSetCapacity(si, 28, 0)
    NumPut(28, si) ; cbSize
    NumPut(SIF_ALL, si, 4) ; fMask
    if !DllCall("GetScrollInfo", "uint", hwnd, "int", bar, "uint", &si)
        return
   
    VarSetCapacity(rect, 16)
    DllCall("GetClientRect", "uint", hwnd, "uint", &rect)
   
    new_pos := NumGet(si, 20) ; nPos

    action := wParam & 0xFFFF
    if action = 0 ; SB_LINEUP
        new_pos -= SCROLL_STEP
    else if action = 1 ; SB_LINEDOWN
        new_pos += SCROLL_STEP
    else if action = 2 ; SB_PAGEUP
        new_pos -= NumGet(rect, 12, "int") - SCROLL_STEP
    else if action = 3 ; SB_PAGEDOWN
        new_pos += NumGet(rect, 12, "int") - SCROLL_STEP
    else if action = 5 ; SB_THUMBTRACK
        new_pos := NumGet(si, 24, "int") ; nTrackPos
    else if action = 6 ; SB_TOP
        new_pos := NumGet(si, 8, "int") ; nMin
    else if action = 7 ; SB_BOTTOM
        new_pos := NumGet(si, 12, "int") ; nMax
    else
        return
   
    min := NumGet(si, 8, "int") ; nMin
    max := NumGet(si, 12, "int") - NumGet(si, 16) ; nMax-nPage
    new_pos := new_pos > max ? max : new_pos
    new_pos := new_pos < min ? min : new_pos
   
    old_pos := NumGet(si, 20, "int") ; nPos
   
    x := 0
   y := 0
    if bar = 0 ; SB_HORZ
        x := old_pos-new_pos
    else
        y := old_pos-new_pos
    ; Scroll contents of window and invalidate uncovered area.

    DllCall("ScrollWindow", "uint", hwnd, "int", x, "int", y, "uint", 0, "uint", 0)
   
    ; Update scroll bar.
    NumPut(new_pos, si, 20, "int") ; nPos
    DllCall("SetScrollInfo", "uint", hwnd, "int", bar, "uint", &si, "int", 1)
}
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group