Sign in to follow this  
Followers 0
pekster

Edit Box With Scrollbars

12 posts in this topic

I would like to use an edit box with scroll bars as it apperas in CyberSlug's example, but without letting the user edit it ($EX_READONLY state.) However, even without that paramater, I am still unable to reproduce what I see when I run CyberSlug's "for screenshot.au3" file. Here is his relevant code:

GUISetControl( "edit", "This is an edit control", 1, 30, 200, 50)

And here is what I am doing:

$result = GuiSetControl("edit", $list, -1, -1, 400, 30, $ES_READONLY)
;readonly = 0x0800 and causes the data to become read only

I also have the same problem (no scroll bars) when I use no state, or define 0. What am I doing wrong?


[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites



Not actually telling it to use scrollbars...

; Will need gui_include.au3 for this
Local $ES_STYLES = 0
$ES_STYLES = BitOR($ES_STYLES, $ES_READONLY)
$ES_STYLES = BitOR($ES_STYLES, $WS_HSCROLL)
$ES_STYLES = BitOR($ES_STYLES, $WS_VSCROLL)

$result = GuiSetControl("edit", $list, -1, -1, 400, 30, $ES_STYLES)

Share this post


Link to post
Share on other sites

So why does CyberSlug's work without defining any style paramater? He didn't include that file, or do any of that bit manipulation with the vertical/ horizontal vars either.


[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

Show me which example. The scrollbars won't display without WS_HSCROLL or WS_VSCROLL.

Share this post


Link to post
Share on other sites

Here is the full code example from CyberSlug:

(all his code, with my one added comment to show you my point of interest)

; Note I did this by hand using relative positioning before I knew any better! - CyberSlug

Opt("GuiCoordMode", 0)

GuiCreate("My GUI", 380, 300)
GuiShow()
WinActivate("My GUI")

FileChangeDir(@ScriptDir)
GUISetControl( "avi", "inetconnect.avi", 1, 1)
    GUISetControl("label", "Sample avi", 1, 40, 70)
GUISetControl( "button", "Button", 1, 40)
GUISetControl( "combo", "Combo", 1, 50)
    GUISetControlData(-1, "Combo", "Combo")
GUISetControl( "date", "", 1, 50, 200)
    GUISetControl("label", "Date control expands in to a calendar...", 1, 30)
;===HERE IS THE LINE REFERANCED IN MY FIRST POST=== :
GUISetControl( "edit", "This is an edit control", 1, 30, 200, 50)

Opt("GuiCoordMode", 1)
GUISetControl( "label","", 100, 1, 1, 1)
Opt("GuiCoordMode", 0)

GUISetControl( "input", "Input", -10, 80, 100, 20)

GUISetControl("label", "This is a green label", 1, 50, 100, 20)
    GUISetControlEx(-1, 0, 0, "" ,0, 0x00FF00)

Opt("GuiCoordMode", 1)
GUISetControl( "list","", 200, 1, 120, 60)
    GUISetControlData(-1, "Listbox control|Sample", "Sample")
Opt("GuiCoordMode", 0)

GUISetControl( "progress", "", 1, 50, 120, 20)
    GUISetControlEx (-1, 70)
    GUISetControl("label", "Sample progress", 40, 21)

GUISetControl( "group", "Group", -30, 30, 140, 70)
    GUISetControl( "radio", "Radio One", 10, 20, 80, 20)
    GUISetControl( "radio", "Radio Two", -1, 20, 80, 20)
        GuiSetControlEx(-1, 1);check Radio Two

Opt("GuiCoordMode", 1)
GUISetControl("checkbox", "Checkbox", 250, 270, 100,20)

GUISetControl( "icon","shell32.dll|2", 330, 10)
   GUISetControl("label", "  Icon", 330, 50)

GUISetControl( "pic","logo.bmp", 80, 1)
   GUISetControl("label", "Sample pic", 115, 45, 60, 15)


GUISetControl("tab", "", 220, 180, 140, 80)
    GUISetControl("tabitem", "One", 1, 60)

    GUISetControl("label", "Sample tab control", 230, 220, 100, 30)
    GUISetControl("tabitem", "Two...", 1, 60)
    GUISetControl("tabitem", "",0,0)



GuiWaitClose()

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

The control is probably automatically getting WS_HSCROLL or WS_VSCROLL when created without overriding the style parameter. If you do manually set your own style (Which must be done to add $ES_READONLY*), I think we are assuming you know what you are doing and only required styles are added. Scrollbars are most definitely not required to make the basic control work like expected, so it is not forced on. It is default only for convenience.

* You can also change the read only state at run time as follows:

Global $EM_SETREADONLY = 0x00CF

; Remove read-only
GUISendMsg($controlRef, $EM_SETREADONLY, 0, 0)

; Add read-only
GUISendMsg($controlRef, $EM_SETREADONLY, 1, 0)

Share this post


Link to post
Share on other sites

Ah, thank you very much. I assumed that setting my global $state var to 0 was the same as what CyberSlug did, but that is not the case. Leaving it off fixed my problem, as well as adding in the proper scroll values. Thanks


[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

This should help :D

$ES_READONLY = 0x800;
$WS_DISABLED = 0x8000000;
$WS_VSCROLL = 0x200000;
$WS_HSCROLL = 0x100000;

$style = $ES_READONLY + $WS_VSCROLL + $WS_HSCROLL


Opt("GUINotifyMode", 1)
GuiCreate("MyGUI", 400,300)
GuiSetControl("Edit","This text is read-only", 10, 10,200,200, $style)
GuiShow()
WinActivate("MyGUI")
While GuiMsg(0) <> -3
    sleep(100)
WEnd

I'll need to make a new "screenshot script" once I finalize AutoBuilder.... any day now....


Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

Beware adding styles. They really need BitOR'd because they need to pass through 32bits. Things are internally stored as double's, remember.

Share this post


Link to post
Share on other sites

Or just bypass the whole problem by including all the convient global definitions in <GuiConstants.au3> :D


[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

Beware adding styles.  They really need BitOR'd because they need to pass through 32bits.  Things are internally stored as double's, remember.

:huh2: That's a very good point, Valik. I'll have to get jpm to add it to the docs--unless it's already there and I missed it :D

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

I don't think it's there. As far as I know, I'm the only one who discovered it with Au3GUI when the change from int to double broke a GUI script where I had been just adding the styles together. I think that it can rarely happen, though... but it can happen. I think a few of the styles are large enough to be negative numbers when stored in an int ( :D at that last statement).

Defining the styles in hex notation also fixes the problem, I think. If I remember, when using hex notation, the number is passed through an int so it should be correct, even if the styles are added instead of BitOR'd (Another reason I always use the hex notation instead of decimal in my code).

Share this post


Link to post
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
Sign in to follow this  
Followers 0