FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help request for custom text highlight at TextBox

 
Post new topic   Reply to topic     Forum Index -> DFL
View previous topic :: View next topic  
Author Message
badmadevil



Joined: 17 Feb 2008
Posts: 2

PostPosted: Sat May 10, 2008 1:42 am    Post subject: Help request for custom text highlight at TextBox Reply with quote

Hi,
I'm a newbie in programming, especially gui-coding.
I'm implementing a GUI based SNUSP interpreter using DFL, similar to this javascript web version:
http://www.quirkster.com/snusp/snusp-js.html

The problem is to, on a textbox, highlight the char the current source code pointers pointed at (eg. x-th char, y-th line, zero-base).

The methods I can think of (may be naive):
A) use drawText & drawTextDisabled ;
B) make the text background color transparent (or do nothing during textbox's onPaintBackground ?), then draw a filled box on window behind the textbox.

The text font will be fixed-size monospaced.

A sub-problem is to locate the target char position.

Some example code is much appreciated, thank you.
Back to top
View user's profile Send private message
Chris Miller



Joined: 27 Mar 2004
Posts: 514
Location: The Internet

PostPosted: Mon May 19, 2008 8:12 pm    Post subject: Re: Help request for custom text highlight at TextBox Reply with quote

If you use a RichTextBox you can change the background color of different ranges of text. The newer snapshots contain extra methods to work with the positions of the characters, for example getCharIndexFromPosition from the base class TextBoxBase.
Back to top
View user's profile Send private message
badmadevil



Joined: 17 Feb 2008
Posts: 2

PostPosted: Mon Jun 02, 2008 3:51 pm    Post subject: Re: Help request for custom text highlight at TextBox Reply with quote

Chris Miller wrote:
If you use a RichTextBox you can change the background color of different ranges of text. The newer snapshots contain extra methods to work with the positions of the characters, for example getCharIndexFromPosition from the base class TextBoxBase.


Thank for reply and sorry for my late response.
I've solved the problem by using Label as cursor. By measureText(), I can get the exact position of the Label cursors on their parent Textbox control (fixed-size font). In each time frame, each cursors' location, color, visibility and text is updated accordingly. It seems work fine.
Thanks again.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DFL All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group