Jump to content

Richedit tab size - (Moved)


Go to solution Solved by pixelsearch,

Recommended Posts

Posted

Hi Jos,

sorry may be i am too stupid.

but i just want to change the @TAB value from actually 6 (seems to be the default) to 4.

this cannot be so complicate.

also where did you move to the appropriate forum?

thanks for the link.

cheers mike

  • Developers
Posted

I understand what you want...   but since you haven't posted any script source to play with there isn't much I want to do as I am to lazy to type the basics myself. ;) 

The post was made in the AutoItx support in stead of this support forum, so I moved it.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

i do not understand what you mean.

the standard @TAB size in a richedit control is 6 spaces.
we want to change this value to 4 spaces. that's all.

this cannot be so complicate.

cheers mike

Posted
@mike1950r May I suggest you adapt the following code to your script, changing the value of 14 with another value that will suit your needs.

#include <SendMessage.au3>
...
$g_hRichEdit = _GUICtrlRichEdit_Create(...)
...
_SetTabStops($g_hRichEdit, 14) ; 14 corresponds approx. to 4 characters width (as my Scite) in this RichEdit control with this font
...
Func _SetTabStops($hWnd, $iTabStops)
    If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
    ; next line _SendMessage based on _GUICtrlEdit_SetTabStops / _GUICtrlRichEdit_SetTabStops, with "uint*" instead of "struct*" of course.
    _SendMessage($hWnd, $EM_SETTABSTOPS, 1, $iTabStops, 0, "wparam", "uint*")
EndFunc   ;==>_SetTabStops

Please indicate what value made it for you, as we don't have the same fonts installed on our computers.
Good luck :)

"I think you are searching a bug where there is no bug... don't listen to bad advice."

Posted (edited)

thanks pixelsearch,

this works nearly 100%.

In my window editor characters are handled like in notepad.

Each character needs the same space. My font:

Global Const $sGlo_WE_FontName = "Lucida Console"
Global Const $iGlo_WE_FontSize = 10
Global Const $iGlo_WE_FontWeight = $FW_NORMAL

WindowEditSetDefaultFont($hGlo_WE_Control, $iGlo_WE_FontSize, $sGlo_WE_FontName)

Honestly, I didn't think it was complicate like this.
thought it just could be like in notepad++, where you change the @TAB width in "options".

cheers mike

Edited by mike1950r
  • Solution
Posted
Yes it matches perfectly, even after 100 characters have been typed on the precedent line (25 tabs on the following line match exactly 100 characters on preceding line). I already tested that 16 would fit, just after you indicated "Lucida Console, fontsize 10, $FW_NORMAL"

As you're using a function WindowEditSetDefaultFont in this post which adds +3 to fontsize (10+3 = 13) then it's important for our readers to understand that "Lucida Console, fontsize 13, $FW_NORMAL" requires a Tab parameter of 16 for the _SetTabStops() function, so @TAB will correspond exactly to 4 characters width, in a RichEdit control using these font parameters.

It's longer to explain than just modifying the value :D

"I think you are searching a bug where there is no bug... don't listen to bad advice."

Posted (edited)

I have modified my function like this:

Func WindowEditSetDefaultFont($hWnd, $iPoints, $sName, $iTabWidth = 4)
    Local $hFont, $iTabStops

    $hFont = _WinAPI_CreateFont($iPoints + 3, 0, 0, 0, $FW_NORMAL, False, False, False, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, $sName)
    _SendMessage($hWnd, $WM_SETFONT, $hFont, True)
    _WinAPI_DeleteObject($hFont)

    $iTabStops = $iTabWidth * 4
    _SendMessage($hWnd, $EM_SETTABSTOPS, 1, $iTabStops, 0, "wparam", "uint*")
EndFunc   ;==>WindowEditSetDefaultFont

You can enter $iTabWidth value directly 4 or 6 etc. always 100% fitting.

thanks lot, pixelsearch,

cheers mike

Edited by mike1950r

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...