Jump to content

Editbox Appending


Ambient
 Share

Recommended Posts

Hi folks,

I am trying to create an ini editor for work purposes. I have a GUI which has a context menu built on the fly from ini sections. When I click on the menu it it then passes the section name to a function that uses $text=IniReadSection ( $g_IniFile, $section ). This then puts the section keys into the editbox $edit1 using

$Edit1 = GUICtrlCreateEdit("",30,70,600,300,BitOR($ES_NOHIDESEL,$ES_AUTOVSCROLL, $WS_HSCROLL,$WS_VSCROLL, $ES_MULTILINE))

GUICtrlSetData ($Edit1 ,_readsection($sText))

The problem is this, before running GUICtrlSetData ($Edit1 ,_readsection($sText))

I run a clear function which essentially does

this

GUICtrlSetData ($Edit1 ,"") which clears the text OK from $edit1

If I then rightclick and bring up my selecting another section it puts it into the editbox but it is appended to the

section text that was there previously. AHs anayone got any ideas where I'mgoing wrong. I have searched for 2 days in forum but can't see any thing releavant.

I a have also tried in clear the following:

$rs=GUICtrlSetData($Edit1 , "","")

sleep(2000)

If $rs=1 Then

msgbox(0,$rs, "Success")

Else

msgbox(0,$rs, "Failure")

Endif

this returns 1

Also tried

_GUICtrlEdit_SetText($edit1,"")

and

GUICtrlSendMsg($Edit1 , $WM_SETTEXT, 0, "")

No joy either , thanks in advance for your suggestions.Also , any ideas how I can save edited text to the file.

Link to comment
Share on other sites

  • Moderators

Ambient,

The code you have tried should work, as you can see here:

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

$sText = "Just for a start"
$sText2 = "And now for something completely different"

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

$hButton = GUICtrlCreateButton("Change", 10, 10, 80, 30)

$hEdit1 = GUICtrlCreateEdit("", 10, 50, 480, 300, BitOR($ES_NOHIDESEL, $ES_AUTOVSCROLL, $WS_HSCROLL, $WS_VSCROLL, $ES_MULTILINE))

GUISetState()

GUICtrlSetData($hEdit1, $sText)

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
            GUICtrlSetData($hEdit1, $sText2)
    EndSwitch

WEnd

So I am tempted to suspect the problem is in the function that sends the text to the GUICtrlSetData command - _readsection. Have you looked at what it is returning - perhaps a quick ConsoleWrite or MsgBox as it returns might pay dividends! ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I suspect you may be right did a quick consolewrite and it looks like it is returning duplicate key names? However only showing one in Editbox. Anyway haven't time today to look at it further . Thank you very much for your suggestion. I'll keep you posted.

Link to comment
Share on other sites

Hello, M23.

Is it possible to use a $Edit box, to display the content of a .INI file.

Imagine, that you have a .INI file in your documents folder, and you want to edit it, but using one $EDIT box, sow you have to read the .INI file in to the $Edit Box, and if you made any change of the text that is on the $Edit box, you can save it.

Do you think that's possible?

Thanks in advance.

Link to comment
Share on other sites

  • Moderators

mini,

Please do not hijack threads - it is considered rude here! ;)

But yes, you can do what you ask very easily. Look at FileRead and FileWrite in the Help file.

If you want more help, start a new topic! :evil:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

mini,

Please do not hijack threads - it is considered rude here! ;)

But yes, you can do what you ask very easily. Look at FileRead and FileWrite in the Help file.

If you want more help, start a new topic! :evil:

M23

Sorry Ambient for using your thread....

Thx for the advise M23

Link to comment
Share on other sites

Hi got this one sorted now working as I would like except the part where I do the editing saving etc.Mini you are forgiven its the season of "goodwill to all men" (oh and women of course) after all lol!Thanks a bunch Melba23 your suggestion worked it was that function. I was initializing a variable outside the function to clear the editbox mived this into the function to clear before updating and now working a treat. All I have to do now is work out how to do the rest of this lol! Have a great Christmas and Thanks again.

Link to comment
Share on other sites

  • Moderators

Ambient,

Glad I could help! ;)

Merry Xmas!

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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