Jump to content

Problem after using '$WS_EX_LAYOUTRTL' at 'GUICreate' Function


IgImAx
 Share

Recommended Posts

Hi all

I'm creating simple customized dialog box for my script and It should have Right-to-Left layout so I use $WS_EX_LAYOUTRTL parameter at my GUICreate function. please look at my code(I made it simple by omit all unnecessary lines!):

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

MsgOkey()

Func MsgOkey()

Local $win_Okey, $msg
Local $img_hGraphic

$win_Okey = GUICreate("Test", 386, 131, -1, -1, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX),$WS_EX_LAYOUTRTL)
GUISetBkColor(0xFFFFFF)

GUISetState()

_GDIPlus_Startup()
$img_hGraphic = _GDIPlus_GraphicsCreateFromHWND($win_Okey)
_GDIPlus_GraphicsFillRect($img_hGraphic, 0, 85, 386, 70,_GDIPlus_BrushCreateSolid(0xF0F0F0F0))

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
_GDIPlus_Shutdown()
GUIDelete()
ExitLoop
EndSelect
WEnd
EndFunc

After I run it my dialog box will look like this:

Posted Image

Picture 1

As you can see at above picture, Why is that "White" part creating!! while it should be fill with Gray Rectangle? (which I specify it by Red-Arrows)

If I just remove '$WS_EX_LAYOUTRTL' parameter at the end of GUICreate function, like this:

$win_Okey = GUICreate("Test", 386, 131, -1, -1, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX))

It will be show that gray rectangle correctly:

Posted Image

Picture 2

Why _GDIPlus_GraphicsFillRect function do not work correctly when I use '$WS_EX_LAYOUTRTL' parameter ?

Even I make $iWidth parameter of _GDIPlus_GraphicsFillRect function larger than GUI width (more than 386) and it did not work!

PS.: (I know about great UDF by others but I just want to create my own simple dialog box, so please do not refer my to others codes, just please solve my problem! Thanks)

Best regards

Teach Others to learn more yourself

My eBooks and Articles in Persian: IgImAx Home! * and more here

Link to comment
Share on other sites

It seems to be a problem with using GDI+ and the RTL settings. Nothing to do with AutoIt I'm afraid to say.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

No, you need to wait for Microsoft to fix it, it's a GDI+ issue, and not an AutoIt issue, as I already told you.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Another idea I had would be to not use the $WS_EX_LAYOUTRTL for the whole GUI but only the controls that actually need it.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

@Emiel Wieldraaijer

Thanks for your Link, Well! I do not know what make that problem exactly!?

@BrewManNH

No, you need to wait for Microsoft to fix it, it's a GDI+ issue, and not an AutoIt issue, as I already told you.

I do not know about that!? cause I have VB.2008 and made a RTL form inside it then test this code on it:

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
     Dim myBrush As New System.Drawing.SolidBrush(System.Drawing.Color.White)
     Dim formGraphics As System.Drawing.Graphics

     formGraphics = Me.CreateGraphics()
     formGraphics.FillRectangle(myBrush, New Rectangle(0, 100, 300, 199))

     myBrush.Dispose()
     formGraphics.Dispose()
End Sub

End Class

The result was this without any problem:

Posted Image

Picture 1

Another idea I had would be to not use the $WS_EX_LAYOUTRTL for the whole GUI but only the controls that actually need it.

I can set all buttons and labels and ... to proper positions based on my RTL language. But there will be at least two problem!:

1) How to place Menus at right side and all theirs sub-menus open base on RTL!? The only way I know (base on my searches!) is that use '$WS_EX_LAYOUTRTL' at GUI level!

2) How to position Close button on left side of GUI and Title bar text place at right side!?

Teach Others to learn more yourself

My eBooks and Articles in Persian: IgImAx Home! * and more here

Link to comment
Share on other sites

Have you tried it without using GDI+ at all, unless it's absolutely necessary for the rest of your script that is? You could do the same thing with a label control with a background color which looks pretty much identical.

#include <GUIConstantsEx.au3>
;~ #include <GDIPlus.au3>
#include <WindowsConstants.au3>

MsgOkey()

Func MsgOkey()
    Local $win_Okey, $msg
    Local $img_hGraphic
    $win_Okey = GUICreate("Test", 386, 131, -1, -1, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX), $WS_EX_LAYOUTRTL)
    GUISetBkColor(0xFFFFFF)
    GUISetState()
;~  _GDIPlus_Startup()
;~  $img_hGraphic = _GDIPlus_GraphicsCreateFromHWND($win_Okey)
;~  _GDIPlus_GraphicsFillRect($iGuictrlcreatelabmg_hGraphic, 0, 85, 386, 70, _GDIPlus_BrushCreateSolid(0xF0F0F0F0))
    GUICtrlCreateLabel("", 0, 85, 386, 70)
    GUICtrlSetBkColor(-1, 0xF0F0F0)
    GUICtrlSetState(-1, $GUI_DISABLE)
    Local $Button = GUICtrlCreateButton(" Test ", 70, 95)
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
;~              _GDIPlus_Shutdown()
                GUIDelete()
                ExitLoop
            Case $msg = $Button
                MsgBox(0, "", "Button pressed")
        EndSelect
    WEnd
EndFunc   ;==>MsgOkey

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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...