Jump to content

Getting two GUICtrlCreateInput shown up in one GUICtrlCreateEdit


IDN
 Share

Recommended Posts

58 minutes ago, IDN said:

hope you know what i want.

Not really 🤔.

Do you mean something like this :

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

#Include <GuiEdit.au3>

; Create flag
$bEditChanged = False

Global $iLineCount = 0 ; Keep a global count so we can check if it has changed

$hGUI = GUICreate("Test", 400, 300)

$cEdit_Num = GUICtrlCreateEdit("", 10, 13, 25, 165, BitOR($ES_AUTOVSCROLL, $ES_READONLY), 0)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetData(-1, "1")
GUICtrlSetBkColor(-1, 0xC0DCC0)

$cEdit_Main = GUICtrlCreateEdit("", 36, 10, 296, 175)
GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM)
GUICtrlCreateLabel("", 10, 164, 25, 11)
GUICtrlSetBkColor(-1, 0xC0DCC0)

GUISetState(@SW_SHOW)

GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")

; Example code only ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$iNewLine = 1
$nBegin = TimerInit()
; End of example code ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    ; If flag set
    If $bEditChanged Then
        ; Adjust numbering if required
        _LineNum()
        ; Clear flag
        $bEditChanged = False
    EndIf

; Example code only ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ; Add 20 lines - once every 250 msecs
    If TimerDiff($nBegin) > 250 And $iNewLine < 20 Then
        ; Add a line to show it working
        GUICtrlSetData($cEdit_Main, "Blah " & $iNewLine & @CRLF, 1)
        ; Increase count
        $iNewLine += 1
        ; Reset timer
        $nBegin = TimerInit()
    EndIf
; End of example code ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

WEnd

Func _WM_COMMAND($hWHnd, $iMsg, $wParam, $lParam)

    ; If it was an update message from the edit
    If _WinAPI_HiWord($wParam) = $EN_CHANGE And _WinAPI_LoWord($wParam) = $cEdit_Main Then
        ; Set the label to the new data
        $bEditChanged = True
    EndIf

EndFunc   ;==>_WM_COMMAND

Func _LineNum() ; line numbering
    Local $iCount = _GUICtrlEdit_GetLineCount ($cEdit_Main)

    ;Check if the number of lines has changed in $cEdit_Main
    ;since this function was last called
    If $iCount <> $iLineCount Then
        ;save the new count to the global variable
        $iLineCount = $iCount
        Local $iNumCount = _GUICtrlEdit_GetLineCount ($cEdit_Num)
        If $iLineCount > $iNumCount Then
            For $i = $iNumCount + 1 To $iLineCount
                _GUICtrlEdit_AppendText ($cEdit_Num, @CRLF & $i)
            Next
        ElseIf $iLineCount < $iNumCount Then
            $text = GUICtrlRead($cEdit_Num)
            For $i = $iNumCount To $iLineCount + 1 Step -1
                $text = StringReplace($text,@CRLF & $i,"")
            Next
            GUICtrlSetData($cEdit_Num, $text)
        EndIf
    EndIf
    Local $iFirstVisMain = _GUICtrlEdit_GetFirstVisibleLine ($cEdit_Main)
    Local $iFirstVisNum = _GUICtrlEdit_GetFirstVisibleLine ($cEdit_Num)
    If $iFirstVisMain <> $iFirstVisNum Then
        _GUICtrlEdit_LineScroll($cEdit_Num, 0, $iFirstVisMain - $iFirstVisNum)
    EndIf
EndFunc

==> it's a script from @Melba23 : see -> edit-control-showing-line-number

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

Yes this is awesome.  You always know what i want 😅.

Im so glad thank you guys for your help and specially  you Musashi, I am in your dept.

I will defenetly come back when I have another issue.

 

Thanks so much. I am so happy 😄

 

Link to comment
Share on other sites

Here's an additional variation by @mLipok (probably based on the script by Melba23) :  line-numbering-for-edit-control

#include <GUIConstants.au3>
#include <GuiEdit.au3>
#include <Misc.au3>

Global $g_iMainLineCount = 0 ; Keep a global count so we can check if it has changed
Global $_idEdit_Num , $_idEdit_Main

Example()

Func Example()
    Local $hGui = GUICreate("Example", 300, 250, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_SYSMENU, $WS_CAPTION, $WS_OVERLAPPEDWINDOW, $WS_TILEDWINDOW, $WS_POPUP, $WS_POPUPWINDOW, $WS_GROUP, $WS_TABSTOP, $WS_BORDER, $WS_CLIPSIBLINGS))
    #forceref $hGui

    $_idEdit_Num = GUICtrlCreateEdit("", 10, 10, 25, 165, BitOR($ES_AUTOVSCROLL, $ES_READONLY), 0)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlSetData(-1, "1")
    GUICtrlSetBkColor(-1, 0xC0DCC0)
    GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM + $GUI_DOCKWIDTH)

    $_idEdit_Main = GUICtrlCreateEdit("", 36, 10, 196, 175, -1, 0)
    GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM)
    GUICtrlCreateLabel("", 10, 220, 25, 11)
    GUICtrlSetBkColor(-1, 0xC0DCC0)
    GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM + $GUI_DOCKWIDTH)

    GUICtrlSetData($_idEdit_Main, "Textline 1" & @CRLF & "Textline 2" & @CRLF & "Textline 3" & @CRLF)

    GUISetState(@SW_SHOW)

    AdlibRegister("_LineNum", 100)

    Local $Msg
    While 1

        $Msg = GUIGetMsg()
        Switch $Msg
            Case $GUI_EVENT_CLOSE
                Exit

        EndSwitch

    WEnd

EndFunc   ;==>Example

Func _LineNum() ; line numbering
    Local $iCount = _GUICtrlEdit_GetLineCount($_idEdit_Main)

    ;Check if the number of lines has changed in $_idEdit_Main
    ;since this function was last called
    If $iCount <> $g_iMainLineCount Then
        ;save the new count to the global variable
        $g_iMainLineCount = $iCount
        Local $iNumCount = _GUICtrlEdit_GetLineCount($_idEdit_Num)
        If $g_iMainLineCount > $iNumCount Then
            For $i = $iNumCount + 1 To $g_iMainLineCount
                _GUICtrlEdit_AppendText($_idEdit_Num, @CRLF & $i)
            Next
        ElseIf $g_iMainLineCount < $iNumCount Then
            Local $text = GUICtrlRead($_idEdit_Num)
            For $i = $iNumCount To $g_iMainLineCount + 1 Step -1
                $text = StringReplace($text, @CRLF & $i, "")
            Next
            GUICtrlSetData($_idEdit_Num, $text)
        EndIf
    EndIf

    Local $iFirstVisMain = _GUICtrlEdit_GetFirstVisibleLine($_idEdit_Main)
    Local $iFirstVisNum = _GUICtrlEdit_GetFirstVisibleLine($_idEdit_Num)
    If $iFirstVisMain <> $iFirstVisNum Then
        _GUICtrlEdit_LineScroll($_idEdit_Num, 0, $iFirstVisMain - $iFirstVisNum)
    EndIf

EndFunc   ;==>_LineNum

 

Short question again : Which entries may appear in the field "Country of origin"? A selected or a worldwide list of countries?

 

Edited by Musashi

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

1 hour ago, Musashi said:

Short question again : Which entries may appear in the field "Country of origin"? A selected or a worldwide list of countries?

I havent think about that but now you are mention it i think a selected list of asian countrys would be great just to see how it works.

 

thank you

Link to comment
Share on other sites

1 hour ago, IDN said:

i think a selected list of asian countrys would be great just to see how it works.

The idea behind it is :
Instead of filling in the field "Country of origin" manually, a predefined pick list (ComboBox) would be helpful. This avoids typos and different forms of writing.

For example, you only need to import a .CSV file and fill the ComboBox. There are various sources with worldwide country lists available. You can take a list and remove all entries, that you don't need.

Windows itself provides country data :

#include <APILocaleConstants.au3>
#include <WinAPILocale.au3>
#include <Array.au3>

Global $aGeoID = _WinAPI_EnumSystemGeoID()
Global $aGeoFriendlyNames[UBound($aGeoID)]
$aGeoFriendlyNames[0] = UBound($aGeoID) - 1
For $i = 1 To $aGeoFriendlyNames[0]
    $aGeoFriendlyNames[$i] = _WinAPI_GetGeoInfo($aGeoID[$i], $GEO_FRIENDLYNAME)
Next
_ArraySort($aGeoFriendlyNames)
_ArrayDisplay($aGeoFriendlyNames, '$GEO_FRIENDLYNAME')

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

On 12/14/2019 at 6:32 PM, Musashi said:

The idea behind it is :
Instead of filling in the field "Country of origin" manually, a predefined pick list (ComboBox) would be helpful. This avoids typos and different forms of writing.

 

I totally agree with you, thank you for showing me this list on windows. I have learnd a lot thanks to you. I am very thankfull that you dont avoid me and even gave me tipps to

do better. 

 

I hope you dont think i am crazy becaus I say everytime thank you but I am relly thankfull.

 

Link to comment
Share on other sites

38 minutes ago, IDN said:

I hope you dont think i am crazy because I say everytime thank you but I am really thankfull.

I clearly prefer people who say "Thank you" once too often, compared to those who just complain :lol:.

For the future (general note) :
You can "rate" a contribution by moving the mouse over the grey heart (bottom right) and clicking on the desired icon.
Use this function wisely, and not for every single comment. The reputation system in this forum is not a high score list, even if some may have a different view.

Furthermore :  Don't do it retroactively here anymore, otherwise it will look like I'm fishing for compliments ;).

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

I have a new problem the nembering works fine and i can see the lines but when i will save the numbering and the lines then it writes the nubers first and then the line like.

 

Local $editcontent = GUIctrlRead($cEdit_Num) & GUICtrlRead($cEdit_Num)

 

that line definiotions what schould be saved but i mean it is just logical that it writes not the numbers in front of the line but only first the numbers and then the line:

for Example when i type in in the Edit_Main somthing like this:

Edit_Num     Eidt_Main

1                     Bla Bla BLa

2                     Bla Bla BLa

and click then button save to save it as a textfile:

it saves me the lines like thes

1

2

Bla Bla BLa

Bla Bla BLa

 

but i want it like i wrote it. in the first place.

 

So here ist my hole code:

 

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

#Include <GuiEdit.au3>
#Include <Misc.au3>

Global $g_iMainLineCount = 0 ; Keep a global count so we can check if it has changed

$hGUI = GUICreate("Form1", 200, 400, Default, Default, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_SYSMENU, $WS_CAPTION, $WS_OVERLAPPEDWINDOW, $WS_TILEDWINDOW, $WS_POPUP, $WS_POPUPWINDOW, $WS_GROUP, $WS_TABSTOP, $WS_BORDER, $WS_CLIPSIBLINGS))
$cEdit_Num = GUICtrlCreateEdit("", 10, 10, 30, 163, BitOR($ES_AUTOVSCROLL, $ES_READONLY, $ES_RIGHT), 0)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetData($cEdit_Num, "1")
GUICtrlSetBkColor($cEdit_Num, 0xC0DCC0)
GUICtrlSetResizing($cEdit_Num, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM + $GUI_DOCKWIDTH)
$save = GUICtrlCreateButton("Save", 50,220,50,20)
$cEdit_Main = GUICtrlCreateEdit("", 40, 10, 150, 180, -1, 0)
GUICtrlSetResizing($cEdit_Main, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM)
$cLabel = GUICtrlCreateLabel("", 10, 173, 30, 17)
GUICtrlSetBkColor($cLabel, 0xC0DCC0)
GUICtrlSetResizing($cLabel, $GUI_DOCKSTATEBAR + $GUI_DOCKLEFT + $GUI_DOCKWIDTH) ; $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM + $GUI_DOCKWIDTH)
GUISetState(@SW_SHOW)

AdlibRegister("_LineNum", 111)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit

         Case $save
             Local $sFileSaveDialog = FileSaveDialog("Save File As", @ScriptDir, "Text Files (*.txt)", $FD_PATHMUSTEXIST)
            Local $editcontent = GUIctrlRead($cEdit_Num) & GUICtrlRead($g_iMainLineCount)
;~             ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $editcontent = ' & $editcontent & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
            FileWrite($sFileSaveDialog, $editcontent)
;~             ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : FileWrite("Save.txt", $sFileSaveDialog) = ' & FileWrite("Save.txt", $sFileSaveDialog) & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

 

    EndSwitch
WEnd

Func _LineNum() ; line numbering
    Local $iCount = _GUICtrlEdit_GetLineCount ($cEdit_Main)

    ;Check if the number of lines has changed in $cEdit_Main
    ;since this function was last called
    If $iCount <> $g_iMainLineCount Then
        ;save the new count to the global variable
        $g_iMainLineCount = $iCount
        Local $iNumCount = _GUICtrlEdit_GetLineCount ($cEdit_Num)
        If $g_iMainLineCount > $iNumCount Then
            For $i = $iNumCount + 1 To $g_iMainLineCount
                _GUICtrlEdit_AppendText ($cEdit_Num,  @CRLF & $i)
            Next
        ElseIf $g_iMainLineCount < $iNumCount Then
            $text = GUICtrlRead($cEdit_Num)
            For $i = $iNumCount To $g_iMainLineCount + 1 Step -1
                $text = StringReplace($text,@CRLF & $i,"")
            Next
            GUICtrlSetData($cEdit_Num, $text)
        EndIf
    EndIf
    Local $iFirstVisMain = _GUICtrlEdit_GetFirstVisibleLine ($cEdit_Main)
    Local $iFirstVisNum = _GUICtrlEdit_GetFirstVisibleLine ($cEdit_Num)
    If $iFirstVisMain <> $iFirstVisNum Then
        _GUICtrlEdit_LineScroll($cEdit_Num, 0, $iFirstVisMain - $iFirstVisNum)
    EndIf
EndFunc

 

 

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