* *

Coding

User

Welcome, Guest. Please login or register.
May 19, 2013, 10:02:38 PM

Login with username, password and session length

Menu

Stats

Members
  • Total Members: 490
  • Latest: Marc_it
Stats
  • Total Posts: 12058
  • Total Topics: 1688
  • Online Today: 96
  • Online Ever: 150
  • (September 26, 2012, 02:29:19 PM)
Users Online
Users: 3
Guests: 57
Spiders: 16
Total: 76
zappa52
billhsln
Larry McCaughn
Sogou
Google (14)
Baidu

Recent Topics

Author Topic: CHR$ (backspace)  (Read 1060 times)

0 Members and 1 Guest are viewing this topic.

Offline rosslcs

  • Newbie
  • *
  • Posts: 30
  • Bananas: 0
CHR$ (backspace)
« on: May 24, 2012, 08:50:23 AM »
I am trying to insert some text within a rich edit control and move the text cursor back one space using the CHR$(8) function as the following example shows ...

CONTROLCMD w1, 1, @RTSETSELCOLOR, SYblue
text = "123" + chr$(8)
handle = GlobalAlloc(@GHND,255)
lock = GlobalLock(handle)
RtlMoveMemory(lock,text,len(text)+1)
GlobalUnlock(handle)
OpenClipboard(w1)
EmptyClipboard()
SetClipboardData(@CFTEXT,handle)
CloseClipboard()
CONTROLCMD w1,1,@RTPASTE

However the CHR$(8) backspace function doesn't seem to work.

Is there an equivalent CHR$ (backspace) character using Creative Basic?

Online Larry McCaughn

  • Administrator
  • Full Member
  • *****
  • Posts: 191
  • Bananas: 4
  • Gender: Male
Re: CHR$ (backspace)
« Reply #1 on: May 24, 2012, 10:46:53 AM »
try this:
Code: [Select]
DEF c1,c2:int
 text = "123"
 ...
CONTROLCMD w1,1,@RTPASTE
CONTROLCMD w1, 1, @RTGETSELECTION, c1, c2
CONTROLCMD w1, 1, @RTSETSELECTION, c1-1, c2-1
« Last Edit: May 24, 2012, 10:48:47 AM by Larry McCaughn »
Admin - Here and @ Ionic Wind Software Forums
Author of Custom Button Designer, Custom Chart Designer, Snippet Manager, and IWB+ (A Visual Designer for IWBasic 2.x)

Offline rosslcs

  • Newbie
  • *
  • Posts: 30
  • Bananas: 0
Re: CHR$ (backspace)
« Reply #2 on: May 25, 2012, 08:35:08 AM »
Thanks for the code example for the backspace function - it worked fine.

Do you know of a similar function that would place the text cursor at the end of a line of text?


Online Larry McCaughn

  • Administrator
  • Full Member
  • *****
  • Posts: 191
  • Bananas: 4
  • Gender: Male
Re: CHR$ (backspace)
« Reply #3 on: May 25, 2012, 09:11:16 AM »
use
CONTROLCMD window | dialog,   ID, @RTGETSELECTION, varStart, varEnd
to get the location of the carat
use
line = CONTROLCMD ( window |   dialog, ID, @RTLINEFROMCHAR, varEnd)
with the carat location from above to find the line the carat is on
use
length = CONTROLCMD (   window | dialog, ID, @RTGETLINELENGTH,line)
to get the length of the line the carat is on
use
char_index = CONTROLCMD ( window | dialog,   ID, @RTCHARFROMLINE, linenum)
to find the location of the first character on the line
NOTE: I'm not sure if this one exists in CBasic. If not you'll have to use
CONST EM_LINEINDEX = 0xBB
char_index = SendMessage(window | dialog, EM_LINEINDEX, linenum, 0, ID)
use
x=char_index+length
CONTROLCMD window | dialog,   ID, @RTSETSELECTION, x, x

the help file is your friend ;)
 
Admin - Here and @ Ionic Wind Software Forums
Author of Custom Button Designer, Custom Chart Designer, Snippet Manager, and IWB+ (A Visual Designer for IWBasic 2.x)

 

To link to us use this code/button on your site

http://www.codingmonkeys.com/images/cm_link.gif