Что нового

Бегущая строка в Lable не бежит

HolyWay

Новичок
Сообщения
24
Репутация
3
Потратил 5 часов на написание малюсенького скрипта для "бегущей строки" в Lable,
но так и не получил результата.
Кошмар :shok:

Покажите пожалуйста пример этой злосчастной "бегущей строки".

P.S. Пример с форума:
Код:
Func TitleChanger()
    $title = WinGetTitle($Form2)
    $newtitle = StringMid($title, 2) & StringLeft($title, 1)
    WinSetTitle($title, "", $newtitle)
EndFunc


мне не помог к сожалению.



Добавлено:
Сообщение автоматически объединено:

так:
Код:
Func TitleChanger()
	ControlGetText($Form,'',$Label)
          $newbstrc = StringMid($bstrc, 2) & StringLeft($bstrc,1)
	    GUICtrlSetData($Label, $newbstrc)
EndFunc


не работает :(
 

madmasles

Модератор
Глобальный модератор
Сообщения
7,790
Репутация
2,322
HolyWay,
Попробуйте примерно так.
Код:
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPI.au3>

Global $sStr = 'пример этой злосчастной "бегущей строки"', $aStr = StringSplit($sStr, ''), $aInf[3]

$hGui = GUICreate('Test', 350, 150)
$nLabel = GUICtrlCreateLabel('', 0, 0, 0, 0)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetFont(-1, 11)
$hLab = GUICtrlGetHandle($nLabel)
$hDC = _WinAPI_GetDC($hLab)
$tS = _WinAPI_GetTextExtentPoint32($hDC, $sStr)
$iW = DllStructGetData($tS, 'X')
$iH = DllStructGetData($tS, 'Y')
_WinAPI_ReleaseDC($hLab, $hDC)
$hDC = 0
$tS = 0
$sStr = ''
GUICtrlSetPos($nLabel, (350 - $iW) / 2, 40, $iW, $iH)
$nBtn = GUICtrlCreateButton('Click', 125, 100, 100, 30)
GUISetState()

While 1
	Switch GUIGetMsg()
		Case $GUI_EVENT_CLOSE
			Exit
		Case $nBtn
			$aInf[2] = Not $aInf[2]
			If $aInf[2] Then
				AdlibRegister('_Test', 100)
			Else
				AdlibUnRegister('_Test')
				$aInf[0] = 0
				$aInf[1] = 0
				_WinAPI_SetWindowText($hLab, '')
			EndIf
	EndSwitch
WEnd

Func _Test()
	Local $s_Text, $i_St, $i_End

	If $aInf[0] = $aStr[0] Then
		$aInf[1] = Not $aInf[1]
		$aInf[0] = 0
	EndIf
	$aInf[0] += 1
	If $aInf[1] Then
		$i_St = $aInf[0]
		$i_End = $aStr[0]
		GUICtrlSetStyle($nLabel, BitOR($GUI_SS_DEFAULT_LABEL, $SS_LEFT))
	Else
		$i_St = 1
		$i_End = $aInf[0]
		GUICtrlSetStyle($nLabel, BitOR($GUI_SS_DEFAULT_LABEL, $SS_RIGHT))
	EndIf
	For $i = $i_St To $i_End
		$s_Text &= $aStr[$i]
	Next
	_WinAPI_SetWindowText($hLab, $s_Text)
	;GUICtrlSetData($nLabel, $s_Text)
EndFunc   ;==>_Test
 

WSWR

AutoIT Гуру
Сообщения
941
Репутация
363
HolyWay
Код:
#include <GUIConstantsEx.au3>

$text='dhhjdfkllkygftjklougggvstujkgteqsgjo;ljguuddrhopljfsrhgvderthjkkkiuufcnhdsxqwgbmjjgcbh'

$Form = GUICreate('', 300, 300, -1, -1)
$Label=GUICtrlCreateLabel($text, 0, 100, 300, 60)
GUICtrlSetBkColor(-1, 0x00FFFF)	
GUICtrlSetFont (-1, 18,400,Default,'Arial')
GUICtrlSetColor(-1,0xFF0000)
GUISetState(@SW_SHOW, $Form)

Do
Sleep(50)
TitleChanger()
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func TitleChanger()
    $bstrc=GUICtrlRead ($Label)
    $newbstrc = StringMid($bstrc, 2) & StringLeft($bstrc,1)
    GUICtrlSetData($Label, $newbstrc)
EndFunc


Но лучше использовать GDIP+
http://autoit-script.ru/index.php/topic,11999.0/topicseen.html
 
Автор
H

HolyWay

Новичок
Сообщения
24
Репутация
3
WSWR
madmasles
Спасибо большое!

:laugh:
 
Автор
H

HolyWay

Новичок
Сообщения
24
Репутация
3
Может быть будет кому то полезным :

Код:
#include <GUIConstants.au3>
#include <GDIplus.au3>
#include <file.au3>
#include <Array.au3>
HotKeySet("{ESC}", "xx")

;FileInstall("OmH.txt", "*")
; FileInstall("black.jpg", "*")

;Global $aRecords
Global $graphics, $bitmap, $backbuffer, $hGUI, $hBrush1, $hBrush2,$hBrush3,$hBrush4,$hBrush5
Global $Width = 1100, $Height = 55
Global $hFormat, $hFamily, $hFont, $text_color, $tLayout
Global $hShadowBrush, $hShadowFormat, $hShadowFamily, $hShadowFont
Global $letter_distance, $Length, $scroller_length,$ioffset,$monic1nik1
Global $font_size = 20,$text

;_FileReadToArray('OmH.txt', $aRecords) 
;_ArrayDelete($aRecords, 0)
;$text = _ArrayToString($aRecords, ' ')

Opt('GUIOnEventMode', 1)
$hwnd = GUICreate('GDI+', $Width, $Height)
;$monic1nik1 = GuiCtrlCreatePic("black.jpg", 0, 0, 1100, 55)
GUISetBkColor(0x000000)

GUISetOnEvent($GUI_EVENT_CLOSE, 'close')
GUISetState()

 $text = 'Очень качественный пример "бегущей строки" в окне GUI !    :)'

_GDIPlus_Startup()
$text_color =0x1ce4f8
$fon_color1=0x131313
$fon_color2=0x090909
$fon_color3=0x000000
$fon_color4=0x090909
$fon_color5=0x131313
$fon_color1='0xFF'&Hex($fon_color1,6)
$fon_color2='0xFF'&Hex($fon_color2,6)
$fon_color3='0xFF'&Hex($fon_color3,6)
$fon_color4='0xFF'&Hex($fon_color4,6)
$fon_color5='0xFF'&Hex($fon_color5,6)
$text_color = '0xFF'&Hex($text_color,6)
$htextBrush = _GDIPlus_BrushCreateSolid($text_color)
$hFormat = _GDIPlus_StringFormatCreate()
$hFamily = _GDIPlus_FontFamilyCreate('Arial')
$hFont = _GDIPlus_FontCreate($hFamily, $font_size, 2)
$tLayout = _GDIPlus_RectFCreate(0, 0)
$hShadowFormat = _GDIPlus_StringFormatCreate()
$hShadowFamily = _GDIPlus_FontFamilyCreate('Arial')

$hShadowFont = _GDIPlus_FontCreate($hShadowFamily, $font_size, 2)
_GDIPlus_GraphicsSetSmoothingMode($backbuffer, 2)
$graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
$bitmap = _GDIPlus_BitmapCreateFromGraphics($Width, $Height, $graphics)
$backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
$hBrush1 = _GDIPlus_BrushCreateSolid($fon_color1)
$hBrush2 = _GDIPlus_BrushCreateSolid($fon_color2)
$hBrush3 = _GDIPlus_BrushCreateSolid($fon_color3)
$hBrush4 = _GDIPlus_BrushCreateSolid($fon_color4)
$hBrush5 = _GDIPlus_BrushCreateSolid($fon_color5)

$letter_distance = $font_size
 $Length = $font_size * 1.666 * 0.36
$cc = $Width
$scroller_length = StringLen($text) * $Length
$FontY = $Height - $font_size * 2.2
 AdlibRegister('ScrollText',50)
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func ScrollText()
    For $ioffset = -200 to 0 step 5
           _GDIPlus_GraphicsFillRect($backbuffer, 0, 8, 1100, 7, $hBrush1)
           _GDIPlus_GraphicsFillRect($backbuffer, 0, 15, 1100, 7, $hBrush2)
          _GDIPlus_GraphicsFillRect($backbuffer, 0, 22, 1100, 9, $hBrush3)
          _GDIPlus_GraphicsFillRect($backbuffer, 0, 31, 1100, 7, $hBrush4)
          _GDIPlus_GraphicsFillRect($backbuffer, 0, 38, 1100, 7, $hBrush5)
         $FontX = $cc + $letter_distance
        DllStructSetData($tLayout, 'x', $FontX)
        DllStructSetData($tLayout, 'y', $FontY)
        _GDIPlus_GraphicsDrawStringEx($backbuffer, $text, $hFont, $tLayout, $hFormat, $htextBrush)
        $cc -= 1
        If - $scroller_length >= $cc + $Width Then $cc = $Width
        Sleep(33)
        _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $Width, $Height)
		_GDIPlus_GraphicsSetSmoothingMode($backbuffer, 2)
    Next
EndFunc
AdlibUnRegister('ScrollText')

Func close()
    _GDIPlus_BrushDispose($htextBrush)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hShadowBrush)
    _GDIPlus_FontDispose($hShadowFont)
    _GDIPlus_FontFamilyDispose($hShadowFamily)
    _GDIPlus_StringFormatDispose($hShadowFormat)
    _GDIPlus_BrushDispose($hBrush1)
	_GDIPlus_BrushDispose($hBrush2)
	_GDIPlus_BrushDispose($hBrush3)
	_GDIPlus_BrushDispose($hBrush4)
	_GDIPlus_BrushDispose($hBrush5)
    _GDIPlus_GraphicsDispose($graphics)
    _GDIPlus_Shutdown()
    Exit
EndFunc

Func xx()
    Sleep (300)
    Exit
EndFunc


;)
 
Верх