April 25, 2024, 03:59:49 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


EDIT control problem [ SOLVED!!! ]

Started by Egil, May 10, 2009, 11:53:24 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Egil

May 10, 2009, 11:53:24 AM Last Edit: May 11, 2009, 04:14:30 AM by Egil
I'm trying to make a simple terminal program to control my TNC (radio modem/controller), planning to use the upper part of program window to show both received and transmitted text, and the lower part showing the text input for transmitting. As shown in the following code.
' Simple terminal program - LA2PJ
AutoDefine "Off"
DEF txd$:string
DEF win:WINDOW
txd$=""
def i, run:INT
DEF left, top, width, height : INT
DEF RXwin_left, RXwin_top, RXwin_width,RXwin_height: INT
DEF TXwin_left, TXwin_top, TXwin_width,TXwin_height: INT

Openwindow win,0,0,480,300,@MINBOX|@MAXBOX|@SIZE,0,"Test",&main
getclientsize win,left,top,width,height
RXwin_left = 5
RXwin_top = 5
RXwin_width = width - 10
RXwin_height = height - 90
TXwin_left = 5
TXwin_top = RXwin_height + 10
TXwin_width = width - 10
TXwin_height = 75

'---  RX window
CONTROL win,@EDIT,"",RXwin_left,RXwin_top,RXwin_width,RXwin_height,@CTEDITMULTI|@VSCROLL,1
'CONTROL win,@LISTBOX, "",RXwin_left,RXwin_top,RXwin_width,RXwin_height,@CTSCROLLVERT|@VSCROLL|@CTEDITAUTOV,1
SETFONT win, "Tahoma",10,400,0,1

'---  TX window
CONTROL win,@EDIT,"",TXwin_left,TXwin_top,TXwin_width,TXwin_height,@CTEDITMULTI|@CTEDITRETURN|@VSCROLL,2
SETFONT win, "Tahoma",10,400,0,2
SETCONTROLNOTIFY(win,2,1,1)
SETFOCUS win,2
SETCONTROLTEXT win,2,""

run=1
waituntil run=0
closewindow win
end

'--------------------------------------------------------------
SUB main
SELECT @MESSAGE

CASE @IDCLOSEWINDOW
run=0

    CASE @IDCONTROL
      IF @CONTROLID = 2
  SELECT @NOTIFYCODE
  CASE @ENENTERKEY
txd$ = GETCONTROLTEXT (win, 2)
SETCONTROLTEXT win, 1, txd$
SETFOCUS win,2
' ADDSTRING win, 1, txd$
SETCONTROLTEXT win,2,""
ENDSELECT
ENDIF

CASE @IDSIZE
IF CONTROLEXISTS(win,1)
getclientsize win,left,top,width,height
RXwin_left = 5
RXwin_top = 5
RXwin_width = width - 10
RXwin_height = height - 90
TXwin_left = 5
TXwin_top = RXwin_height + 10
TXwin_width = width - 10
TXwin_height = 75
setsize win,RXwin_left,RXwin_top,RXwin_width,RXwin_height,1
setsize win,TXwin_left,TXwin_top,TXwin_width,TXwin_height,2
ENDIF

  ENDSELECT
RETURN
ENDSUB

I want the text in the upper part to remain on screen with automatic vertical scrolling, and fold back text when linelength exceeds the window width.
But when RXwin is defined as an EDIT control, the text dissapears when a new sentence is enterred in TXwin.
If I change the RXwin to a LISTBOX I get what I want, but the window doesn't scroll automaticly.

As I have seen other windows programs doing something similar to I want try do, I am sure there is a simple soution to my problem. But right now I am not able to figure it out myself.

Can anyone lead me back on the right track please? ;D
Support Amateur Radio  -  Have a ham  for dinner!

LarryMc

A richedit control allows you to add text as you describe by positioning the the placement.
It will also handle wordwrap and scrolling.

Read carefully about the rich edit control in the help file.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Egil

Thanks Larry!
I'll try that tomorrow. Getting late here, and have to get up early to cath a ferry.

By the way, when I was trying out different methods, I found that using a LISTBOX control for the upper window and using INSERTSTRING  instead of ADDSTRING to pass the new string, I was able to change the direction of the list is shown.
By using the example from the User manual , INSERTSTRING win, 1, 0, txd$ the newest line always is placed on top of the list, but if I use INSERTSTRING win, 1, -1, txd$ instead, the new input appears on a new line under the list. Couldn't find this anywhere in the manual, but it may come in handy one day...
Support Amateur Radio  -  Have a ham  for dinner!

Egil

May 11, 2009, 04:13:23 AM #3 Last Edit: May 11, 2009, 04:14:55 AM by Egil
As usual, all the questions I stumble into have been asked and answered before.
I found the solution to my problem here:  http://www.ionicwind.com/forums/index.php/topic,3174.0.html
;D ;D ;D
Support Amateur Radio  -  Have a ham  for dinner!