Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dialog Questions - Read-Only and Word Wrap
#15
It's a dialog that allows you to assign often used stock or custom phrases to tab after tab of buttons in the multipage dialog, that are then available for pasting into documents. The small button on each page of the dialog allow you to rename the buttons (i.e. to help you remember what phrase it brings up (displayed in the large text box).
This was kind of a simplified version for the purposes of the forum. I have customized it a lot since then but the xml part works awesomely (THanks Gintaras!!!) for storing the phrases as well as the button titles.

By the way, In this version, it puts your choices on the clipboard.

Enjoy,
Stuart


Function MultiTabPhraseFillerMacro
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

;BEGIN DIALOG
;0 "" 0x10C80A44 0x100 0 0 476 182 "MultiTabPhraseFillerMacro"
;1 Button 0x54030001 0x4 328 136 48 14 "OK"
;2 Button 0x54030000 0x4 386 136 48 14 "Cancel"
;4 Edit 0x54231044 0x200 272 16 202 112 ""
;6 Button 0x54012000 0x0 340 156 78 16 "Update Macro Text?"
;101 Button 0x54032000 0x0 6 18 117 14 ""
;102 Button 0x54032000 0x0 6 32 117 14 ""
;103 Button 0x54032300 0x0 6 46 117 14 ""
;104 Button 0x54032300 0x0 6 60 117 14 ""
;105 Button 0x54032000 0x0 6 74 117 14 ""
;106 Button 0x54032000 0x0 138 18 117 14 ""
;107 Button 0x54032000 0x0 138 32 117 14 ""
;108 Button 0x54032000 0x0 138 46 117 14 ""
;109 Button 0x54032000 0x0 138 60 117 14 ""
;110 Button 0x54032000 0x0 138 74 117 14 ""
;111 Button 0x54032000 0x0 6 100 117 14 ""
;112 Button 0x54032000 0x0 6 114 117 14 ""
;113 Button 0x54032000 0x0 6 128 117 14 ""
;114 Button 0x54032000 0x0 6 142 117 14 ""
;115 Button 0x54032000 0x0 6 156 117 14 ""
;116 Button 0x54032000 0x0 138 100 117 14 ""
;117 Button 0x54032000 0x0 138 114 117 14 ""
;118 Button 0x54032000 0x0 138 128 117 14 ""
;119 Button 0x54032000 0x0 138 142 117 14 ""
;120 Button 0x54032000 0x0 138 156 117 14 ""
;121 Button 0x54032000 0x0 123 18 10 14 ".."
;122 Button 0x54032000 0x0 123 32 10 14 ".."
;123 Button 0x54032000 0x0 123 46 10 14 ".."
;124 Button 0x54032000 0x0 123 60 10 14 ".."
;125 Button 0x54032000 0x0 123 74 10 14 ".."
;126 Button 0x54032000 0x0 255 18 10 14 ".."
;127 Button 0x54032000 0x0 255 32 10 14 ".."
;128 Button 0x54032000 0x0 255 46 10 14 ".."
;129 Button 0x54032000 0x0 255 60 10 14 ".."
;130 Button 0x54032000 0x0 255 74 10 14 ".."
;131 Button 0x54032000 0x0 123 100 10 14 ".."
;132 Button 0x54032000 0x0 123 114 10 14 ".."
;133 Button 0x54032000 0x0 123 128 10 14 ".."
;134 Button 0x54032000 0x0 123 142 10 14 ".."
;135 Button 0x54032000 0x0 123 156 10 14 ".."
;136 Button 0x54032000 0x0 255 100 10 14 ".."
;137 Button 0x54032000 0x0 255 114 10 14 ".."
;138 Button 0x54032000 0x0 255 128 10 14 ".."
;139 Button 0x54032000 0x0 255 142 10 14 ".."
;140 Button 0x54032000 0x0 255 156 10 14 ".."
;5 Static 0x54000010 0x20004 6 430 389 1 ""
;3 SysTabControl32 0x54000040 0x0 2 0 492 182 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030001 "" "0" ""

class CToolTip m_htt ;;delete this if already declared in init2

str controls = "4"
str e4

str-- tag ;;was MacroID

;load xml file
str-- xmlfile="$desktop$\SampleMacros.xml"
if(!dir(xmlfile)) _s="<SampleMacros></SampleMacros>"; _s.setfile(xmlfile) ;;first time, create new file with no data
IXml-- xml
xml=CreateXml
xml.FromFile(xmlfile)
IXmlNode-- xr=xml.RootElement ;;this will be often used
IXmlNode ne

if(!ShowDialog("MultiTabPhraseFillerMacro" &MultiTabPhraseFillerMacro &controls)) ret

e4.setclip
act win("Microsoft Word" "OpusApp")
'Ai;;menu for inserting comments into Word Doc
'm;;brings up a new comment dialog in Word
0.5
outp e4
ret
;messages
CToolTip-- tt ;;CToolTip variables usually can be declared with thread scope (- or --). If thread can have multiple instances of the same dialog, use window scope (SetProp/GetProp). Don't use global and local.
sel message
,case WM_INITDIALOG
,;tab control
,int i t htb=id(3 hDlg)
,TCITEM ti.mask=TCIF_TEXT
,str st="A[]B[]C[]D[]E[]F[]G[]H[]I[]J[]K[]L"
,foreach(ti.pszText st) SendMessage htb TCM_INSERTITEMA i &ti; i+1
,
,;tooltips
,tt.Create(hDlg)
,tt.AddTool(hDlg 4 "Text changes apply only for this comment insertion. To permanently change text, Choose Update Macro Text")
,for(i 121 141) tt.AddTool(hDlg i "Click to Change Button Text")
,
,t=0; goto g11 ;;select first tab
,case WM_DESTROY
,,tt.Destroy
,case WM_SETCURSOR
,,tt.OnWmSetcursor(wParam lParam)
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3
ret
;messages2
sel wParam
,case 6
,,if(!tag.len) ret
,,str NewMacroText
,,NewMacroText.getwintext(id(4 hDlg))
,,if(mes("Are you sure you want to permanently change macro text[](i.e. changes will also apply to future sessions)?" "Macro Text Change Confirmation" "OC?")!='O') ret
,,xr.SetChild(tag NewMacroText)
,,xml.ToFile(xmlfile)
,case else
,if(wParam>=101 and wParam<=140)
,,t=SendMessage(id(3 hDlg) TCM_GETCURSEL 0 0) ;;tab
,,
,,if(wParam>=101 and wParam<=120) ;;big button
,,,i=wParam-100
,,,tag.from("e" t*100+i)
,,,_s=xr.Child(tag).Value; err
,,,_s.setwintext(id(4 hDlg))
,,else ;;small [...] button
,,,wParam-20
,,,i=wParam-100
,,,tag.from("e" t*100+i)
,,,str OldButtonText NewButtonText ChangeText
,,,OldButtonText.getwintext(id(wParam hDlg))
,,,ChangeText.format("Change button text from ''%s'' to:" OldButtonText)
,,,if(!inp(NewButtonText ChangeText "Change Button Text" "Enter new button title here.....")) ret
,,,ne=xr.Child(tag); if(!ne) ne=xr.Add(tag)
,,,ne.SetAttribute("b" NewButtonText)
,,,xml.ToFile(xmlfile)
,,,NewButtonText.setwintext(id(wParam hDlg))
,case IDOK
,case IDCANCEL
ret 1
;messages3
NMHDR* nh=+lParam
sel nh.code
,case TCN_SELCHANGE
,t=SendMessage(nh.hwndFrom TCM_GETCURSEL 0 0)
,;g11
,;set text of buttons in this tab
,for i 1 21
,,NewButtonText=xr.Child(_s.from("e" t*100+i)).AttributeValue("b"); err NewButtonText=""
,,NewButtonText.setwintext(id(i+100 hDlg))
,;click first button to update tag and the textbox
,but 101 hDlg


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)