IonicWind Software

IWBasic => General Questions => Topic started by: Brian on October 17, 2017, 07:50:48 AM

Title: Tabbing
Post by: Brian on October 17, 2017, 07:50:48 AM
Hi,

I have a window, with EnableTabs set, that has four edit boxes and five buttons. All of the controls have @TABSTOP set

One of the edit boxes has @CTEDITMULTI set, as well. If you Tab between controls, it stops at the edit box that has the @CTEDITMULTI set. Won't go any further. If you take out the @CTEDITMULTI it will tab correctly

Any ideas?

Brian
Title: Re: Tabbing
Post by: Andy on October 17, 2017, 08:37:19 AM
Brian,

Have you thought of using an int variable as a counter, increment the int variable.

Pseudo code:

MyTabCount = 0

if tab key pressed
  MyTabCount ++

  if MyTabCount > 2 (2 = number of things to tab)
    MyTabCount = 1
  endif

  if MyTabCount = 1 then setfocus win,control1
  if MyTabCount = 2 then setfocus win,control2
endif

That's how I've done it before.



Title: Re: Tabbing
Post by: Brian on October 17, 2017, 08:54:23 AM
Andy,

It's an idea, thank you. I'll explore NOT using @CTEDITMULTI first, I think!

Brian
Title: Re: Tabbing
Post by: fasecero on October 17, 2017, 04:36:19 PM
Brian,

To move to the next control you have to sub-class the edit and modify the default TAB behavior.



$INCLUDE "windowssdk.inc"
$include "commctrl.inc"

' var
INT SUBCLASS_ID = 12345

' interface
CONST EDIT_1 = 1
CONST BUTTON_2 = 2
CONST EDIT_3 = 3
CONST BUTTON_4 = 4
WINDOW w1
OPENWINDOW w1,0,0,254,270,@CAPTION,0,"Caption",&mainhandler
ENABLETABS(w1, 1)
CENTERWINDOW w1

' message loop
WAITUNTIL ISWINDOWCLOSED(w1)

' procedure
SUB mainhandler(), INT
SELECT @MESSAGE
CASE @IDCREATE
OnInit()
CASE @IDCLOSEWINDOW
OnClose()
CLOSEWINDOW w1
ENDSELECT
RETURN 0
ENDSUB

SUB OnInit()
CONTROL w1,@EDIT,"Edit1",90,17,70,20,@TABSTOP,EDIT_1
CONTROL w1,@BUTTON,"Button1",90,58,70,20,@TABSTOP,BUTTON_2
CONTROL w1,@EDIT,"Edit2",89,93,70,84,@TABSTOP | @CTEDITMULTI | @CTEDITRETURN ,EDIT_3
CONTROL w1,@BUTTON,"Button2",89,199,70,20,@TABSTOP,BUTTON_4

SetWindowSubclass(GETCONTROLHANDLE(w1, EDIT_3), &MySubclassProc, SUBCLASS_ID, 0)
ENDSUB

SUB OnClose()
RemoveWindowSubclass(GETCONTROLHANDLE(w1, EDIT_3), &MySubclassProc, SUBCLASS_ID)
ENDSUB

' subclass proc
SUB MySubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
LRESULT response

SELECT (uMsg)
CASE WM_GETDLGCODE
IF wParam = VK_TAB THEN
response = DefSubclassProc(hWnd, uMsg, wParam, lParam)
response = response & NOT(DLGC_WANTALLKEYS)
RETURN response
ENDIF
ENDSELECT

RETURN DefSubclassProc(hWnd, uMsg, wParam, lParam)
ENDSUB

Title: Re: Tabbing
Post by: Brian on October 18, 2017, 02:18:20 AM
Thank you - I will try it. Didn't realise you had to do that. Believe it or not, it is the first time I have used a multiline edit box!

Brian
Title: Re: Tabbing
Post by: Andy on October 18, 2017, 02:37:02 AM
Brian,

Would you not be better using a richedit control rather than an edit control?

The richedit allows for lots of lines where the edit control is limited to the height you set it to.

Title: Re: Tabbing
Post by: Brian on October 18, 2017, 04:58:24 AM
Andy,
Not true! You can have over 30,000 characters in an edit box, plus vertical and horizontal scrollbars. Anyway, I only need 255
Brian
Title: Re: Tabbing
Post by: Andy on October 18, 2017, 06:38:06 AM
True,

I was just observing the example here, I could only do a few lines before it would not do carriage return anymore.

Title: Re: Tabbing
Post by: Egil on October 18, 2017, 11:43:17 AM
QuoteYou can have over 30,000 characters in an edit box

Thats true, as long as you define the string used to contain the contents of the EditBox as an ISTRING. Otherwise the limit is 255 characters (which probably is the case in the example Andy is referring to).
Title: Re: Tabbing
Post by: fasecero on October 18, 2017, 05:48:43 PM
Add @VSCROLL to remove the height limitation. According to MSDN, the amount of text a user can enter is 32K (32000 characters).
Title: Re: Tabbing
Post by: Andy on October 19, 2017, 06:11:07 AM
Yes I always forget about the @VSCROLL option  :-[, and I believe the limit 32K is 32,767 characters.

I've used it several edit controls:

CONTROLCMD(dy3,EDIT_2,@EDSETLIMITTEXT,32767)

:)

Title: Re: Tabbing
Post by: fasecero on October 19, 2017, 04:07:04 PM
Makes sense. That value exactly matches the maximum signed 16 bit int. Probably they're keeping the maximun edit size inside a WORD/SWORD variable.