Jump to content

Left to Right Input with $WS_EX_LAYOUTRTL


Anas
 Share

Go to solution Solved by funkey,

Recommended Posts

Hello,

 

Is it possible to left-aligns the text in an input that is a part of a GUI created with $WS_EX_LAYOUTRTL?

#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

#region - GUI Create
GUICreate('', 250, 100 -1, -1, -1, -1, $WS_EX_LAYOUTRTL)
GUICtrlCreateInput('', 5, 5) ; Make it display Left to Right
GUISetState()
#endregion

#region - GUI SelectLoop
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
WEnd
#endregion
Link to comment
Share on other sites

  • Solution

#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <EditConstants.au3>
#include <WinAPI.au3>


#region - GUI Create
GUICreate('', 250, 100 -1, -1, -1, -1, $WS_EX_LAYOUTRTL)
GUICtrlCreateInput('', 5, 5) ; Make it display Left to Right

Global $hInput = GUICtrlGetHandle(-1)
Global $InputStyle = _WinAPI_GetWindowLong($hInput, $GWL_STYLE)
Global $InputExStyle = _WinAPI_GetWindowLong($hInput, $GWL_EXSTYLE)

_WinAPI_SetWindowLong($hInput, $GWL_STYLE, BitXOR($InputStyle, $ES_RIGHT))
_WinAPI_SetWindowLong($hInput, $GWL_EXSTYLE, BitXOR($InputExStyle, 0x7000))


GUISetState()
#endregion

#region - GUI SelectLoop
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
WEnd
#endregion

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

  • Moderators

@funkey, where did you get the magic number 0x7000?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • 2 months later...

@Anas : yes strange, the style does not applies direclty when creating the control, but need a GUICtrlSetStyle... I'm interested to understand why to.
 
Also, 2 other methods :

GUICreate('', 250, 100 -1, -1, -1, -1, $WS_EX_LAYOUTRTL)
GUICtrlCreateInput('test', 5, 5)
GUICtrlSetStyle(-1, $WS_VISIBLE + $WS_CHILD, $WS_EX_CLIENTEDGE)
#include <GUIConstants.au3>
#include <WinAPI.au3>


$hGui = GUICreate('', 250, 100)

GUICtrlCreateInput('test', 5, 5)

$iExStyle = _WinAPI_GetWindowLong($hGui, $GWL_EXSTYLE)
_WinAPI_SetWindowLong($hGui, $GWL_EXSTYLE, BitOR($iExStyle, $WS_EX_LAYOUTRTL)) ; sets the extended style after all controls are created

GUISetState()

While GUIGetMsg() <> $GUI_EVENT_CLOSE
    Sleep(10)
WEnd
Edited by jguinch
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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