Jump to content

Guictrlsetstyle() Problem


Recommended Posts

Hey, it's me again :)

I'm creating a editor with the GUI EDIT and i want to protect the edit with readonly and with a button to unlock it.

I got the script and it works, but there's a resize problem. When i'm maximize or resize the window and change the style, the editbox resizes back to the orginal size. How can I fix this?

Here's a example:

#NoTrayIcon
#include <GUIConstants.au3>

GUICreate("hoi", 400, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX, $WS_SIZEBOX))
$edit = GUICtrlCreateEdit("Blabla", 0, 0, 400, 350)
GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM)
$button = GUICtrlCreateButton("SET TEXT and readonly 1", 10, 360, 190, 23)
$button1 = GUICtrlCreateButton("SET TEXT 2", 200, 360, 190, 23)
GUISetState()
While 1
    Switch GUIGetMsg()
    Case -3
        Exit
    Case $button
        GUICtrlSetStyle($edit, BitOR($ES_LEFT, $ES_AUTOHSCROLL, $ES_READONLY))
        GUICtrlSetData($edit, "The new text")
    Case $button1
        GUICtrlSetStyle($edit, BitOR($ES_LEFT, $ES_AUTOHSCROLL))
        GUICtrlSetData($edit, "The new text")
    EndSwitch
WEnd

Thanks Ghastly_MIB

Link to comment
Share on other sites

Global Const $EM_SETREADONLY = 0xCF

; set to read only
    GUICtrlSendMsg($edit, $EM_SETREADONLY, 1, 0)
; unset read only
    GUICtrlSendMsg($edit, $EM_SETREADONLY, 0, 0)

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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