Sign in to follow this  
Followers 0
Datus

[solved]smooth scroll over image

12 posts in this topic

#1 ·  Posted (edited)

spent a while looking through forums but not luck.

in my mind im sure i have found this before but was over a year ago doh.

anyway what i am trying to do is scroll a label (text) over a backdrop without flicker.

here is the code

#include "GUIConstantsEx.au3"
#include "StaticConstants.au3"

$main=GUICreate("A window", 400, 150)
$picl = GUICtrlCreatePic(@WorkingDir & "\backdrop.jpg", 0, 0, 400, 150)
GUICtrlSetState(-1, $GUI_DISABLE)
$labell = GUICtrlCreateLabel("this is label over image" &@CRLF& " and even more text", 00, 10, 400, 65, $SS_CENTER)
GUICtrlSetFont(-1, 14)
GUICtrlSetColor(-1, 0x000000)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Close = GUICtrlCreateButton("Close", 350, 35, 60, 40)
GUISetState(@SW_SHOW, $main)


GUISetState()

For $i = 150 To 0 Step -1
  ; Nedd to look for this within loop
        $msg = GUIGetMsg()
        If $msg = $Close Then
            GUIDelete($main)
            Exit
        EndIf
            GUICtrlSetPos($labell, 1, $i)
        Sleep(45); Needed despite GUIGetMsg to slow the scroll!
    Next
Edited by Datus

We live as we dream alone!

Share this post


Link to post
Share on other sites



not sure what you mean.

doesnt make a different how many charactors i use?

i think i need api calls or something


We live as we dream alone!

Share this post


Link to post
Share on other sites

Also flickers.

#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <FontConstants.au3>
#include <WindowsConstants.au3>

$Form = GUICreate('A window', 420, 150)
$Pic = GUICtrlCreatePic('Wind.jpg', 0, 0, 420, 150)
GUICtrlSetState(-1, $GUI_DISABLE)
$Close = GUICtrlCreateButton('Close', 350, 35, 60, 40)
GUISetState()

$hPic = GUICtrlGetHandle($Pic)
$hDC = _WinAPI_GetDC($hPic)
$hFont = _WinAPI_CreateFont(26, 0, 0, 0, 400, 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Tahoma')
$hOldFont = _WinAPI_SelectObject($hDC, $hFont)
_WinAPI_SetTextColor($hDC, 0x00FFFF)
_WinAPI_SetBkMode($hDC, $TRANSPARENT)

$tRECT = DllStructCreate($tagRect)
DllStructSetData($tRECT, 'Left', 0)
DllStructSetData($tRECT, 'Right', 348)
DllStructSetData($tRECT, 'Top', 150)
DllStructSetData($tRECT, 'Bottom', 150)

$sText = 'This is label over image' & @CRLF & ' and even more text'

For $i = 150 To 0 Step -1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $Close, $GUI_EVENT_CLOSE
            _WinAPI_InvalidateRect($hPic, $tRECT1)
            _WinAPI_SelectObject($hDC, $hOldFont)
            _WinAPI_DeleteObject($hFont)
            _WinAPI_ReleaseDC(0, $hDC)
            Exit
    EndSwitch
    _WinAPI_InvalidateRect($hPic, $tRECT)
    DllStructSetData($tRECT, 'Top', $i)
    DllStructSetData($tRECT, 'Bottom', 150)
    _WinAPI_DrawText($hDC, $sText, $tRECT, $DT_CENTER)
    Sleep(40)
Next

Share this post


Link to post
Share on other sites

interesting.

i have searched my drive for that example but no luck atm.

had 1 pc and 2 laptops since then ;0


We live as we dream alone!

Share this post


Link to post
Share on other sites

interesting.

i have searched my drive for that example but no luck atm.

had 1 pc and 2 laptops since then ;0

Maybe you could get rid of the flashing by merging transitions. Here is an idea of what I mean, but perhaps if the idea was applied somehow to Yashied's example it would remove the small amount of flicker that's still there.

This is only to show the idea, it's not very useful. The caption bar flickers so you have to ignore that for this demo :) and it's very very slow.

#include "GUIConstantsEx.au3"
#include "StaticConstants.au3"
#include <WindowsConstants.au3>
#include <ScreenCapture.au3>

Global Const $WS_EX_COMPOSITED = 0x2000000;to stop flashing graphics.

Local Const $STM_SETIMAGE = 0x0172
Local Const $IMAGE_BITMAP = 0
_ScreenCapture_Capture("test001.jpg",0,0,400,400)

$main = GUICreate("A window", 400, 150, 200, 200)
$picl = GUICtrlCreatePic(@WorkingDir & "\test001.jpg", 0, 0, 400, 150)
GUICtrlSetState(-1, $GUI_DISABLE)
$labell = GUICtrlCreateLabel("this is label over image" & @CRLF & " and even more text", 00, 100, 400, 65, $SS_CENTER)
GUICtrlSetFont(-1, 14)
GUICtrlSetColor(-1, 0x000000)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Close1 = GUICtrlCreateButton("Close", 350, 35, 60, 40)
GUISetState(@SW_SHOW, $main)




$main2 = GUICreate("A window", 400, 150, 200, 200)

$pic2 = GUICtrlCreatePic(@WorkingDir & "\test001.jpg", 0, 0, 400, 150)
GUICtrlSetState(-1, $GUI_DISABLE)
$label2 = GUICtrlCreateLabel("this is label over image" & @CRLF & " and even more text", 00, 100, 400, 65, $SS_CENTER)
GUICtrlSetFont(-1, 14)
GUICtrlSetColor(-1, 0x000000)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Close2 = GUICtrlCreateButton("Close", 350, 35, 60, 40)
GUISetState(@SW_HIDE, $main2)


WinSetTrans($main2, "", 0)
GUISetState(@SW_SHOW, $main2)

$main3 = GUICreate("A window", 400, 150, 200, 200)
$pic3 = GUICtrlCreatePic(@WorkingDir & "\test001.jpg", 0, 0, 400, 150)
GUICtrlSetState(-1, $GUI_DISABLE)
$Close3 = GUICtrlCreateButton("Close", 350, 35, 60, 40)
GUISetState(@SW_SHOW, $main3)


For $j = 2 To 100 Step 2
    WinSetOnTop($main2, "", 1)
   ;sleep(10)
    For $i = 10 To 250 Step 2
        WinSetTrans($main2, "", $i + 4)
        winsettrans($main,"",255-$i/2)
    Next
    ControlMove($main, "", $labell, 0, 100 - $j)
    WinSetTrans($main, "", 0)
    WinSetOnTop($main, "", 1)
   ;sleep(10)
    For $i = 10 To 250 Step 2
        WinSetTrans($main, "", $i + 4)
        winsettrans($main2,"",255-$i/2)
    Next
    ControlMove($main2, "", $label2, 0, 100 - $j - 1)
    WinSetTrans($main2, "", 0)
Next

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

martin, good idea. The follows example is not blinking for me.

#Include <GUIConstantsEx.au3>
#Include <StaticConstants.au3>
#Include <WindowsConstants.au3>

$Width = 420
$Height = 150
$sText = 'AutoIt v3 is a freeware BASIC-like scripting language designed for automating the ' & _
         'Windows GUI and general scripting. It uses a combination of simulated keystrokes, mouse ' & _
         'movement and window/control manipulation in order to automate tasks in a way not possible or ' & _
         'reliable with other languages (e.g. VBScript and SendKeys). AutoIt is also very small, ' & _
         'self-contained and will run on all versions of Windows out-of-the-box with no annoying "runtimes" ' & _
         'required!'

; Main Window
$Form1 = GUICreate('Test', $Width, $Height, 620, 500)
$Pic1 = GUICtrlCreatePic(@WindowsDir & '\Web\Wallpaper\Wind.jpg', 0, 0, 348, 150)
$Label1 = GUICtrlCreateLabel($sText, 0, 150, 348, 150, $SS_CENTER)
GUICtrlSetFont(-1, 10)
GUICtrlSetColor(-1, 0xFFFF00)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Close = GUICtrlCreateButton('Close', 354, 105, 60, 40)

GUIRegisterMsg($WM_MOVE, 'WM_MOVE')

$Pos = WinGetPos($Form1)
$Border = ($Pos[2] - $Width) / 2
$X = $Pos[0] + $Border
$Y = $Pos[1] + $Pos[3] - $Height - $Border

; Popup Window
$Form2 = GUICreate('', 348, 150, $X, $Y, BitOR($WS_DISABLED, $WS_POPUP), -1, $Form1)
GUICtrlCreatePic(@WindowsDir & '\Web\Wallpaper\Wind.jpg', 0, 0, 348, 150)
$Label2 = GUICtrlCreateLabel($sText, 0, 150, 348, 150, $SS_CENTER)
GUICtrlSetFont(-1, 10)
GUICtrlSetColor(-1, 0xFFFF00)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

GUISetState(@SW_SHOW, $Form2)
GUISetState(@SW_SHOW, $Form1)

For $i = 150 To -150 Step -1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $Close, $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    GUICtrlSetPos($Label1, 0, $i)
    WinSetTrans($Form2, '', 0)
    GUICtrlSetPos($Label2, 0, $i)
    WinSetTrans($Form2, '', 255)
    Sleep(20)
Next

Func WM_MOVE($hWnd, $iMsg, $wParam, $lParam)
    WinMove($Form2, '', BitAND($lParam, 0xFFFF), BitShift($lParam, 16))
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_MOVE
Edited by Yashied

Share this post


Link to post
Share on other sites

martin, good idea. The follows example is not blinking for me.

#Include <GUIConstantsEx.au3>
#Include <StaticConstants.au3>
#Include <WindowsConstants.au3>

$Width = 420
$Height = 150
$sText = 'AutoIt v3 is a freeware BASIC-like scripting language designed for automating the ' & _
         'Windows GUI and general scripting. It uses a combination of simulated keystrokes, mouse ' & _
         'movement and window/control manipulation in order to automate tasks in a way not possible or ' & _
         'reliable with other languages (e.g. VBScript and SendKeys). AutoIt is also very small, ' & _
         'self-contained and will run on all versions of Windows out-of-the-box with no annoying "runtimes" ' & _
         'required!'

; Main Window
$Form1 = GUICreate('Test', $Width, $Height, 620, 500)
$Pic1 = GUICtrlCreatePic(@WindowsDir & '\Web\Wallpaper\Wind.jpg', 0, 0, 348, 150)
$Label1 = GUICtrlCreateLabel($sText, 0, 150, 348, 150, $SS_CENTER)
GUICtrlSetFont(-1, 10)
GUICtrlSetColor(-1, 0xFFFF00)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Close = GUICtrlCreateButton('Close', 354, 105, 60, 40)

GUIRegisterMsg($WM_MOVE, 'WM_MOVE')

$Pos = WinGetPos($Form1)
$Border = ($Pos[2] - $Width) / 2
$X = $Pos[0] + $Border
$Y = $Pos[1] + $Pos[3] - $Height - $Border

; Popup Window
$Form2 = GUICreate('', 348, 150, $X, $Y, BitOR($WS_DISABLED, $WS_POPUP), -1, $Form1)
GUICtrlCreatePic(@WindowsDir & '\Web\Wallpaper\Wind.jpg', 0, 0, 348, 150)
$Label2 = GUICtrlCreateLabel($sText, 0, 150, 348, 150, $SS_CENTER)
GUICtrlSetFont(-1, 10)
GUICtrlSetColor(-1, 0xFFFF00)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

GUISetState(@SW_SHOW, $Form2)
GUISetState(@SW_SHOW, $Form1)

For $i = 150 To -150 Step -1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $Close, $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    GUICtrlSetPos($Label1, 0, $i)
    WinSetTrans($Form2, '', 0)
    GUICtrlSetPos($Label2, 0, $i)
    WinSetTrans($Form2, '', 255)
    Sleep(20)
Next

Func WM_MOVE($hWnd, $iMsg, $wParam, $lParam)
    WinMove($Form2, '', BitAND($lParam, 0xFFFF), BitShift($lParam, 16))
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_MOVE
That's good Yashied, and you've made it much more simple :).

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Well done thanks very much.

When i get a chance i will study the code to see how you cracked it but will use it in my program.

Cheers!


We live as we dream alone!

Share this post


Link to post
Share on other sites

Look at my posts about anti-flicker techniques, for example:

http://www.autoitscript.com/forum/index.ph...ost&p=98708

http://www.autoitscript.com/forum/index.ph...mp;hl=blackjack

Basic princip:

Do all painting to hidden memory bitmap first and finally use BitBlt to copy whole image to visible GUI. 

Also catch WM_PAINT message to do that drawing from there.

Share this post


Link to post
Share on other sites

Look at my posts about anti-flicker techniques, for example:

http://www.autoitscript.com/forum/index.ph...ost&p=98708

http://www.autoitscript.com/forum/index.ph...mp;hl=blackjack

Basic princip:

Do all painting to hidden memory bitmap first and finally use BitBlt to copy whole image to visible GUI.

Also catch WM_PAINT message to do that drawing from there.

That would mean that the text would have to be drawn on the image rather than being a separate control which is moving wouldn't it?


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

That would mean that the text would have to be drawn on the image rather than being a separate control which is moving wouldn't it?

Yes.

Or another possibility is to use prospeed DLL/UDF.

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  
Followers 0