I have a small program (console application) which displays the DateTimePicker control. When the modeless dialog box is displayed, I want it to show a specified month/day/year, not necessarily the current month/day/year. Is this possible to do? Below is a copy of my code. As soon as the dialog is displayed, the program jumps to the callback routine (DlgMain), where I attempt to set all zeros for the month/day/year. Any help would be appreciated.
-------------------------------------------------------------------------
program calendar
use dflogm
use dfwin
implicit none
include 'resource.fd'
integer reti
logical retl
type (dialog) dlg
type (T_MSG) mesg
type (T_SYSTEMTIME) st
external DlgMain,DlgCancelModeless
c Initialize Dialog
retl=dlginit(IDD_DIALOG1,dlg)
retl=DlgSetSub(dlg,IDCANCEL,DlgCancelModeless)
c Display Dialog
retl=dlgmodeless(dlg,SW_SHOW)
call DlgMain(dlg,-1,0)
do while (GetMessage (mesg,NULL,0,0))
if (DlgIsDlgMessage(mesg).eqv..false.) then
retl=TranslateMessage(mesg)
reti=DispatchMessage(mesg)
end if
end do
retl=DlgSendCtrlMessage(dlg,IDC_DATETIMEPICKER1,
+ DTM_GETSYSTEMTIME,0,LOC(st))
print *,'Day: ',st%wDay
print *,'Month: ',st%wMonth
print *,'Year: ',st%wYear
call dlgexit(dlg)
call DlgUninit(dlg)
call exit ( )
end
c Subroutine DlgMain
c This subroutine controls the main dialog box.
subroutine DlgMain(dlg,id,callbacktype)
use dflogm
use dfwin
implicit none
include 'resource.fd'
integer hWnd,id,callbacktype,reti
logical retl
type (dialog) dlg
type (T_SYSTEMTIME) st
c Trying to set all calendar data to zero - but this does not work, calandar still shows current date
hWnd=GetDlgItem(dlg%hWnd,IDC_DATETIMEPICKER1)
reti = SendMessage(GetDlgItem(dlg%hWnd, IDC_DATETIMEPICKER1 ),
+ MCM_SETCURSEL, 0, LOC(st))
return
end
c Subroutine DlgCancelModeless
c This subroutine is used when Cancel button is pushed in a
c modeless dialog box. Used to cancel current dialog and return
c to main menu.
subroutine DlgCancelModeless(dlg,id,callbacktype)
use dflogm
use dfwin
implicit none
include 'resource.fd'
integer id,callbacktype
logical retl
type (dialog) dlg
call PostQuitMessage(0)
return
end
-------------------------------------------------------------------------