Hey all,
I've put together a realtime HTML editor kind of thing, not for any other reason than to practice some coding. Here's the snippet if anyone wants it.
// COMPILE_OPTS|D:\Users\d692908\Documents\Macro Scheduler 14\website.exe||CONSOLE=0|INCLUDES=1||RUNTIMES=1|BMPS=1
Let>FileSaved=False
Dialog>MainMenu
object MainMenu: TForm
Left = 3533
Top = 152
HelpContext = 5000
BorderIcons = [biSystemMenu, biMaximize]
Caption = 'Web-Preview'
ClientHeight = 337
ClientWidth = 680
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
Menu = MainMenu
OldCreateOrder = True
Position = poScreenCenter
ShowHint = True
OnTaskBar = False
DesignSize = (
680
337)
PixelsPerInch = 96
TextHeight = 13
object HTML: tMSMemo
Left = 8
Top = 8
Width = 289
Height = 321
Text = '<!DOCTYPE html>'#13#10'<html>'#13#10'<body>'#13#10#13#10'</body>'#13#10'</html>'
ScrollBars = ssBoth
Anchors = [akLeft, akTop, akBottom]
TabOrder = 0
end
object Website: tMSHTMLViewer
Left = 304
Top = 8
Width = 368
Height = 317
TabOrder = 1
Anchors = [akLeft, akTop, akRight, akBottom]
BorderStyle = htFocused
DefFontName = 'Times New Roman'
DefPreFontName = 'Courier New'
HistoryMaxCount = 0
NoSelect = False
PrintMarginBottom = 2.000000000000000000
PrintMarginLeft = 2.000000000000000000
PrintMarginRight = 2.000000000000000000
PrintMarginTop = 2.000000000000000000
PrintScale = 1.000000000000000000
end
object Browse: tMSButton
Left = 323
Top = 225
Width = 75
Height = 25
Caption = 'Browse'
TabOrder = 2
Visible = False
DoBrowse = False
InitialDir = 'C:\Users\%USER_NAME%\Desktop'
Filter = 'HTML Files (*.html) | *.HTML|All Files (*.*) | *.*'
BrowseStyle = fbSave
end
object Open: tMSButton
Left = 421
Top = 237
Width = 75
Height = 25
Caption = 'Open'
TabOrder = 3
Visible = False
DoBrowse = False
Filter = 'HTML Files (*.html) | *.HTML|All Files (*.*) | *.*'
BrowseStyle = fbOpen
end
object MainMenu: tMSMainMenu
object MenuItem1: tMSMenuItem
Caption = '&File'
object OpenMenu: tMSMenuItem
Caption = '&Open'
end
object SaveAs: tMSMenuItem
Caption = '&Save As'
end
object Close: tMSMenuItem
Caption = '&Close'
end
end
end
end
EndDialog>MainMenu
AddDialogHandler>MainMenu,HTML,OnChange,doCreateWebsite
AddDialogHandler>MainMenu,,onClose,doClose
AddDialogHandler>MainMenu,Close,onClick,doClose
AddDialogHandler>MainMenu,SaveAs,onClick,doSaveAs
AddDialogHandler>MainMenu,OpenMenu,onClick,doOpen
Show>MainMenu
Label>IdleLoop
Wait>.001
Goto>IdleLoop
LabelToVar>HTML1,varDefaultHTML
/*
HTML1:
<!DOCTYPE html>
<html>
<body>
</body>
</html>
*/
SRT>doCreateWebsite
GetDialogProperty>MainMenu,HTML,Text,varWebsiteText
SetDialogProperty>MainMenu,Website,HTML,varWebsiteText
If>FileSaved=True
SetDialogProperty>MainMenu,,Caption,Web-Preview - %varFilename%*
Endif
END>doCreateWebsite
SRT>doClose
Exit>0
END>doClose
SRT>doSaveAs
SetDialogProperty>MainMenu,Browse,Filename,*.html
SetDialogProperty>MainMenu,Browse,doBrowse,True
GetDialogProperty>MainMenu,Browse,Filename,varFilename
GetDialogProperty>MainMenu,HTML,Text,varWebsiteText
GetDialogProperty>MainMenu,,Caption,varWindowName
Position>html,varFilename,1,varHTMlExists,TRUE
If>varHTMlExists<1
ConCat>varFilename,.html
Endif
/*
IfFileExists>%varFilename%
Ask>%varFilename% already exists. Would you like to overwrite?,varFileExists
If>varFileExists=YES
DeleteFile>%varFilename%
WriteLn>%varFilename%,nWLNRes,varWebsiteText
Let>FileSaved=True
SetDialogProperty>MainMenu,,Caption,%varWindowName% - %varFilename%
Endif
Else
WriteLn>%varFilename%,nWLNRes,varWebsiteText
Let>FileSaved=True
SetDialogProperty>MainMenu,,Caption,%varWindowName% - %varFilename%
Endif
*/
IfFileExists>%varFilename%
DeleteFile>%varFilename%
Endif
WriteLn>%varFilename%,nWLNRes,varWebsiteText
Let>FileSaved=True
SetDialogProperty>MainMenu,,Caption,Web-Preview - %varFilename%
END>doSaveAs
SRT>doOpen
SetDialogProperty>MainMenu,Open,doBrowse,True
GetDialogProperty>MainMenu,Open,Filename,varFilename
GetDialogProperty>MainMenu,HTML,Text,varWebsiteText
ReadFile>varFilename,varHTML
If>varHTML=##NOFILE##
SetDialogProperty>MainMenu,HTML,Text,varWebsiteText
Else
SetDialogProperty>MainMenu,HTML,Text,varHTML
SetDialogProperty>MainMenu,,Caption,Web-Preview - %varFilename%
Endif
END>doOpen
View Snippet Page
Does anyone know a way to find the position of the text cursor in a memo box or even the highlighted text? I want to add a feature that would be similar to when you post on the forum - You highlight the text you want, click "insert colour" or something similar, and then the selected text would be surrounded by the required code.
Before: Hello world
After: <font color="red">Hello world</font>
Hope I've made this clear, but if not, let me know
Thanks in advance,
Dominic Fichera
Find selected text in Dialog Memo box
Moderators: Dorian (MJT support), JRL
-
- Pro Scripter
- Posts: 82
- Joined: Mon Mar 24, 2014 12:15 pm
Find selected text in Dialog Memo box
Hey all,
I've put together a realtime HTML editor kind of thing, not for any other reason than to practice some coding. Here's the snippet if anyone wants it.
View Snippet Page
Does anyone know a way to find the position of the text cursor in a memo box or even the highlighted text? I want to add a feature that would be similar to when you post on the forum - You highlight the text you want, click "insert colour" or something similar, and then the selected text would be surrounded by the required code.
Before: Hello world
After: <font color="red">Hello world</font>
Hope I've made this clear, but if not, let me know
Thanks in advance,
Dominic Fichera
I've put together a realtime HTML editor kind of thing, not for any other reason than to practice some coding. Here's the snippet if anyone wants it.
View Snippet Page
Does anyone know a way to find the position of the text cursor in a memo box or even the highlighted text? I want to add a feature that would be similar to when you post on the forum - You highlight the text you want, click "insert colour" or something similar, and then the selected text would be surrounded by the required code.
Before: Hello world
After: <font color="red">Hello world</font>
Hope I've made this clear, but if not, let me know
Thanks in advance,
Dominic Fichera
- Grovkillen
- Automation Wizard
- Posts: 1131
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
- Contact:
Re: Find selected text in Dialog Memo box
I would do a cut (ctrl + x) and then get the clipboard text, add surounding code, put the new text to clipboard, then do a paste (ctrl + v). This happens so fast that the user wouldn't notice it at all.
-
- Pro Scripter
- Posts: 82
- Joined: Mon Mar 24, 2014 12:15 pm
Re: Find selected text in Dialog Memo box
Hey Grovkillen,
Thanks for the response
The only problem with doing this is if I click a button to launch the SRT, it would take focus away from the memo box... and without focus on the memo box, it's not going to cut (CTRL+X) the highlighted text...
Perhaps is there a way to focus a dialog and THEN focus a particular object in that dialog? If there is such a thing, the cut would work
View Snippet Page
I've added some changes to the script that put in the "font changing" buttons to show you what I mean by losing focus.
Currently the script works if you manually copy the text you want to change and click the button... So, getting there slowly!
Thanks,
Dominic Fichera
Thanks for the response
The only problem with doing this is if I click a button to launch the SRT, it would take focus away from the memo box... and without focus on the memo box, it's not going to cut (CTRL+X) the highlighted text...
Perhaps is there a way to focus a dialog and THEN focus a particular object in that dialog? If there is such a thing, the cut would work
View Snippet Page
I've added some changes to the script that put in the "font changing" buttons to show you what I mean by losing focus.
Currently the script works if you manually copy the text you want to change and click the button... So, getting there slowly!
Thanks,
Dominic Fichera
Re: Find selected text in Dialog Memo box
Hi, you can get the focus back by using:
Code: Select all
SetDialogObjectFocus>Dialog Name, Object Name
-
- Pro Scripter
- Posts: 82
- Joined: Mon Mar 24, 2014 12:15 pm
Re: Find selected text in Dialog Memo box
That's perfect! Thanks hagchr!