Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
setwintext against EditReplaceSel
#1
In the dialog which it follows the text in control 9 is displayed on the proper moment if EditReplaceSel is used. However, if setwintext is used the text is displayed after the 5sec delay. Any advice on this issue is mostly welcome.


Function Dialog53
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog"
;3 Button 0x54032000 0x0 11 7 48 14 "Button"
;9 Edit 0x54030880 0x200 10 29 203 12 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040700 "*" "" "" ""

str controls = "9"
str e9
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 3
,_s="Test Text"
;,_s.setwintext(id(9 hDlg))
;,www.quickmacros.com/forum/showthread.php?tid=6398&pid=31094&highlight=setwintext*#pid31094
;,DT_SetControl(hDlg 9 _s)
,EditReplaceSel(hDlg 9 _s 1)
,1
,mac "ClepsydraSPU"
,5
,shutdown -6 0 "ClepsydraSPU"
,
,
ret 1
#2
setwintext does not repaint the control, therefore it is repainted after the wait time. In dialogs don't use wait functions. Use SetTimer. If very very need to use a wait function, before it insert 'opt waitmsg 1'.
#3
Gintaras, many thanks for a clear, as always, explanation. Let me ask one more question. I am in need to wait, in this dialog, the execution of an .exe (fortran) program, previously launched in the dialog, as in the function which it follows :

Function tempf12
Code:
Copy      Help
#sub mcapip v
function hDlg

EnableWindow(id(76, hDlg) 0)    
ShowWindow(id(2, hDlg) SW_HIDE)    
_s=F"Collecting Spectrum : {d_spfile}"
;_s.setwintext(id(9 hDlg))
EditReplaceSel(hDlg 9 _s 1)

run F"{d_exe}\mcapip.exe" "" "" "" 16
mac "ClepsydraSPU"
;
;WaitFor
opt waitmsg -1
int waitmax=120
int wt(waitmax*1000) t1(GetTickCount)
int swb
rep
,1
,int pid=ProcessNameToId("mcapip.exe" 0)
,if pid<=0; break
,if(wt>0 and GetTickCount-t1>=wt)
,,_s="Wait Timeout"
,,;out "<>%s : <open ''%s /%i''>%s</open> - %s" NowT si _error.place si _s
,,;mac "Warning_QM"
,,swb=1
,,ret

shutdown -6 0 "ClepsydraSPU"
if swb
,_s.setwintext(id(9 hDlg))
else
,_s=F"Spectrum is now collected, in : {d_spfile}"
_s.setwintext(id(9 hDlg))
EnableWindow(id(1, hDlg) 1)    
EnableWindow(id(77, hDlg) 1)    
DT_SetButtonIcon hDlg t_il F"1=15 77=18"
ret

Can you, please, suggest a more efficient way to do this?

I have successfully replaced the waitfor loop using a SetTimer hDlg 2 10000 0 statemnt. I hope this improved it.Please advise.
#4
Macro Macro10
Code:
Copy      Help
\Dialog_Editor

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;4 Edit 0x54030080 0x200 8 8 96 12 ""
;3 Button 0x54032000 0x0 8 24 44 16 "Run"
;END DIALOG
;DIALOG EDITOR: "" 0x2040701 "*" "" "" ""

str controls = "4"
str e4
e4="notepad.exe"
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 3
,str sFile.getwintext(id(4 hDlg))
,
,int h=id(3 hDlg)
,EnableWindow h 0
,
,opt waitmsg 1 ;;process messages while waiting
,wait 0 H mac("sub.Thread" "" sFile) ;;run code in other thread and wait
,
,EnableWindow h 1
,case IDOK
,case IDCANCEL
ret 1


#sub Thread
function str'sFile

run sFile "" "" "" 0x400
#5
Dear Gintaras, I have now modified my routines according to your example. It is perfect! Many thanks once more. Best regrads.


Forum Jump:


Users browsing this thread: 1 Guest(s)