Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Smart Dialog Questions
#3
HI Gintaras,
I think I got it almost all down now. But even though it works, see below, it is giving me warning

Exception (RT) in OMultiTabPhraseFiller<: exception in destructors of local variables

I think this is from the calling the smart dialog from the smart dialog and returning the variables. It works however, so I don't know if I can just ignore that.

I added a rollup function which is real nice!
I also added a running comments dialog for inserting into new or pre-exisitng doc.
Thanks again!!
Stuart

Function MultiTabPhraseFiller
Trigger Wd     Help - how to add the trigger to the macro
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

;BEGIN DIALOG
;0 "" 0x10C80A44 0x100 0 0 476 182 "MultiTab PhraseFiller Macro"
;4 Edit 0x54231044 0x200 272 16 198 112 ""
;6 Button 0x54012000 0x0 282 160 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 ".."
;1001 Button 0x54032000 0x0 380 160 78 16 "View All Comments"
;1003 Button 0x54032000 0x0 448 0 28 12 "RollUp"
;1005 Button 0x54032000 0x0 274 132 46 22 "Paste into Document"
;1006 Button 0x54032000 0x0 322 132 46 22 "Insert as Comment"
;1007 Button 0x54032100 0x0 400 0 48 12 "Rename Tab"
;5 Static 0x54000010 0x20004 6 430 385 1 ""
;5 Static 0x54000010 0x20004 6 430 371 1 ""
;1004 Button 0x54032000 0x0 372 132 46 22 "Copy to Clipboard"
;1002 Button 0x54032000 0x0 420 132 46 22 "Undo"
;3 SysTabControl32 0x54000040 0x0 0 0 492 182 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030000 "" "0" ""

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

str controls = "0 4"
str t0 e4

Acc WinWordAcc=acc("Microsoft Word" "CLIENT" win("Microsoft Word" "OpusApp") "OpusApp" "" 0x1000)
str WinWordName=WinWordAcc.Name
t0.format("MultiTab PhraseFiller Macro:   %s" WinWordName)

str-- tag ;;was MacroID

;load xml file
str-- xmlfile="$Personal$\MultiTabPhraseFiller\MultiTabPhraseFillerMacros.xml"
if(!dir(xmlfile)) _s="<MultiTabPhraseFillerMacros></MultiTabPhraseFillerMacros>"; _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("MultiTabPhraseFiller" &MultiTabPhraseFiller &controls win("Word" "OpusApp"))) ret
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 IDOK
,,ifi(win("CommentPastCopyCancel" "#32770"))
,,,clo+ win("CommentPastCopyCancel" "#32770");err
,DT_GetControls hDlg &controls
,;e4.setclip
,;act win("Microsoft Word" "OpusApp")
,;int CaretX CaretY
,;GetCaretXY CaretX CaretY
,;out CaretX
,;out CaretY
,;'Aim;;menu for inserting comments into Word Doc
,;0.4
,;outp e4
,;0.1
,;'ZZ
,ret
,case IDCANCEL
,,ifi(win("CommentPastCopyCancel" "#32770"))
,,,clo+ win("CommentPastCopyCancel" "#32770");err
,case 6
,,ifi(win("CommentPastCopyCancel" "#32770"))
,,,clo+ win("CommentPastCopyCancel" "#32770");err    
,,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 1001
,,ifi(win("CommentPastCopyCancel" "#32770"))
,,,clo+ win("CommentPastCopyCancel" "#32770");err
,,mac "RunningCommentsDlg"
,case 1002
,,ifi(win("CommentPastCopyCancel" "#32770"))
,,,clo+ win("CommentPastCopyCancel" "#32770");err
,,act win("Microsoft Word" "OpusApp");err ret
,,'Cz;;undo
,case 1003
,,ifi(win("CommentPastCopyCancel" "#32770"))
,,,clo+ win("CommentPastCopyCancel" "#32770");err
,,Acc DlgTitleBarAcc=acc("" "TITLEBAR" win("MultiTab PhraseFiller Macro:" "#32770") "#32770" "MultiTab PhraseFiller Macro:" 0x1000)
,,str DlgTitleBarVal=DlgTitleBarAcc.Value
,,int cy; GetWinXY win("MultiTab PhraseFiller Macro:" "#32770") 0 0 0 cy
,,out cy
,,;DlgTitleBarAcc.Location(0 0 0 cy)
,,if cy> 100
,,,siz 0 50 win("MultiTab PhraseFiller Macro:" "#32770") 1
,,if cy<100
,,,siz 0 329 win("MultiTab PhraseFiller Macro:" "#32770") 1
,case 1004
,,ifi(win("CommentPastCopyCancel" "#32770"))
,,,clo+ win("CommentPastCopyCancel" "#32770");err
,,;Copy
,,str MacroFieldText.getwintext(id(4 hDlg))
,,MacroFieldText.setclip
,case 1005
,,ifi(win("CommentPastCopyCancel" "#32770"))
,,,clo+ win("CommentPastCopyCancel" "#32770");err
,,;Paste
,,int WinWordTextControl= child("Microsoft Word Document" "_WwG" win("Microsoft Word" "OpusApp") 0x1)
,,str SelectedText.getsel(0 0 WinWordTextControl)
,,if len(SelectedText) > 0
,,,str Overwrite.format("Overwrite selected text?[]''%s " SelectedText)
,,,if(mes(Overwrite "MultiTabPhraseFiller" "OC?")!='O') ret
,,MacroFieldText.getwintext(id(4 hDlg))
,,MacroFieldText.setclip
,,act win("Microsoft Word" "OpusApp")
,,outp MacroFieldText
,case 1006
,,ifi(win("CommentPastCopyCancel" "#32770"))
,,,clo+ win("CommentPastCopyCancel" "#32770");err
,,;Comment
,,MacroFieldText.getwintext(id(4 hDlg))
,,str RunningComments
,,str ClipPlusSpacer.format("%s[][]" MacroFieldText)
,,rget RunningComments "RunningComments" "RunningComments" "$Personal$\MultiTabPhraseFiller\Macros.ini";err
,,RunningComments.escape(0)
,,RunningComments.addline(ClipPlusSpacer)
,,RunningComments.escape(1)
,,rset RunningComments "RunningComments" "RunningComments" "$Personal$\MultiTabPhraseFiller\Macros.ini";err
,,act win("Microsoft Word" "OpusApp")
,,int CaretX CaretY
,,GetCaretXY CaretX CaretY
,,out CaretX
,,out CaretY
,,'Aim;;menu for inserting comments into Word Doc
,,0.4
,,outp MacroFieldText
,,lef CaretX CaretY
,case else
,ifi(win("CommentPastCopyCancel" "#32770"))
,,clo+ win("CommentPastCopyCancel" "#32770");err
,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))
,,,controls = "3 4 5 6"
,,,str c3Com c4Pas c5Cop c6Can
,,,;if(!ShowDialog("NumWinSelec" &NumWinSelec 0 0 0 0 0 0 x ym-100 "mouse.ico" )) ret
,,,int yc = -25
,,,int xc= 35
,,,int CPCE=ShowDialog("CommentPasteCopyCancel" &CommentPasteCopyCancel &controls 0 0 0 0 0 xc yc)
,,,out CPCE
,,,if CPCE=3
,,,,goto Comment
,,,if CPCE = 4
,,,,goto Paste
,,,if CPCE = 5
,,,,goto Copy
,,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))
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
,ifi(win("CommentPastCopyCancel" "#32770"))
,,clo win("CommentPastCopyCancel" "#32770")
,;but 101 hDlg
,

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

str controls = "3 4 8 6"
str b3 b4 e5 b6
str RunningCommentsText
rget RunningCommentsText "RunningComments" "RunningComments" "$Personal$\MultiTabPhraseFiller\Macros.ini";err;;EDEC = macro
RunningCommentsText.escape(0)


e5 = RunningCommentsText


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

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 499 320 "Radiology Editorial Board Running Comments (powered by Radfusion)"
;2 Button 0x54030000 0x4 200 288 102 18 "Close"
;3 Button 0x54032000 0x0 340 260 84 21 "Clear Running Comments"
;4 Button 0x54032000 0x0 74 260 90 21 "Save Running Comments to New File"
;6 Button 0x54032000 0x0 170 260 84 21 "Add Running Comments to Existing File"
;7 Button 0x54032000 0x0 256 260 82 21 "Copy Running Comments to Clipboard"
;8 Edit 0x54601844 0x0 10 6 482 244 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030000 "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 3
,,RunningCommentsText = ""    
,,rset RunningCommentsText "RunningComments" "RunningComments" "$Personal$\MultiTabPhraseFiller\Macros.ini";err
,,rget RunningCommentsText "RunningComments" "RunningComments" "$Personal$\MultiTabPhraseFiller\Macros.ini";err
,,RunningCommentsText.setwintext(id(8 hDlg))        
,case 4
,,str RunningCommentsFileName
,,if(!inp(RunningCommentsFileName "Please assign a filename for ''Running Comments''" "Radiology Editorial Board" "Enter filename here.... (don't need to add  ''.doc'')")) ret
,,out RunningCommentsFileName
,,RunningCommentsFileName.ReplaceInvalidFilenameCharacters("_")
,,out RunningCommentsFileName
,,str initdir = "$Personal$"
,,if OpenSaveDialog(1 RunningCommentsFileName "Word Documents[]*.doc; *.doc*[]All files[]*.*" "doc" initdir "Save Copy of Radiology Editorial Board ''Running Comments''")
,,,out RunningCommentsFileName
,,,rget RunningCommentsText "RunningComments" "RunningComments" "$Personal$\MultiTabPhraseFiller\Macros.ini";err;;EDEC = macro
,,,RunningCommentsText.escape(0)
,,,RunningCommentsText.setfile(RunningCommentsFileName 0 -1)
,,,run RunningCommentsFileName
,case 6
,,str ExistingRunningCommentsFileName
,,if OpenSaveDialog(0 ExistingRunningCommentsFileName "Word Documents[]*.doc; *.doc*[]All files[]*.*" "doc" initdir "Select existing ''Running Comments'' file")
,,,out ExistingRunningCommentsFileName
,,,rget RunningCommentsText "RunningComments" "RadEdBoardRunningComments" "$Personal$\MultiTabPhraseFiller\Macros.ini";err;;EDEC = macro
,,,RunningCommentsText.escape(0)
,,,RunningCommentsText.setfile(ExistingRunningCommentsFileName -1 -1)
,,,run ExistingRunningCommentsFileName    
,case 7
,,rget RunningCommentsText "RunningComments" "RunningComments" "$Personal$\MultiTabPhraseFiller\Macros.ini";err;;EDEC = macro
,,RunningCommentsText.escape(0)
,,RunningCommentsText.setclip
,case IDOK
,case IDCANCEL
ret 1

;

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



str controls = "3 4 5 6"
str  c3Com c4Pas c5Cop c6Can
;
int CPCE=ShowDialog("CommentPasteCopyCancel" &CommentPasteCopyCancel &controls)
out CPCE
ret CPCE

;BEGIN DIALOG
;0 "" 0x800010C0 0x0 0 0 84 16 "CommentPastCopyCancel"
;3 Button 0x54030088 0x0 0 0 20 16 "Comment"
;4 Button 0x54031083 0x0 20 0 20 16 "Paste"
;5 Button 0x54031083 0x0 40 0 22 16 "Copy"
;6 Button 0x54031083 0x0 62 0 22 16 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030000 "" "" ""

ret
;messages
CToolTip-- ttCCPE ;;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
,int CopyInt=qm.LoadPictureFile("$personal$\MultiTabPhraseFiller\Copy.bmp" 0) ;;loads bmp, gif or jpg.
,SendMessage(id(5 hDlg) BM_SETIMAGE IMAGE_BITMAP CopyInt)
,int CommentInt=qm.LoadPictureFile("$personal$\MultiTabPhraseFiller\Comment.bmp" 0) ;;loads bmp, gif or jpg.
,SendMessage(id(3 hDlg) BM_SETIMAGE IMAGE_BITMAP CommentInt)
,int PasteInt=qm.LoadPictureFile("$personal$\MultiTabPhraseFiller\Paste.bmp" 0) ;;loads bmp, gif or jpg.
,SendMessage(id(4 hDlg) BM_SETIMAGE IMAGE_BITMAP PasteInt)
,int CancelInt=qm.LoadPictureFile("$personal$\MultiTabPhraseFiller\Cancel.bmp" 0) ;;loads bmp, gif or jpg.
,SendMessage(id(6 hDlg) BM_SETIMAGE IMAGE_BITMAP CancelInt)
,;tooltips
,ttCCPE.Create(hDlg)
,ttCCPE.AddTool(hDlg 3 "Insert text as COMMENT")
,ttCCPE.AddTool(hDlg 4 "PASTE Text directly into Word main body text")
,ttCCPE.AddTool(hDlg 5 "COPY text to clipboard  (can manually paste into any location)")
,ttCCPE.AddTool(hDlg 6 "CANCEL")    
,ret 1
,case WM_DESTROY
,ttCCPE.Destroy
,for(_i 3 7) DeleteObject(SendMessage(id(_i hDlg) BM_SETIMAGE IMAGE_BITMAP 0))
,case WM_SETCURSOR
,,ttCCPE.OnWmSetcursor(wParam lParam)
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case [3,4,5,6]
,DT_Ok hDlg wParam


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)