Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Thu Nov 21, 2019 1:32 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: blink\flash a text in a console application
PostPosted: Mon Dec 26, 2011 12:14 pm 
Offline

Joined: Thu Nov 08, 2007 4:59 am
Posts: 392
Location: Germany
Hi,

is there a way to blink (flash) a text in a console application?

I've tried to use API call SetConsoleTextAttribute with the constant COMMON_LVB_REVERSE_VIDEO ... but no success

I use XP and Win7

Heinz


Top
 Profile  
Reply with quote  
 Post subject: Re: blink\flash a text in a console application
PostPosted: Mon Jan 30, 2012 7:23 pm 
Offline

Joined: Mon Oct 03, 2005 4:30 pm
Posts: 54
Location: Auckland NZ
You could try something like this (Place in app.run event). Only works on the last displayed line though.

[code]
[code]Dim b As Boolean
Dim s As String = "Hello World"

While True
stdout.Write chr(13) ' Moves the cursor back to the beginning of the line
If b Then
stdout.Write " " ' Needs to be at least as long as s
Else
stdout.Write s
End If
b = not b ' toggles b
DoEvents(500) ' Sleeps the app for 500ms
Wend[/code]
[/code]


Last edited by Wayneg@axisdirect.co.nz on Sat Apr 14, 2012 1:14 am, edited 3 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: blink\flash a text in a console application
PostPosted: Mon Jan 30, 2012 11:59 pm 
Offline
User avatar

Joined: Mon Apr 02, 2007 2:08 am
Posts: 1225
Location: San Francisco, CA, USA
One way to do this is to use a timer that alternates between writing your message and then clearing it.

I will assume that since you say you've tried SetConsoleTextAttribute that you know how to get a handle to the console's output buffer. So something like this:

Declare Function SetConsoleCursorPosition Lib "Kernel32" (cHandle As Integer, info As COORD) As Boolean
Dim info As New MemoryBlock(4)
info.UInt16(0) = 0 //The X coordinate of the cursor
info.UInt16(2) = 0 //The Y coordinate of the cursor
Call SetConsoleCursorPosition(StdOutHandle, coords) Then //StdOutHandle is the output buffer's handle


Using the timer, first write your message to the console. Then, on the second time your timer fires, move the cursor's X coordinate to 0 (the beginning of the line) and print a space for each character in your message, overwriting it with blanks, and then move the cursor back to the beginning of the line. On the third time around print the message again. Repeat, alternately clearing and writing your message.

_________________
Boredom Software


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group