Jump to content

Recommended Posts

Posted

Hello :bye:

It has been quite awhile since I posted but thought I would share an interesting script that I am using in one of my projects.

This script allows a user to quickly edit a label control and and relock it.

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

Global $Data, $Label

GUICreate("Example", 500, 500)
$Data = GUICtrlCreateEdit("Write something in here and hit lock.", 0, 0, 500, 480)
$State = GUICtrlCreateButton("Lock", 0, 480, 500, 20)
GUISetState(@SW_SHOW)

$Set = 0

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $State
            If $Set = 0 Then
                $Label = GUICtrlCreateLabel(GUICtrlRead($Data), 0, 0, 500, 480)
                GUICtrlSetState($Label, $GUI_HIDE)
                GUICtrlDelete($Data)
                GUICtrlSetState($Label, $GUI_SHOW)
                GUICtrlSetData($State, "Unlock")
                $Set = 1
            ElseIf $Set = 1 Then
                $Data = GUICtrlCreateEdit(GUICtrlRead($Label), 0, 0, 500, 480)
                GUICtrlSetState($Data, $GUI_HIDE)
                GUICtrlDelete($Label)
                GUICtrlSetState($Data, $GUI_SHOW)
                GUICtrlSetData($State, "Lock")
                $Set = 0
            Else
            ;    _Error()
                Exit
            EndIf
    EndSwitch
WEnd
Posted (edited)

  On 8/13/2012 at 1:14 PM, 'czardas said:

I like the concept. I was also thinking it might be an idea to make the label clickable - just a thought!

That is actually a good idea, but would need a way of making the client aware of that.

Edited by SkellySoul
Posted (edited)

My version:

  Reveal hidden contents

Regards,

João Carlos.

Edited by JScript

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

  Reveal hidden contents

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Posted (edited)

I thought it would be something like this:

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <WinAPI.au3>

$hGUI = GUICreate("Example", 500, 500)

$iLabel = GUICtrlCreateLabel("Some data, right click to show the menu.", 20, 20, 460, 40)

$iMenu = GUICtrlCreateContextMenu($iLabel)
$iRename_MItem = GUICtrlCreateMenuItem("Rename", $iMenu)

GUISetState(@SW_SHOW)

While 1
    $iMsg = GUIGetMsg()

    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $iRename_MItem
            GUICtrlSetState($iLabel, $GUI_HIDE)

            $aCtrlPos = ControlGetPos($hGUI, '', $iLabel)

            $iEdit = GUICtrlCreateEdit(GUICtrlRead($iLabel), $aCtrlPos[0], $aCtrlPos[1],  $aCtrlPos[2]+5, $aCtrlPos[3]+5, BitOR($ES_WANTRETURN, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL))
            $hEdit = GUICtrlGetHandle($iEdit)

            While 1
                Sleep(10)

                $tPoint = _WinAPI_GetMousePos()

                If _WinAPI_WindowFromPoint($tPoint) <> $hEdit And (_IsPressed('01') Or _IsPressed('1B')) Then
                    ExitLoop
                EndIf
            WEnd

            GUICtrlSetData($iLabel, GUICtrlRead($iEdit))
            GUICtrlDelete($iEdit)
            GUICtrlSetState($iLabel, $GUI_SHOW)
    EndSwitch
WEnd
Edited by MrCreatoR

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted (edited)

In the UDF format to make life easier for noobs ...

  Reveal hidden contents

Regards,

João Carlos.

Edited by JScript

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

  Reveal hidden contents

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Posted (edited)

Here another approach:

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

Global $Data, $Label, $sData, $iExStyle, $iStyle, $hGUI, $hData, $State, $Set

$hGUI = GUICreate("Example", 500, 500)
$Data = GUICtrlCreateEdit("Write something in here and hit lock.", 0, 0, 500, 480)
$hData = GUICtrlGetHandle($Data)
$State = GUICtrlCreateButton("Lock", 0, 480, 500, 20)
GUISetState(@SW_SHOW)

$iStyle = _WinAPI_GetWindowLong($hData, $GWL_STYLE )
$iExStyle = _WinAPI_GetWindowLong($hData, $GWL_EXSTYLE)
$Set = 0

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $State
            If $Set = 0 Then
                _WinAPI_SetWindowLong($hData, $GWL_STYLE , BitXOR($iStyle, 0x3118C0)) ;this is unfortunately not working properly thus the GUIRegisterMsg() below
                GUICtrlSetData($State, "Unlock")
                _WinAPI_RedrawWindow($hGUI)
                $sData = GUICtrlRead($Data)
                GUIRegisterMsg($WM_COMMAND, '_WM_COMMAND')
                $Set = 1
            ElseIf $Set = 1 Then
                _WinAPI_SetWindowLong($hData, $GWL_STYLE ,  $iStyle)
                GUICtrlSetData($State, "Lock")
                _WinAPI_RedrawWindow($hGUI)
                GUIRegisterMsg($WM_COMMAND, '')
                $Set = 0
            Else
            ;    _Error()
                Exit
            EndIf
    EndSwitch
WEnd

Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    Switch BitAND($wParam, 0x0000FFFF)
        Case $Data
            GUICtrlSetData($Data, $sData)
    EndSwitch
    Return "GUI_RUNDEFMSG"
EndFunc

Or even easier:

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

Global $Data, $Label, $hGUI, $hData, $State, $Set

$hGUI = GUICreate("Example", 500, 500)
$Data = GUICtrlCreateEdit("Write something in here and hit lock.", 0, 0, 500, 480)
$State = GUICtrlCreateButton("Lock", 0, 480, 500, 20)
GUISetState(@SW_SHOW)
$Set = 0

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $State
            If $Set = 0 Then
                GUICtrlSetState($Data, $GUI_DISABLE)
                GUICtrlSetData($State, "Unlock")
                $Set = 1
            ElseIf $Set = 1 Then
                GUICtrlSetState($Data, $GUI_ENABLE)
                GUICtrlSetData($State, "Lock")
                $Set = 0
            Else
            ;    _Error()
                Exit
            EndIf
    EndSwitch
WEnd

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted

I honestly didn't expect so many people to reply to this thread or be interested. I really enjoyed seeing everyone else's take on the idea and will be sure to use them.

Posted (edited)

  Quote

this is unfortunately not working properly thus the GUIRegisterMsg() below

:huh:

What wrong with GUICtrlSetStyle($Data, BitOR($iStyle, $ES_READONLY))?

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>

$hGUI = GUICreate("Example", 500, 500)
$iData = GUICtrlCreateEdit("Write something in here and hit lock.", 0, 0, 500, 480)
$iState = GUICtrlCreateButton("Lock", 0, 480, 500, 20)

GUISetState(@SW_SHOW)

$iSet = 0

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $iState
            Local $aData[2][2] = [[$ES_READONLY, 0], ["Unlock", "Lock"]]

            GUICtrlSetStyle($iData, BitOR($GUI_SS_DEFAULT_EDIT, $aData[0][$iSet]))
            GUICtrlSetData($iState, $aData[1][$iSet])

            $iSet = Number(Not $iSet)
    EndSwitch
WEnd
Edited by MrCreatoR

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted (edited)

Thanks MrCreatoR, I searched for something like GUICtrlSetStyle() but found first _WinAPI_SetWindowLong()...

Here the code with GUICtrlSetStyle():

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

Global $Data, $Label, $sData, $iExStyle, $iStyle, $hGUI, $hData, $State, $Set

$hGUI = GUICreate("Example", 500, 500)
$Data = GUICtrlCreateEdit("Write something in here and hit lock.", 0, 0, 500, 480)
$hData = GUICtrlGetHandle($Data)
$State = GUICtrlCreateButton("Lock", 0, 480, 500, 20)
GUISetState(@SW_SHOW)

$iStyle = _WinAPI_GetWindowLong($hData, $GWL_STYLE )
$iExStyle = _WinAPI_GetWindowLong($hData, $GWL_EXSTYLE)
$Set = 0

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $State
            If $Set = 0 Then
                GUICtrlSetStyle($Data, $iStyle + $ES_READONLY)
                GUICtrlSetData($State, "Unlock")
                $sData = GUICtrlRead($Data)
                $Set = 1
            ElseIf $Set = 1 Then
                GUICtrlSetStyle($Data, $iStyle)
                GUICtrlSetData($State, "Lock")
                $Set = 0
            Else
            ;    _Error()
                Exit
            EndIf
    EndSwitch
WEnd

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted (edited)

@skellysoul

Thank you for raising this subject it's been interesting and informative seeing everyones approach to the task.

@MrCreatoR

My favourite was your solution, in fact I think it is so good that it should be placed into the Snippets section.

EDIT: (To clarify which one, )

Thanks @all

Regards,

DeMo.

Edited by GerrOrneq

Quote of the week:"BASIC programmers never die, they GOSUB and don't RETURN." -- UnknownWisdom of the ages:

  

  • I'd be unstoppable... if not for law enforcement and physics.
  • Marriage, the number 1 cause of divorce.
  • Don't steal... the government hates competition.
  • Irish Government Motto: We’ve got what it takes to take what you’ve got.
  • Birthdays are good for you. Statistics show that the people who have the most live the longest.
  • Failure is not an option. It comes bundled with your Microsoft product.-- Ferenc Mantfeld
  • If you learn from your mistakes, then why ain't I a genius?! -- Anonymous
  • Remember, live every day as if it was your last day! one day you will be right.
  • How is it one careless match can start a forest fire, but it takes a whole box to start a campfire?
  • Sure my system is secure, it just locked up again.
  • I haven't lost my mind; I have a tape back-up somewhere.  ~Author Unknown
Posted

  On 8/14/2012 at 3:25 PM, 'GerrOrneq said:

@MrCreatoR

My favourite was your solution, in fact I think it is so good that it should be placed into the Snippets section.

EDIT: (To clarify which one, )

It's need more polishing, for example, while you select the editable text and drag the mouse outside the control borders the edit is done.

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted (edited)

Here it's in UDF style:

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

Global $hEL_Wnd, $iEL_Label, $iEL_Edit

$hGUI = GUICreate("Example", 500, 100)

$aEditLabel = _EditableLabel_Create($hGUI, "Some data, left click (and wait few moments) to edit.", 20, 20, 460, 30)

Dim $aAccellKeys[1][2] = [['{ESC}', $aEditLabel[1]]]
GUISetAccelerators($aAccellKeys, $hGUI)

GUISetState(@SW_SHOW)

While 1
    $iMsg = GUIGetMsg()
    
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $aEditLabel[0]
            _EditableLabel_Show($aEditLabel)
        Case $aEditLabel[1]
            _EditableLabel_Hide($aEditLabel, False)
    EndSwitch
WEnd

Func _EditableLabel_Create($hWnd, $sData, $iLeft, $iTop, $iWidth = -1, $iHeight = -1)
    Local $aRet[2]
    
    $aRet[0] = GUICtrlCreateLabel($sData, $iLeft, $iTop, $iWidth, $iHeight)
    $aRet[1] = GUICtrlCreateEdit($sData, $iLeft, $iTop, $iWidth + 5, $iHeight + 5, BitOR($ES_WANTRETURN, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL))
    GUICtrlSetState($aRet[1], $GUI_HIDE)
    
    $hEL_Wnd = $hWnd
    
    Return $aRet
EndFunc

Func _EditableLabel_Show($aEditLabel = 0)
    If @NumParams > 0 Then
        $iEL_Label = $aEditLabel[0]
        $iEL_Edit = $aEditLabel[1]
        AdlibRegister('_EditableLabel_Show', 800)
        Return
    EndIf
    
    AdlibUnRegister('_EditableLabel_Show')
    GUIRegisterMsg($WM_LBUTTONUP, '__EL_WM_LBUTTONUP')
    
    Local $aPos = ControlGetPos($hEL_Wnd, '', $iEL_Label)
    Local $aWinPos = WinGetClientSize($hEL_Wnd)
    
    If ($aPos[1] + ($aPos[3] - 10)) > $aWinPos[1] Then
        $aPos[3] = $aWinPos[1] - ($aPos[1] + 10)
    EndIf
    
    GUICtrlSetData($iEL_Edit, GUICtrlRead($iEL_Label))
    GUICtrlSetPos($iEL_Edit, $aPos[0], $aPos[1], $aPos[2] + 5, $aPos[3] + 5)
    
    GUICtrlSetState($iEL_Edit, $GUI_SHOW)
    GUICtrlSetState($iEL_Label, $GUI_HIDE)
EndFunc

Func _EditableLabel_Hide($aEditLabel, $bUpdate = True)
    GUIRegisterMsg($WM_LBUTTONUP, '')
    
    If IsArray($aEditLabel) Then
        $iEL_Label = $aEditLabel[0]
        $iEL_Edit = $aEditLabel[1]
    EndIf
    
    GUICtrlSetState($iEL_Edit, $GUI_HIDE)
    GUICtrlSetState($iEL_Label, $GUI_SHOW)
    
    If $bUpdate Then
        Local $aPos = ControlGetPos($hEL_Wnd, '', $iEL_Label)
        Local $sData = GUICtrlRead($iEL_Edit)
        
        StringReplace($sData, @CRLF, '')
        Local $iLines = @extended - 1
        
        GUICtrlSetData($iEL_Label, $sData)
        GUICtrlSetPos($iEL_Label, $aPos[0], $aPos[1], $aPos[2], $aPos[3] + (22 * $iLines))
    EndIf
EndFunc

Func __EL_WM_LBUTTONUP($hWnd, $iMsg, $wParam, $lParam)
    _EditableLabel_Hide(0, True)
EndFunc
Edited by MrCreatoR

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

  • 2 weeks later...
Posted

Very nice feature to edit labels.

I had some issues with the above example in UDF style though. When there is only one line on the label @extended returns 0 and so the label is made one line (22) smaller. For example by clicking on the text and then outside the label without changing anything. Also the label doesn't resize back when lines are removed. I also would like that style/exstyle parameters can be set on the label.

This code works for me (v3.3.8.1)

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>

Global $hEL_Wnd, $iEL_Label, $iEL_Edit
$hGUI = GUICreate("Example", 500, 200)
$aEditLabel = _EditableLabel_Create($hGUI, "Some data, left click (and wait few moments) to edit.", 20, 20, 280, 22,-1,$WS_EX_DLGMODALFRAME)
Dim $aAccellKeys[1][2] = [['{ESC}', $aEditLabel[1]]]
GUISetAccelerators($aAccellKeys, $hGUI)
GUISetState(@SW_SHOW)
While 1
$iMsg = GUIGetMsg()
Switch $iMsg
     Case $GUI_EVENT_CLOSE
         Exit
     Case $aEditLabel[0]
         _EditableLabel_Show($aEditLabel)
     Case $aEditLabel[1]
         _EditableLabel_Hide($aEditLabel, False)
EndSwitch
WEnd
Func _EditableLabel_Create($hWnd, $sData, $iLeft, $iTop, $iWidth = -1, $iHeight = -1,$sStyle= -1, $sExStyle =-1)
Local $aRet[2]
$aRet[0] = GUICtrlCreateLabel($sData, $iLeft, $iTop, $iWidth, $iHeight, $sStyle, $sExStyle)
$aRet[1] = GUICtrlCreateEdit($sData, $iLeft, $iTop, $iWidth + 5, $iHeight + 5, BitOR($ES_WANTRETURN, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL))
GUICtrlSetState($aRet[1], $GUI_HIDE)
$hEL_Wnd = $hWnd
Return $aRet
EndFunc
Func _EditableLabel_Show($aEditLabel = 0)
If @NumParams > 0 Then
     $iEL_Label = $aEditLabel[0]
     $iEL_Edit = $aEditLabel[1]
     AdlibRegister('_EditableLabel_Show', 800)
     Return
EndIf
AdlibUnRegister('_EditableLabel_Show')
GUIRegisterMsg($WM_LBUTTONUP, '__EL_WM_LBUTTONUP')
Local $aPos = ControlGetPos($hEL_Wnd, '', $iEL_Label)
Local $aWinPos = WinGetClientSize($hEL_Wnd)
If ($aPos[1] + ($aPos[3] - 10)) > $aWinPos[1] Then
     $aPos[3] = $aWinPos[1] - ($aPos[1] + 10)
EndIf
GUICtrlSetData($iEL_Edit, GUICtrlRead($iEL_Label))
GUICtrlSetPos($iEL_Edit, $aPos[0], $aPos[1], $aPos[2], $aPos[3])
GUICtrlSetState($iEL_Edit, $GUI_SHOW)
GUICtrlSetState($iEL_Label, $GUI_HIDE)
EndFunc
Func _EditableLabel_Hide($aEditLabel, $bUpdate = True)
GUIRegisterMsg($WM_LBUTTONUP, '')
If IsArray($aEditLabel) Then
     $iEL_Label = $aEditLabel[0]
     $iEL_Edit = $aEditLabel[1]
EndIf
GUICtrlSetState($iEL_Edit, $GUI_HIDE)
GUICtrlSetState($iEL_Label, $GUI_SHOW)
If $bUpdate Then
     Local $aPos = ControlGetPos($hEL_Wnd, '', $iEL_Label)
     Local $sData = GUICtrlRead($iEL_Edit)
     StringReplace($sData, @CRLF, '')
     Local $iLines = @extended + 1
     GUICtrlSetData($iEL_Label, $sData)
     GUICtrlSetPos($iEL_Label, $aPos[0], $aPos[1], $aPos[2], 22 * $iLines)
EndIf
EndFunc
Func __EL_WM_LBUTTONUP($hWnd, $iMsg, $wParam, $lParam)
_EditableLabel_Hide(0, True)
EndFunc

I also mixed the UDF with an example of Melba23 so the label can be dragged as well:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <EditConstants.au3>
; Mouse coords relative to GUI client area
Opt("MouseCoordMode", 2)
Global $hEL_Wnd, $iEL_Label, $iEL_Edit,$fDblClk
; Create GUI
$hGUI = GUICreate("Left click to drag/Right click to edit", 300, 200)
$cLabel = _EditableLabel_Create($hGUI, "Flexible label", 10, 150, 100, 22)
GUICtrlSetBkColor(-1, 0xD4D0C8)
;Sets the accelerator table
Dim $aAccellKeys[1][2] = [['{ESC}', $cLabel[1]]]
GUISetAccelerators($aAccellKeys, $hGUI)
GUISetState()

While 1
Switch GUIGetMsg()
     Case $GUI_EVENT_CLOSE
         Exit
Case $GUI_EVENT_SECONDARYUP
         $cInfo = GUIGetCursorInfo($hGUI)
         $iControl = $cInfo[4]
         If $iControl = $cLabel[0] then _EditableLabel_Show($cLabel)
     Case $GUI_EVENT_PRIMARYDOWN
         $cInfo = GUIGetCursorInfo($hGUI)
         $iControl = $cInfo[4]
         Switch $iControl
             Case $cLabel[0]
                 $bPos = ControlGetPos($hGUI, "", $iControl)
                 $iSubtractX = $cInfo[0] - $bPos[0]
                 $iSubtractY = $cInfo[1] - $bPos[1]
                 ; Move the control until the mouse button is released
                 Do
                     $cInfo = GUIGetCursorInfo($hGUI)
                     ControlMove($hGUI, "", $iControl, $cInfo[0] - $iSubtractX, $cInfo[1] - $iSubtractY)
                 Until Not $cInfo[2]
EndSwitch
     Case $cLabel[1]
         _EditableLabel_Hide($cLabel, False)
EndSwitch
WEnd
Func _EditableLabel_Create($hWnd, $sData, $iLeft, $iTop, $iWidth = -1, $iHeight = -1,$sStyle= -1, $sExStyle =-1)
Local $aRet[2]
$aRet[0] = GUICtrlCreateLabel($sData, $iLeft, $iTop, $iWidth, $iHeight, $sStyle, $sExStyle)
$aRet[1] = GUICtrlCreateEdit($sData, $iLeft, $iTop, $iWidth + 5, $iHeight + 5, BitOR($ES_WANTRETURN, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL))
GUICtrlSetState($aRet[1], $GUI_HIDE)
$hEL_Wnd = $hWnd
Return $aRet
EndFunc
Func _EditableLabel_Show($aEditLabel = 0)
If @NumParams > 0 Then
     $iEL_Label = $aEditLabel[0]
     $iEL_Edit = $aEditLabel[1]
     AdlibRegister('_EditableLabel_Show', 800)
     Return
EndIf
AdlibUnRegister('_EditableLabel_Show')
GUIRegisterMsg($WM_LBUTTONUP, '__EL_WM_LBUTTONUP')
Local $aPos = ControlGetPos($hEL_Wnd, '', $iEL_Label)
Local $aWinPos = WinGetClientSize($hEL_Wnd)
If ($aPos[1] + ($aPos[3] - 10)) > $aWinPos[1] Then
     $aPos[3] = $aWinPos[1] - ($aPos[1] + 10)
EndIf
GUICtrlSetData($iEL_Edit, GUICtrlRead($iEL_Label))
GUICtrlSetPos($iEL_Edit, $aPos[0], $aPos[1], $aPos[2], $aPos[3])
GUICtrlSetState($iEL_Edit, $GUI_SHOW)
GUICtrlSetState($iEL_Label, $GUI_HIDE)
EndFunc
Func _EditableLabel_Hide($aEditLabel, $bUpdate = True)
GUIRegisterMsg($WM_LBUTTONUP, '')
If IsArray($aEditLabel) Then
     $iEL_Label = $aEditLabel[0]
     $iEL_Edit = $aEditLabel[1]
EndIf
GUICtrlSetState($iEL_Edit, $GUI_HIDE)
GUICtrlSetState($iEL_Label, $GUI_SHOW)
If $bUpdate Then
     Local $aPos = ControlGetPos($hEL_Wnd, '', $iEL_Label)
     Local $sData = GUICtrlRead($iEL_Edit)
     StringReplace($sData, @CRLF, '')
     Local $iLines = @extended + 1
     GUICtrlSetData($iEL_Label, $sData)
     GUICtrlSetPos($iEL_Label, $aPos[0], $aPos[1], $aPos[2], 22 * $iLines)
EndIf
EndFunc
Func __EL_WM_LBUTTONUP($hWnd, $iMsg, $wParam, $lParam)
_EditableLabel_Hide(0, True)
EndFunc

This works quite ok, though I think it would be nicer to just use GUICtrlCreateLabel and set the style to $SS_DRAGANDDROP and $SS_EDIT.

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