\
Tips and Tricks
User Interface Tips
Read Me dialogs (rtf formatted text in scrollable control)
| Read Me dialogs (rtf formatted text in scrollable control) |
You can put this code into a common header file and then define the name
of the file containing the readme in the macro "READMEDLG_TEXT_FILE":
;--- Does the user want a readme dialog (if so they have told us the filename)? ---
#ifdef READMEDLG_TEXT_FILE
;--- Define the version number of this tip ------------------------------
#define READMEDLG_VERSION 10.116
;--- Define some defaults -----------------------------------------------
#define? READMEDLG_TEXT_TITLE Read Me
#define? READMEDLG_TEXT_DESCRIPTION Some important information, please read it before continuing...
#ifndef READMEDLG_INSERT
;--- User hasn't defined the "Dialog" commands "INSERT" parameter ---
#ifdef REMOVED_LicenseAgreementDlg ;;Only exists if the dialog has been removed...
#define? READMEDLG_INSERT WelcomeDlg
#else
#define? READMEDLG_INSERT LicenseAgreementDlg
#endif
#endif
;--- User has specified the name of a readme file so read it into a vbscript string format ---
#DefineRexx ''
;--- Make sure the licence file exists -------------------------------
@@ReadMeFile = FindFile("<$READMEDLG_TEXT_FILE>")
if @@ReadMeFile = '' then
Error('We could not find the readme file "<$READMEDLG_TEXT_FILE>"');
;--- Read the information --------------------------------------------
call FileClose @@ReadMeFile, 'N';
@@Text = charin(@@ReadMeFile,1, 999999);
call FileClose @@ReadMeFile;
;--- Create a VB string (including the outer quotes) -----------------
@@VbStr = ReplaceString(@@Text, '"', '""');
@@VbStr = ReplaceString(@@VbStr, '00'x, ' '); ;;God knows why the trailing null exists...
@@VbStr = ReplaceString(@@VbStr, '0D'x, '" & vbCR & "');
@@VbStr = ReplaceString(@@VbStr, '0A'x, '" & vbLF & "');
@@VbStr = '"' || @@VbStr || '"' ;;Add the outer quotes
#DefineRexx
;--- Create an empty dialog at configured location (but with normal buttons etc) ---
<$Dialog "<$READMEDLG_TEXT_TITLE>" Description="<$READMEDLG_TEXT_DESCRIPTION>" INSERT="<$READMEDLG_INSERT>" Dialog="ReadMeDlg">
<$/Dialog>
;--- Now insert out controls by "hand" (can cheat by copying from other dialogs) ---
<$Table "Control">
;--- Add the readme control ---------------------------------------------
#(
<$Row
Dialog_="ReadMeDlg"
Control="ReadMeRtfText"
Type="ScrollableText"
X="20"
Y="60"
Width="330"
Height="120"
Attributes="7"
Property=""
*Text=^<??@@VbStr>^ ;;Use the VBSCRIPT string we created above
Control_Next="Back" ;;Finish the control chain ("BannerBitmap" points there now, fixed below)
Help=""
>
#)
;--------------------------------------------------------------------------
;--- The "ReadMeDlg" started "empty" so "BannerBitmap" points to "Back" ---
;--- * We will need to point it to our first control ---
;--- * Our last control needs to point to "Back" ---
;--------------------------------------------------------------------------
#(
<$Row
@Where="`Dialog_` = 'ReadMeDlg' AND `Control` = 'BannerBitmap'"
@OK='=1'
Control_Next="ReadMeRtfText" ;;Previous value = Back, this points to the first control we add to the empty dialog
>
#)
<$/Table>
#endif