Jump to content

GUICtrlCreateEdit


Recommended Posts

hi,

can I set bold data in GUICtrlCreateEdit like this:

'my text bla... bla... <b>this is bold</> and other text is not bold bla.. bla...'

I wuold like to select 'this is bold' text and when I press button [bOLD] the data set to <b>this is bold</b>

like wysiwyg editor but most simple and only with au3 file

thanks, bye

Link to comment
Share on other sites

You can't do this with edit control. You have to create a IE object inside your GUI to do this..

Examples can be found in the helpfile.

sorry but I don't have much experience with IE object, can you post me one example?

I would like to write a txt file only with text and html format, only with <b> and <I>

with the gui edit I can't find text selected and set to another text?

Link to comment
Share on other sites

Sometimes, the search function works miracles...

This is my own example though.

#include <GUIConstants.au3>
#include <IE.au3>

_IEErrorHandlerRegister ()

$oIE = _IECreateEmbedded ()
GUICreate("Embedded Web control Test", 640, 580, _
        (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _
        $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 600, 360)
$GUI_Button_Back = GUICtrlCreateButton("Back", 10, 420, 100, 30)
$GUI_Button_Forward = GUICtrlCreateButton("Forward", 120, 420, 100, 30)
$GUI_Button_Home = GUICtrlCreateButton("Home", 230, 420, 100, 30)
$GUI_Button_Stop = GUICtrlCreateButton("Stop", 340, 420, 100, 30)

GUISetState()       ;Show GUI

_IENavigate($oIE,"about:blank")
_IEDocWriteHTML($oIE,"<html><b>This is bold</b><br><i>This is italic</i><br>This is normal</html>")

; Waiting for user to close the window
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $GUI_Button_Home
            _IENavigate ($oIE, "http://www.autoitscript.com")
        Case $msg = $GUI_Button_Back
            _IEAction ($oIE, "back")
        Case $msg = $GUI_Button_Forward
            _IEAction ($oIE, "forward")
        Case $msg = $GUI_Button_Stop
            _IEAction ($oIE, "stop")
    EndSelect
WEnd
Link to comment
Share on other sites

Sometimes, the search function works miracles...

This is my own example though.

I have searching but I don't have find solution to my problem...

your example display only text htm formatted but is not possible to modify them with gui interface...

This is for my inexperience...

I must load a txt file, modify them and save it in text format and not htm...

now I play with autoit...

thanks Manadar

Link to comment
Share on other sites

In Holland we call this behavior "Verder kijken dan je lul lang is.."

#include <GUIConstants.au3>
#include <IE.au3>

_IEErrorHandlerRegister ()

$oIE = _IECreateEmbedded ()
GUICreate("Embedded Web control Test", 640, 580)
$GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 600, 300)


$Edit = GUICtrlCreateEdit("",10,360,600-80,80,BitOR($ES_AUTOVSCROLL,$ES_AUTOhSCROLL))
$Go = GUICtrlCreateButton("Send",540,360,80,80)

GUISetState()       ;Show GUI

_IENavigate($oIE,"about:blank")

_IEDocWriteHTML($oIE,"This example allows BB-code to be input.. use [ b] [ /b] to make bolds and [ i] [ /i] to make italics.. <p>")

; Waiting for user to close the window
While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Go
            $Read = GUICtrlRead($Edit)
            $Read = StringReplace($Read,@CRLF,"<p>")
            $Read = StringReplace($Read,"[b]","<b>")
            $Read = StringReplace($Read,"[/b]","</b>")
            $Read = StringReplace($Read,"[i]","<i>")
            $Read = StringReplace($Read,"[/i]","</i>")
            _IEDocWriteHTML($oIE,_IEDocReadHTML($oIE) & "<p>" & $Read)
            
            GUICtrlSetData($Edit,"")
            GUICtrlSetState($Edit,$GUI_FOCUS)
    EndSwitch
WEnd
Edited by Manadar
Link to comment
Share on other sites

In Holland we call this behavior "Verder kijken dan je lul lang is.."

thanks for your help...

but now I have find the solution....

this is part of the script...

bye

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

Func Copy($contenuto)
    $a_sel = _GUICtrlEditGetSel($contenuto)
    Local $WholeEdit = GUICtrlRead($contenuto)
    Local $Trim = StringLeft(StringTrimLeft($WholeEdit, $a_sel[1]), $a_sel[2] - $a_sel[1])
    Return $Trim
EndFunc


$Form1 = GUICreate("Editor", 445, 326, 259, 177)
$contenuto = GUICtrlCreateEdit("", 72, 32, 297, 185)
GUICtrlSetData(-1, "Select text and press BOLD")
$bold = GUICtrlCreateButton("bold", 80, 232, 65, 25, 0)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $bold
        $Cur_Sel = Copy($contenuto)
        $Mod_Sel = "<b>" & $Cur_Sel & "</b>"
        _GUICtrlEditReplaceSel($contenuto, TRUE, $Mod_Sel)
    EndSwitch
WEnd
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...