Jump to content

Edit with diffrent styles


Recommended Posts

  • Moderators

Reinhardt1julian,

No, you need a RichEdit control for that. Guess where you find out about them. ;)

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

Ok, I tried to fix this but I took a part of the code from the helpfile

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
RichEditExample()
Func RichEditExample()
Local $oRP, $TagsPageC, $AboutC, $PrefsC, $StatC, $GUIActiveX, $msg
$oRP = ObjCreate("RICHTEXT.RichtextCtrl.1")

GUICreate("Embedded RICHTEXT control Test", 320, 200, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))
$TagsPageC = GUICtrlCreateLabel('Visit Tags Page', 5, 180, 100, 15, $SS_CENTER)
GUICtrlSetFont($TagsPageC, 9, 400, 4)
GUICtrlSetColor($TagsPageC, 0x0000ff)
GUICtrlSetCursor($TagsPageC, 0)
$AboutC = GUICtrlCreateButton('About', 105, 177, 70, 20)
$PrefsC = GUICtrlCreateButton('FontSize', 175, 177, 70, 20)
$StatC = GUICtrlCreateButton('Plain Style', 245, 177, 70, 20)

$GUIActiveX = GUICtrlCreateObj($oRP, 10, 10, 400, 260)
GUICtrlSetPos($GUIActiveX, 10, 10, 300, 160)

With $oRP; Object tag pool
.OLEDrag()
.Font = 'Arial'
.text = "Hello - Au3 supports ActiveX components like the RICHTEXT thanks to SvenP" & @CRLF & 'Try write some text and quit to reload'
;.FileName = @ScriptDir & '\RichText.rtf'
;.BackColor = 0xff00
EndWith

GUISetState();Show GUI

While 1
$msg = GUIGetMsg()

Select
Case $msg = $GUI_EVENT_CLOSE
$oRP.SaveFile(@ScriptDir & "\RichText.rtf", 0)
ExitLoop
Case $msg = $TagsPageC
Run(@ComSpec & ' /c start http://www.myplugins.info/guids/typeinfo/typeinfo.php?clsid={3B7C8860-D78F-101B-B9B5-04021C009402}', '', @SW_HIDE)
Case $msg = $AboutC
$oRP.AboutBox()
Case $msg = $PrefsC
$oRP.SelFontSize = 12
Case $msg = $StatC
$oRP.SelBold = False
$oRP.SelItalic = False
$oRP.SelUnderline = False
$oRP.SelFontSize = 8
EndSelect
WEnd
GUIDelete()
EndFunc ;==>RichEditExample

But even directly copied from the Helpfile it got the error:

==> Only Object-type variables allowed in a "With" statement.:
With $oRP
With ^ ERROR

Even if i run the whole code from the Helpfile it runs the Example() Function

And then Gives out the MyError window twice. First Posted Image and then Posted Image

Whats the Error? i'm not able to fix it. I tried to comment out the with section (in the part of the help file), but then it didn't display any edit at all. And when i click on one of the buttons, it Crashes with the error

==> Variable must be of type "Object".:
$oRP.AboutBox()
$oRP^ ERROR

To se What i want to get in the end i'll provide this code:

$Form2 = GUICreate("Plan Creator", 410, 299, -1, -1, BitOr($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_SIZEBOX))
$MenuItem2 = GUICtrlCreateMenu("Datei")
$MenuItem4 = GUICtrlCreateMenuItem("Neu", $MenuItem2)
$MenuItem3 = GUICtrlCreateMenuItem("Speichern", $MenuItem2)
$MenuItem7 = GUICtrlCreateMenuItem("Öffnen", $MenuItem2)
$MenuItem8 = GUICtrlCreateMenuItem("Schließen", $MenuItem2)
$MenuItem1 = GUICtrlCreateMenu("Termine")
$MenuItem6 = GUICtrlCreateMenuItem("Termin hinzufügen", $MenuItem1)
$MenuItem5 = GUICtrlCreateMenu("Liste der Messdiener")
$MenuItem9 = GUICtrlCreateMenuItem("Anzeigen", $MenuItem5)
$MenuItem11 = GUICtrlCreateMenuItem("Exportieren", $MenuItem5)
$MenuItem10 = GUICtrlCreateMenuItem("Importieren", $MenuItem5)
$mainsize = WinGetClientSize("Plan Creator")
Global $Edit1 = GUICtrlCreateEdit("", 8, 8, $mainsize[0] - 15, $mainsize[1] - 15)
GUISetState(@SW_SHOW)
And all i want is $Edit1 to be with richtext. Edited by Reinhardt1julian
Link to comment
Share on other sites

  • Moderators

Reinhardt1julian,

You need to look at the GUIRichEdit UDF - not that very advanced example. This is the page you should be looking at. ;)

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

  • Moderators

Reinhardt1julian,

Here is a helper function I wrote some time ago to make using RichEdits a bit easier - they are tricky beasts and I try to avoid them as much as possible. ;)

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

Ok. Now i want to save it. I tried it with this code:

Func _speichern()
    $MyDocsFolder = "::{450D8FBA-AD25-11D0-98A8-0800361B1103}"
    $wohinexport = FileSaveDialog("Plan Speichern", $MyDocsFolder,"Rich Text Files (*rtf)", 2)
    _processWindow()
    _FileCreate($wohinexport & ".rtf")
    $file5 = FileOpen($wohinexport & ".rtf", 2)
    $wasinfile = GUICtrlRead($Edit1)
    FileWrite($wohinexport & ".rtf", $wasinfile)
    FileClose($file5)
    GUIDelete($Progressform)
EndFunc

But that wont work, it'll save a file with only a 0 in it. how can i get the text properly with bold and stuff?

Link to comment
Share on other sites

  • Moderators

Reinhardt1julian,

If you start using UDF functions you normally need to continue using UDF functions - the basic Autoit GUICtrl* functions only work with controls that were created with the native GUICtrlCreate* functions. :)

Can you find a suitable candidate in the _GUICtrlRichEdit_* functions to get the text of the RichEdit control you created with _GUICtrlRichEdit_Create? There is definitely one in there if you look. ;)

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

  • Moderators

Reinhardt1julian,

I have not worked much with RichEdits - as I mentioned above they are tricky things - so I cannot really help a great deal. Looking through the UDF, the _GUICtrlRichEdit_StreamToFile function looks like it might be worth a try - note you must have an .rtf extension to the file. ;)

Give it a go and see how you get on - and please let me know as well. :)

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

  • Moderators

Reinhardt1julian,

Excellent. When you have it all working, please post the script in the "Examples" section as RichEdits are not that well known - as you have found out they are not that easy to work with. :whistle:

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

How can i check is a variable contain something? Maybe i searched the wron keyword, but in the helpfile i can't find anything. I want to check if a path (outputtet by FileSaveDialog) already contans a file extention, if not it should add it.

EDIT: *Facepalm* Why don't i just google it...

Edited by Reinhardt1julian
Link to comment
Share on other sites

  • Moderators

Reinhardt1julian,

StringInStr will do that in simple cases: ;)

$sPath = "C:\AutoIt\Script"
If Not StringInStr($sPath, ".rtf") Then ; If there is NOT ".rtf" in the string
    $sPath &= ".rtf"  ; Add it to the end
EndIf
MsgBox(0, "Result", $sPath)

$sPath = "C:\AutoIt\Script.rtf"
If Not StringInStr($sPath, ".rtf") Then
    $sPath &= ".rtf"
EndIf
MsgBox(0, "Result", $sPath)

It gets more difficult if there is a possibility that there is a wrong extension that needs to be replaced - but that gets into StringRegExp territory and you do not want to go there yet. :D

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