GtaSpider Posted January 1, 2009 Share Posted January 1, 2009 Hi and Happy New Year everyone Does anyone know a way, how to scroll Text with GDIPlus smoothie with DrawString (_GDIPlus_DrawStringEx)?I know, I can use the String... commands like StringTrimLeft and so one. But this dont looks smooth, if I use a nonmonospaced Font (like e.g. Arial)I want to say e.g. he should go every 100ms 2 Pixels left. Dont matter, if the Text is "WWWW" or "IIII" ;-)This should work on a graphic object.Would be great, if someone have got an Idea, and sorry again for my bad horrible english.Thanks Your Spider www.AutoIt.de - Moderator of the German AutoIt Forum Link to comment Share on other sites More sharing options...
monoceres Posted January 1, 2009 Share Posted January 1, 2009 Something like this maybe? expandcollapse popup#include <GDIPlus.au3> Opt("GUIOnEventMode", 1) $hwnd = GUICreate("GDI+ Example", 400, 300) $label = GUICtrlCreateLabel("", 10, 10, 380, 40) GUICtrlCreateButton("Start/Stop scrolling",150,50,100,30) GUICtrlSetOnEvent(-1,"startstop") GUISetOnEvent(-3, "close") GUISetBkColor(0xF0F0F0) GUISetState() _GDIPlus_Startup() $graphics = _GDIPlus_GraphicsCreateFromHWND(ControlGetHandle($hwnd, "", $label)) $bitmap = _GDIPlus_BitmapCreateFromGraphics(380, 40, $graphics) $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap) $ffamily = _GDIPlus_FontFamilyCreate("Arial") $arial = _GDIPlus_FontCreate($ffamily, 24) $sformat = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($sformat, 1) $blackbrush = _GDIPlus_BrushCreateSolid() $pos = 0 $speed=0 Do _GDIPlus_GraphicsClear($backbuffer, 0xFFF0F0F0) $pos -= $speed $rectf = _GDIPlus_RectFCreate($pos, 0, 380, 40) If $pos < -300 Then $pos = 300 _GDIPlus_GraphicsDrawStringEx($backbuffer, "Scrolling text", $arial, $rectf, $sformat, $blackbrush) _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, 380, 40) Sleep(10) Until False Func startstop() $speed=Not $speed EndFunc Func close() _GDIPlus_BrushDispose($blackbrush) _GDIPlus_StringFormatDispose($sformat) _GDIPlus_FontDispose($arial) _GDIPlus_FontFamilyDispose($ffamily) _GDIPlus_GraphicsDispose($backbuffer) _GDIPlus_BitmapDispose($bitmap) _GDIPlus_GraphicsDispose($graphics) _GDIPlus_Shutdown() Exit EndFunc ;==>close Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
GtaSpider Posted January 1, 2009 Author Share Posted January 1, 2009 Hello Hey, i like ya dude. Thank you Doesn't looks bad, but there is a problem: The width don't automatically fits to the Text length if I change the Text (the Text is sometimes 2 chars Len and sometimes 50 chars ;-) ) And i don't can use something like StringLen, because the string can be III or the string can be WWW, so the chars don't have the same width. Have you an Idea? It's for my G15 ;-) By the way: In some days I will release a complete new G15 LCD UDF. This UDF connect directly to the Logitech SDK and is so faster and better than the old one with the AvLCD.dll. Spider www.AutoIt.de - Moderator of the German AutoIt Forum Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 1, 2009 Moderators Share Posted January 1, 2009 Would probably be easier to use GUICtrlCreateObj + htm text/javascript for the scroll. No overhead and you don't have to be married to a loop. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
monoceres Posted January 2, 2009 Share Posted January 2, 2009 Hello Hey, i like ya dude. Thank you Doesn't looks bad, but there is a problem: The width don't automatically fits to the Text length if I change the Text (the Text is sometimes 2 chars Len and sometimes 50 chars ;-) ) And i don't can use something like StringLen, because the string can be III or the string can be WWW, so the chars don't have the same width. Have you an Idea? It's for my G15 ;-) By the way: In some days I will release a complete new G15 LCD UDF. This UDF connect directly to the Logitech SDK and is so faster and better than the old one with the AvLCD.dll. Spider Ah I see. Well then _GDIPlus_GraphicsMeasureString does the trick expandcollapse popup#include <GDIPlus.au3> Opt("GUIOnEventMode", 1) $hwnd = GUICreate("GDI+ Example", 400, 100) $label = GUICtrlCreateLabel("", 10, 10, 380, 40) GUICtrlCreateButton("Start/Stop scrolling", 150, 50, 100, 30) GUICtrlSetOnEvent(-1, "startstop") GUISetOnEvent(-3, "close") GUISetBkColor(0xF0F0F0) GUISetState() _GDIPlus_Startup() $graphics = _GDIPlus_GraphicsCreateFromHWND(ControlGetHandle($hwnd, "", $label)) $bitmap = _GDIPlus_BitmapCreateFromGraphics(380, 40, $graphics) $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap) $ffamily = _GDIPlus_FontFamilyCreate("Arial") $arial = _GDIPlus_FontCreate($ffamily, 24) $sformat = _GDIPlus_StringFormatCreate() ;~ _GDIPlus_StringFormatSetAlign($sformat, 1) $blackbrush = _GDIPlus_BrushCreateSolid() $pos = 0 $speed = 1 $text = "This is a string" Do _GDIPlus_GraphicsClear($backbuffer, 0xFFF0F0F0) $pos -= $speed $rectf = _GDIPlus_RectFCreate($pos, 0, 380, 40) $arr = _GDIPlus_GraphicsMeasureString($graphics, $text, $arial, $rectf, $sformat) $stringwidth = DllStructGetData($arr[0], "Width") If $pos < -$stringwidth Then $pos = $stringwidth*2 _GDIPlus_GraphicsDrawStringEx($backbuffer, $text, $arial, $rectf, $sformat, $blackbrush) _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, 380, 40) Sleep(10) Until False Func startstop() $speed = Not $speed EndFunc ;==>startstop Func close() _GDIPlus_BrushDispose($blackbrush) _GDIPlus_StringFormatDispose($sformat) _GDIPlus_FontDispose($arial) _GDIPlus_FontFamilyDispose($ffamily) _GDIPlus_GraphicsDispose($backbuffer) _GDIPlus_BitmapDispose($bitmap) _GDIPlus_GraphicsDispose($graphics) _GDIPlus_Shutdown() Exit EndFunc ;==>close Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
GtaSpider Posted January 2, 2009 Author Share Posted January 2, 2009 Hello Ah, thank you very much mate This is fantastic. Perfect Your Spider www.AutoIt.de - Moderator of the German AutoIt Forum Link to comment Share on other sites More sharing options...
a440hz Posted May 7, 2010 Share Posted May 7, 2010 Thank you very much for this useful script monoceres. I'm unable to get it to work with longer strings. Any suggestions? -Regards, Joe expandcollapse popup#include <GDIPlus.au3> Opt("GUIOnEventMode", 1) $hwnd = GUICreate("GDI+ Example", 400, 100) $label = GUICtrlCreateLabel("", 10, 10, 380, 40) GUICtrlCreateButton("Start/Stop scrolling", 150, 50, 100, 30) GUICtrlSetOnEvent(-1, "startstop") GUISetOnEvent(-3, "close") GUISetBkColor(0xF0F0F0) GUISetState() _GDIPlus_Startup() $graphics = _GDIPlus_GraphicsCreateFromHWND(ControlGetHandle($hwnd, "", $label)) $bitmap = _GDIPlus_BitmapCreateFromGraphics(380, 40, $graphics) $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap) $ffamily = _GDIPlus_FontFamilyCreate("Arial") $arial = _GDIPlus_FontCreate($ffamily, 24) $sformat = _GDIPlus_StringFormatCreate() ;~ _GDIPlus_StringFormatSetAlign($sformat, 1) $blackbrush = _GDIPlus_BrushCreateSolid() $pos = 0 $speed = 1 $text = "This is a string that is too long to scroll right." Do _GDIPlus_GraphicsClear($backbuffer, 0xFFF0F0F0) $pos -= $speed $rectf = _GDIPlus_RectFCreate($pos, 0, 380, 40) $arr = _GDIPlus_GraphicsMeasureString($graphics, $text, $arial, $rectf, $sformat) $stringwidth = DllStructGetData($arr[0], "Width") If $pos < -$stringwidth Then $pos = $stringwidth*2 _GDIPlus_GraphicsDrawStringEx($backbuffer, $text, $arial, $rectf, $sformat, $blackbrush) _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, 380, 40) Sleep(10) Until False Func startstop() $speed = Not $speed EndFunc ;==>startstop Func close() _GDIPlus_BrushDispose($blackbrush) _GDIPlus_StringFormatDispose($sformat) _GDIPlus_FontDispose($arial) _GDIPlus_FontFamilyDispose($ffamily) _GDIPlus_GraphicsDispose($backbuffer) _GDIPlus_BitmapDispose($bitmap) _GDIPlus_GraphicsDispose($graphics) _GDIPlus_Shutdown() Exit EndFunc ;==>close Are you experienced? Link to comment Share on other sites More sharing options...
a440hz Posted May 9, 2010 Share Posted May 9, 2010 I found Marquee.au3 to do the trick for me. Are you experienced? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 9, 2010 Moderators Share Posted May 9, 2010 (edited) Hi,If anyone is interested, Marquee.au3 can be found here. M23Edit: The board did not like the first link! Edited May 9, 2010 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
a440hz Posted June 10, 2010 Share Posted June 10, 2010 Hi, If anyone is interested, Marquee.au3 can be found here. M23 Edit: The board did not like the first link! Hi Melba23 and thank you! Pardon me for not providing a link myself. Got so darned tied up trying to hurdle my own programming deficiencies that I neglected not only to acknowledge you for your excellent script but to offer an easy way for others to benefit from it. All the best, Joe Are you experienced? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now