Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Setting Tab stops in edit controls


  • Please log in to reply
3 replies to this topic
Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
The message EM_SETTABSTOPS (0xCB) changes the standard tab stops setting. It accepts an array or a single integer, if the same value has to repeat. Edit controls work not only with fixed length fonts, so the distance cannot be given by the number of characters but "dialog template units". In my Windows version (large system fonts), in edit controls with Courier New font, 4 units correspond to one character, therefore 12 as the last parameter of the DllCall sets tab stops at every 3 characters. The Shift-Control-TAB hotkey activates this in the foreground window. If there are more than one edit controls in the active window, change EDIT1 to EDIT2, EDIT3…
VarSetCapacity(TAB,4,0)

DllCall("RtlFillMemory",UInt,&TAB, UInt,1, UChar,12)   ; n pos tabs ~ 4*n



+^TAB::SendMessage 0xCB, 1, &TAB, EDIT1, A


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
You may already know this, but there's a built-in method to specify your tab stops when creating or updating an Edit control or ListBox:

Tn: The letter T may be used to set tab stops inside a multi-line edit control (since tab stops determine the column positions to which literal TAB characters will jump, they can be used to format the text into columns). If the letter T is not used, tab stops are set at every 32 dialog units (the width of each "dialog unit" is determined by the operating system). If the letter T is used only once, tab stops are set at every n units across the entire width of the control. For example, Gui, Add, Edit, vMyEdit r16 t64 would double the default distance between tab stops. To have custom tab stops, specify the letter T multiple times as in the following example: Gui, Add, Edit, vMyEdit r16 t8 t16 t32 t64 t128. One tab stop is set for each of the absolute column positions in the list, up to a maximum of 50 tab stops.



Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
You are right, for AHK created edit controls the Tn option is simpler. Otherwise, like in Notepad, a method like the SendMessage above seems to be necessary.

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Ah ha, great idea. :)