Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Input window default action
#1
Hi Gintaras, hi all,

i have an input box to enter description if needed at firefox closing.

int ok=inp(_s "Enter description?" "Backup Description")

I can manage OK and Cancel button action.

I wish if i don't push any button or don't enter description at all for 5 sec,
i.e input box is not used for 5 sec, the inp closes on its own and do action
as if cancel was pressed (ok=0).

Any idea?

Thanks.
#2
This will be in next QM.
Function InputBox
Code:
Copy      Help
;/
function! str&inputText [flags] [$staticText] [$captionText] [hwndOwner] [x] [y] [int&checkVar] [$checkText] [timeoutS] [dlgProc] ;;flags: 1 on Cancel end macro, 2 use inputText as default, 4 multiline, 8 password, 16 digits, 32 button, 64 raw x y

;Shows input box (dialog).
;Returns: 1 OK, 0 Cancel.

;inputText - variable that receives text.
;flags - see above.
;staticText - text above the edit field.
;captionText - title bar text.
;hwndOwner - owner window handle. If not used, the dialog is always-on-top.
;x, y - dialog position in screen. By default, 0 is screen center, negative is from screen right or top.
;checkVar - variable that sets and receives check box value (0 or 1). If omitted or 0, does not show check box.
;checkText - check box text.
;timeoutS - max number of seconds to show the dialog if user does not type or click. On timeout the function returns 0.
;dlgProc - address of optional <help "::/User/IDH_DIALOG_EDITOR.html#A9">dialog procedure</help> function, like with smart dialogs.
;;;Flag 32 adds button [...], id 7. Then dlgProc can do something when user clicks it. By default the button does nothing.
;;;The function also can use the edit box (id 4) and other controls.

;REMARKS
;Uses <help>ShowDialog</help>.
;Supports <help>_monitor</help>.

;See also: <inp>.
;Added in: QM 2.3.5.

;EXAMPLES
;str s
;if(!InputBox(s 0 "Text:")) ret
;out s

;InputBox(_s 1 "The macro will end on Cancel.")

;_s="default"
;if(!InputBox(_s 2)) ret

;if(!InputBox(_s 0 "" "Input box at screen right-bottm" 0 -1 -1)) ret

;if(!InputBox(_s 0 "" "Input box with timeout" 0 0 0 0 "" 10)) ret


if(empty(captionText)) captionText="QM - Input"
str sStatic(staticText) sCaption(captionText) sCheck(checkText)
sStatic.escape(1); sCaption.escape(1); sCheck.escape(1)

int estDlg(0x10189) stEd(iif(flags&4 0x54231044 0x54030080)) stCh(0x44012003) wSt(212) wEd(208) stBt(0x44030000)
if(hwndOwner) estDlg~WS_EX_TOPMOST
if(flags&8) stEd|ES_PASSWORD
if(flags&16) stEd|ES_NUMBER
if(&checkVar) stCh|WS_VISIBLE
if(timeoutS) wSt-24
if(flags&32) stBt|WS_VISIBLE; wEd-16

str dd
if flags&4
,wSt+100; wEd+100
,dd=
F
;BEGIN DIALOG
;0 "" 0x90C80ACC 0x{estDlg} 0 0 323 217 "{sCaption}"
;3 Static 0x54000000 0x0 8 4 {wSt} 21 "{sStatic}"
;4 Edit 0x{stEd} 0x200 8 26 {wEd} 164 ""
;7 Button 0x{stBt} 0 300 26 16 14 "..."
;5 Button 0x{stCh} 0 8 196 98 16 "{sCheck}"
;6 Static 0x44000002 0x0 302 0 20 9 ""
;1 Button 0x54030001 0 214 198 48 14 "OK"
;2 Button 0x54030000 0 266 198 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030503 "" "" "" ""
else
,dd=
F
;BEGIN DIALOG
;0 "" 0x90C80ACC 0x{estDlg} 0 0 223 68 "{sCaption}"
;3 Static 0x54000000 0x0 8 4 {wSt} 21 "{sStatic}"
;4 Edit 0x{stEd} 0x200 8 26 {wEd} 14 ""
;7 Button 0x{stBt} 0 200 26 16 14 "..."
;5 Button 0x{stCh} 0 8 48 98 16 "{sCheck}"
;6 Static 0x44000002 0x0 202 0 20 9 ""
;1 Button 0x54030001 0 116 50 48 14 "OK"
;2 Button 0x54030000 0 168 50 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030503 "" "" "" ""

str controls = "4 5"
str e4 c5
if(flags&2) e4=inputText
if(&checkVar) c5=checkVar!0

if(!ShowDialog(dd &__IB_DlgProc &controls hwndOwner flags&64 0 0 &timeoutS x y))
,if(flags&1) end
,ret

inputText=e4
if(&checkVar) checkVar=val(c5)
ret 1
Function __IB_DlgProc
Code:
Copy      Help
;/
function# hDlg message wParam lParam

int* a=+DT_GetParam(hDlg)
sel message
,case WM_INITDIALOG
,if a[0]>0
,,hid- id(6 hDlg)
,,SetTimer hDlg 1 1000 0
,
,case WM_TIMER
,sel wParam
,,case 1
,,a[0]-1
,,if(a[0]>0) _s=a[0]; _s.setwintext(id(6 hDlg))
,,else KillTimer hDlg 1; DT_Cancel hDlg
,,ret 1
,
,case WM_SETCURSOR
,if(a[0]>0 and lParam>>16!WM_MOUSEMOVE) KillTimer hDlg 1; a[0]=0
,
,case WM_COMMAND
,if(a[0]>0 and wParam=EN_CHANGE<<16|4) KillTimer hDlg 1; a[0]=0

if(a[1]) ret CallWindowProc(a[1] hDlg message wParam lParam)
ret message=WM_COMMAND
#3
Thanks.


Forum Jump:


Users browsing this thread: 1 Guest(s)