Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dialog trouble launching macro
#1
[Edited to clarify question]

Hi,

I need to combine a number of (currently separate and working) variable-input interfaces (e.g. a list box, a input box and a date picker) onto one dialog (call it "Form")

I'm using a Smart Diag (if there's a better way, pls lemme know). The trouble I'm having is with launching the date picker macro as part of the diag. I currently have it launched from a button using "event" BN_CLICKED. Here are the problems:

1. If possible the date picker control should really be right on the diag "form" as opposed to a button which opens it.

2. Even using a button to launch, I get the date picker interface window only after closing the dialog Form. I've tried to run it from the Form function "case" in a sep thread, and tried flag 0x400 and a few other things w/o any luck.

Just using a test dialog with only one button, I call the date picker from the button click event (e.g. case mac "murFTP_call_date")

Here's the murFTP_call_date macro:

Code:
Copy      Help
str controls = "5 6"
str sb5C e6 t
SYSTEMTIME- t_st1 t_st2 t_st3 ;;we share these variables with the dialog procedure

if(!ShowDialog("murFTP_func_date" &murFTP_func_date)) ret
DATE d.fromsystemtime(t_st1) ;;convert to DATE (for easy display)
str s=d
t.time(d "%Y%m%d")

out t

And it's associated dialog/function murFTP_func_date:

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

def DTM_FIRST 0x1000
def DTM_GETSYSTEMTIME (DTM_FIRST + 1)
def DTM_SETSYSTEMTIME (DTM_FIRST + 2)

BEGIN DIALOG
0 "" 0x10C80A44 0x100 0 0 216 123 "murFTP: Enter Event Date"
1 Button 0x54030001 0x4 100 102 48 14 "OK"
2 Button 0x54030000 0x4 154 102 50 14 "Cancel"
3 SysDateTimePick32 0x54000000 0x204 76 52 68 16 ""
4 Static 0x54000000 0x0 6 10 106 22 "Press OK to use today's date or choose another date below."
END DIALOG
DIALOG EDITOR: "" 0x202000A "" ""

ret
messages
SYSTEMTIME- t_st1 t_st2 t_st3
sel message
    case WM_INITDIALOG
    DT_Init(hDlg lParam)
     here can be initialized using DTM_SETSYSTEMTIME
    ret 1
    case WM_DESTROY DT_DeleteData(hDlg)
    case WM_COMMAND goto messages2
ret
messages2
int ctrlid=wParam&0xFFFF; message=wParam>>16
sel wParam
    case IDOK
    DT_Ok hDlg
    SendMessage(id(3 hDlg) DTM_GETSYSTEMTIME 0 &t_st1)
    SendMessage(id(4 hDlg) DTM_GETSYSTEMTIME 0 &t_st2)
    SendMessage(id(5 hDlg) DTM_GETSYSTEMTIME 0 &t_st3)
    
    case IDCANCEL DT_Cancel hDlg
ret 1

As I said earlier, I'd rather not even launch it with a button but rather have the date picker directly on the dialog/form.



Any advice is much appreciated!

Steve
#2
Place date picker control together with other controls in the same dialog. If it is difficult to program new date picker control, use the existing sample as a template, and add other controls to it.
#3
Function Form222
Code:
Copy      Help
;/Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

;BEGIN DIALOG
;0 "" 0x10C80A44 0x100 0 0 216 123 "murFTP: Enter Event Date"
;1 Button 0x54030001 0x4 100 102 48 14 "OK"
;2 Button 0x54030000 0x4 154 102 50 14 "Cancel"
;3 SysDateTimePick32 0x54000000 0x204 6 22 96 14 ""
;4 Static 0x54000000 0x0 150 72 106 22 "Press OK to use today's date or choose another date below."
;5 Edit 0x54030080 0x200 6 4 96 14 ""
;END DIALOG
;DIALOG EDITOR: "" 0x202000B "" ""


ret
;messages
SYSTEMTIME- t_st1
sel message
,case WM_INITDIALOG
,;here can be initialized using DTM_SETSYSTEMTIME
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,SendMessage(id(3 hDlg) DTM_GETSYSTEMTIME 0 &t_st1)
,
,case IDCANCEL
ret 1

Macro
Code:
Copy      Help
;variable for date
SYSTEMTIME- t_st1

;standard dialog code
str controls = "5"
str e5
if(!ShowDialog("Form222" &Form222 &controls)) ret

;convert date to string
str t
DATE d.fromsystemtime(t_st1) ;;convert to DATE (for easy display)
;str s=d

t.time(d "%Y%m%d")

;results
out e5
out t
#4
Thanks...yeah I don't know how I got stuck in my mind on doing it the hard way, when it was so bloody obvious. In the end I added the normal controls to the date picker like you suggested, but I'm gonna swap out the existing dt code for that above since it's w/o the extra baggage.

One more quick question...

Is there any way to not have a default (current) date displayed in the above DT combo control or make it required that something was actually chosen with the control (for instance: click the control to use today's date)?

I know it's usually convenient to have today's date as default, but I need to make sure that a date was actually chosen by human intervention and not by accidental default. These three input controls affect a lot of operations downstream that would be very hard to undo (file naming, html creation, ftp subdirs, uploading large files, notification emails etc...)

Thanks again,

s
#5
Add DTS_SHOWNONE style. Its value is 2. It adds a checkbox. On WM_INITDIALOG send DTM_SETSYSTEMTIME message with GDT_NONE flag. It unchecks the checkbox. If the checkbox is unchecked, DTM_GETSYSTEMTIME retuns not GDT_VALID. All this is documented in the MSDN Library.

Code:
Copy      Help
;/Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

;BEGIN DIALOG
;0 "" 0x10C80A44 0x100 0 0 216 123 "murFTP: Enter Event Date"
;1 Button 0x54030001 0x4 100 102 48 14 "OK"
;2 Button 0x54030000 0x4 154 102 50 14 "Cancel"
;3 SysDateTimePick32 0x54000002 0x204 6 22 96 14 ""
;4 Static 0x54000000 0x0 150 72 106 22 "Press OK to use today's date or choose another date below."
;5 Edit 0x54030080 0x200 6 4 96 14 ""
;END DIALOG
;DIALOG EDITOR: "" 0x202000B "" ""


ret
;messages
SYSTEMTIME- t_st1
sel message
,case WM_INITDIALOG
,;here can be initialized using DTM_SETSYSTEMTIME
,SendMessage(id(3 hDlg) DTM_SETSYSTEMTIME GDT_NONE 0)
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,if(SendMessage(id(3 hDlg) DTM_GETSYSTEMTIME 0 &t_st1)!=GDT_VALID) mes "please select date"; ret
,
,case IDCANCEL
ret 1
#6
Thanks for the ultra quick response and code.

And I'll add the MSDN library to the list of places to look for answers before bugging you...

S


Forum Jump:


Users browsing this thread: 1 Guest(s)