f



Month selector

Hi, i'm trying to show the window that appears when a user clicks on month using datetimepicker. For example, the user clicks on December 2016 and a window with these info is showed:

<        2016        >
jan   feb   mar   aprl
may   jun   jul   aug
sep   oct   nov   dec

but no luck with that. That window i need to show.
Can anyone help me with this? It's possible?
Thanks.
0
ccyasa
12/14/2016 3:33:38 PM
comp.clipper.visual-objects 12618 articles. 0 followers. Post Follow

12 Replies
363 Views

Similar Articles

[PageSpeed] 8

Hi   ??????

>  i'm trying to show the window that appears when
>  a user clicks on month using datetimepicker.
>  <      2016        >
>  jan   feb   mar   aprl
>  may   jun   jul   aug
>  sep   oct   nov   dec

Here´s the code to show the dropdown calendar  in month view. More view
options are mentioned below.

--------------

METHOD ControlNotify(oEvent) CLASS <YourWindowClass>
LOCAL pNMHDR AS _winNMHDR
LOCAL hMonthControl AS PTR

  DO CASE

  CASE DWORD ( oEvent:NotifyCode ) == DTN_DROPDOWN

         pNMHDR := PTR ( _CAST , oEvent:lParam )


         IF pNMHDR.hwndFrom == <oYourDTPicker>:Handle()

          hMonthControl := SendMessage(<oYourDTPicker>:Handle() ,
DTM_GETMONTHCAL , 0 , 0L )

          SendMessage( hMonthControl, MCM_SETCURRENTVIEW, 0 , MCMV_MONTH )

         ENDIF


  ENDCASE

  RETURN SUPER:ControlNotify(oEvent)

-------------
missing defines:
--------------

DEFINE MCM_SETCURRENTVIEW := MCM_FIRST + 32

DEFINE MCMV_CENTURY := 3
DEFINE MCMV_DAY := 0
DEFINE MCMV_DECADE := 2
DEFINE MCMV_MONTH := 1


Regards
Karl-Heinz 

0
Karl
12/14/2016 6:26:24 PM
El mi=C3=A9rcoles, 14 de diciembre de 2016, 15:26:29 (UTC-3), Karl-Heinz es=
cribi=C3=B3:
> Hi   ??????
>=20
> >  i'm trying to show the window that appears when
> >  a user clicks on month using datetimepicker.
> >  <      2016        >
> >  jan   feb   mar   aprl
> >  may   jun   jul   aug
> >  sep   oct   nov   dec
>=20
> Here=C2=B4s the code to show the dropdown calendar  in month view. More v=
iew
> options are mentioned below.
>=20
> --------------
>=20
> METHOD ControlNotify(oEvent) CLASS <YourWindowClass>
> LOCAL pNMHDR AS _winNMHDR
> LOCAL hMonthControl AS PTR
>=20
>   DO CASE
>=20
>   CASE DWORD ( oEvent:NotifyCode ) =3D=3D DTN_DROPDOWN
>=20
>          pNMHDR :=3D PTR ( _CAST , oEvent:lParam )
>=20
>=20
>          IF pNMHDR.hwndFrom =3D=3D <oYourDTPicker>:Handle()
>=20
>           hMonthControl :=3D SendMessage(<oYourDTPicker>:Handle() ,
> DTM_GETMONTHCAL , 0 , 0L )
>=20
>           SendMessage( hMonthControl, MCM_SETCURRENTVIEW, 0 , MCMV_MONTH =
)
>=20
>          ENDIF
>=20
>=20
>   ENDCASE
>=20
>   RETURN SUPER:ControlNotify(oEvent)
>=20
> -------------
> missing defines:
> --------------
>=20
> DEFINE MCM_SETCURRENTVIEW :=3D MCM_FIRST + 32
>=20
> DEFINE MCMV_CENTURY :=3D 3
> DEFINE MCMV_DAY :=3D 0
> DEFINE MCMV_DECADE :=3D 2
> DEFINE MCMV_MONTH :=3D 1
>=20
>=20
> Regards
> Karl-Heinz

Hi, thanks Karl, this is that i need.
Regards.

Sebasti=C3=A1n
0
ccyasa
12/14/2016 9:04:45 PM
El mi=C3=A9rcoles, 14 de diciembre de 2016, 15:26:29 (UTC-3), Karl-Heinz es=
cribi=C3=B3:
> Hi   ??????
>=20
> >  i'm trying to show the window that appears when
> >  a user clicks on month using datetimepicker.
> >  <      2016        >
> >  jan   feb   mar   aprl
> >  may   jun   jul   aug
> >  sep   oct   nov   dec
>=20
> Here=C2=B4s the code to show the dropdown calendar  in month view. More v=
iew
> options are mentioned below.
>=20
> --------------
>=20
> METHOD ControlNotify(oEvent) CLASS <YourWindowClass>
> LOCAL pNMHDR AS _winNMHDR
> LOCAL hMonthControl AS PTR
>=20
>   DO CASE
>=20
>   CASE DWORD ( oEvent:NotifyCode ) =3D=3D DTN_DROPDOWN
>=20
>          pNMHDR :=3D PTR ( _CAST , oEvent:lParam )
>=20
>=20
>          IF pNMHDR.hwndFrom =3D=3D <oYourDTPicker>:Handle()
>=20
>           hMonthControl :=3D SendMessage(<oYourDTPicker>:Handle() ,
> DTM_GETMONTHCAL , 0 , 0L )
>=20
>           SendMessage( hMonthControl, MCM_SETCURRENTVIEW, 0 , MCMV_MONTH =
)
>=20
>          ENDIF
>=20
>=20
>   ENDCASE
>=20
>   RETURN SUPER:ControlNotify(oEvent)
>=20
> -------------
> missing defines:
> --------------
>=20
> DEFINE MCM_SETCURRENTVIEW :=3D MCM_FIRST + 32
>=20
> DEFINE MCMV_CENTURY :=3D 3
> DEFINE MCMV_DAY :=3D 0
> DEFINE MCMV_DECADE :=3D 2
> DEFINE MCMV_MONTH :=3D 1
>=20
>=20
> Regards
> Karl-Heinz

The code works excellent, now i try to subclass DatimePicker as MonthSelect=
or and move the code to MonthSelector to avoid duplicate that code en every=
 window that i need this behaviour.
I try adapting the code in MonthSelector:Dispatch method without luck:

METHOD Dispatch(oEvent) CLASS MonthSelector

	LOCAL pNMHDR AS _winNMHDR
	LOCAL hMonthControl AS PTR

	IF (oEvent:Message =3D=3D WM_NOTIFY)
		pNMHDR:=3D PTR(_CAST, oEvent:lParam)
		IF (pNMHDR._code =3D=3D DTN_DROPDOWN)
			hMonthControl:=3D SendMessage(SELF:Handle(), DTM_GETMONTHCAL, 0, 0L)
			SendMessage(hMonthControl, MCM_SETCURRENTVIEW, 0, MCMV_MONTH)
		ENDIF
	ENDIF

	RETURN SUPER:Dispatch(oEvent)

Any hint?
Thanks.

Sebasti=C3=A1n
0
ccyasa
12/15/2016 12:47:33 PM
Hi Sebastian,

>
> METHOD Dispatch(oEvent) CLASS MonthSelector
>

on control level you don´t receive a DTN_DROPDOWN. What you can do is to use
a window base class ( assuming in the example that your DTPickers are
sitting on DataDialogs ) and a DTPicker class.

-----------------------------
CLASS BaseDataDialog INHERIT DataDialog

METHOD ControlNotify(oEvent) CLASS BaseDataDialog
LOCAL pnMHDR AS _winNMHDR
LOCAL oDP AS DateTimePicker


  DO CASE

  CASE DWORD ( oEvent:NotifyCode ) == DTN_DROPDOWN

         pnMHDR := PTR ( _CAST , oEvent:lParam )


         oDP := GetObjectByHandle ( pnMHDR.hwndFrom )


         IF oDP != NULL_OBJECT .AND. IsMethod ( oDP , #__SetView )
             Send ( oDP , #__SetView )

         ENDIF


  ENDCASE

  RETURN SUPER:ControlNotify(oEvent)

------------------------------------
the required DTPicker class
-----------------------------------

CLASS BaseDateTimePicker INHERIT DateTimePicker

PROTECT _nView := MCMV_DAY  AS INT   // Default is day-view


METHOD __SetView() CLASS BaseDateTimePicker
LOCAL hMonthControl AS PTR

    hMonthControl := SendMessage(SELF:Handle() , DTM_GETMONTHCAL , 0 , 0L )

    SendMessage( hMonthControl, MCM_SETCURRENTVIEW, 0 , _nView )


    RETURN SELF


ASSIGN View ( nView ) CLASS BaseDateTimePicker

// MCMV_CENTURY
// MCMV_DAY
// MCMV_DECADE
// MCMV_MONTH

    _nView := nView

    RETURN nView

----------

as long as you do not assign a value > MCMV_DAY to <oDP>:View,  the dropdown
calendar is shown in day-view.


regards
Karl-Heinz 

0
Karl
12/15/2016 5:25:21 PM
El jueves, 15 de diciembre de 2016, 14:25:21 (UTC-3), Karl-Heinz escribi=C3=
=B3:
> Hi Sebastian,
>=20
> >
> > METHOD Dispatch(oEvent) CLASS MonthSelector
> >
>=20
> on control level you don=C2=B4t receive a DTN_DROPDOWN. What you can do i=
s to use
> a window base class ( assuming in the example that your DTPickers are
> sitting on DataDialogs ) and a DTPicker class.
>=20
> -----------------------------
> CLASS BaseDataDialog INHERIT DataDialog
>=20
> METHOD ControlNotify(oEvent) CLASS BaseDataDialog
> LOCAL pnMHDR AS _winNMHDR
> LOCAL oDP AS DateTimePicker
>=20
>=20
>   DO CASE
>=20
>   CASE DWORD ( oEvent:NotifyCode ) =3D=3D DTN_DROPDOWN
>=20
>          pnMHDR :=3D PTR ( _CAST , oEvent:lParam )
>=20
>=20
>          oDP :=3D GetObjectByHandle ( pnMHDR.hwndFrom )
>=20
>=20
>          IF oDP !=3D NULL_OBJECT .AND. IsMethod ( oDP , #__SetView )
>              Send ( oDP , #__SetView )
>=20
>          ENDIF
>=20
>=20
>   ENDCASE
>=20
>   RETURN SUPER:ControlNotify(oEvent)
>=20
> ------------------------------------
> the required DTPicker class
> -----------------------------------
>=20
> CLASS BaseDateTimePicker INHERIT DateTimePicker
>=20
> PROTECT _nView :=3D MCMV_DAY  AS INT   // Default is day-view
>=20
>=20
> METHOD __SetView() CLASS BaseDateTimePicker
> LOCAL hMonthControl AS PTR
>=20
>     hMonthControl :=3D SendMessage(SELF:Handle() , DTM_GETMONTHCAL , 0 , =
0L )
>=20
>     SendMessage( hMonthControl, MCM_SETCURRENTVIEW, 0 , _nView )
>=20
>=20
>     RETURN SELF
>=20
>=20
> ASSIGN View ( nView ) CLASS BaseDateTimePicker
>=20
> // MCMV_CENTURY
> // MCMV_DAY
> // MCMV_DECADE
> // MCMV_MONTH
>=20
>     _nView :=3D nView
>=20
>     RETURN nView
>=20
> ----------
>=20
> as long as you do not assign a value > MCMV_DAY to <oDP>:View,  the dropd=
own
> calendar is shown in day-view.
>=20
>=20
> regards
> Karl-Heinz

Thanks Karl, something similar i have. I was trying to avoid subclass the w=
indows classes and encapsulate all the code in BaseDateTimePicker, i was th=
inking that i can check for that event inside this class.
Regards.

Sebasti=C3=A1n
0
ccyasa
12/15/2016 6:23:03 PM
Hi Sebastian,

here´s a cleaner ControlNotify  -  most of the time i´m on a pure Dispatch() 
trip ;-)


METHOD ControlNotify(oEvent) CLASS BaseDataDialog

  DO CASE

  CASE DWORD ( oEvent:NotifyCode ) == DTN_DROPDOWN

         IF oEvent:control != NULL_OBJECT .AND. IsMethod ( oEvent:control ,
#__SetView )
             Send ( oEvent:control , #__SetView )

         ENDIF


  ENDCASE

    RETURN SUPER:ControlNotify(oEvent)


regards
Karl-Heinz 

0
Karl
12/15/2016 6:24:47 PM
El jueves, 15 de diciembre de 2016, 15:25:54 (UTC-3), Karl-Heinz escribi=C3=
=B3:
> Hi Sebastian,
>=20
> here=C2=B4s a cleaner ControlNotify  -  most of the time i=C2=B4m on a pu=
re Dispatch()=20
> trip ;-)
>=20
>=20
> METHOD ControlNotify(oEvent) CLASS BaseDataDialog
>=20
>   DO CASE
>=20
>   CASE DWORD ( oEvent:NotifyCode ) =3D=3D DTN_DROPDOWN
>=20
>          IF oEvent:control !=3D NULL_OBJECT .AND. IsMethod ( oEvent:contr=
ol ,
> #__SetView )
>              Send ( oEvent:control , #__SetView )
>=20
>          ENDIF
>=20
>=20
>   ENDCASE
>=20
>     RETURN SUPER:ControlNotify(oEvent)
>=20
>=20
> regards
> Karl-Heinz

Yes, i see that. Thanks.
My mistake thinking that can i put all the code inside de subclass of DateT=
imePicker.
Regards.

Sebasti=C3=A1n
0
ccyasa
12/15/2016 6:34:18 PM
El jueves, 15 de diciembre de 2016, 15:25:54 (UTC-3), Karl-Heinz escribi=C3=
=B3:
> Hi Sebastian,
>=20
> here=C2=B4s a cleaner ControlNotify  -  most of the time i=C2=B4m on a pu=
re Dispatch()=20
> trip ;-)
>=20
>=20
> METHOD ControlNotify(oEvent) CLASS BaseDataDialog
>=20
>   DO CASE
>=20
>   CASE DWORD ( oEvent:NotifyCode ) =3D=3D DTN_DROPDOWN
>=20
>          IF oEvent:control !=3D NULL_OBJECT .AND. IsMethod ( oEvent:contr=
ol ,
> #__SetView )
>              Send ( oEvent:control , #__SetView )
>=20
>          ENDIF
>=20
>=20
>   ENDCASE
>=20
>     RETURN SUPER:ControlNotify(oEvent)
>=20
>=20
> regards
> Karl-Heinz

One last question, is there is any way to know if the user click on < >, th=
e year, or a month?

<        2016        >
jan   feb   mar   aprl
may   jun   jul   aug
sep   oct   nov   dec=20

Regards.

Sebasti=C3=A1n
0
ccyasa
12/17/2016 11:47:29 AM
Replying on message of Sat, 17 Dec 2016 03:47:29 -0800 (PST) from
ccyasa.sbassano@gmail.com:


 Hello Sebasti´┐Żn,

>One last question, is there is any way to know if the user click on < >, the year, or a month?


The MonthCalendar and DateTimePicker both inherit from the Control
Class. You can use the methods there  like dispatch, KeyUp, Keydown,
same for the mosue.

I found this in the NG in 2000, from  Frank Seidel on a question of
Jamal:

here's how I intercept date changes (should work regardless of the VO
version)

METHOD dispatch(oEvent) CLASS dlgResTermin
LOCAL ptrNMDateTimeChange AS _winNMDATETIMECHANGE
	
  //...
  CASE oEvent:Message == WM_NOTIFY
    IF oEvent:wParam ==  DTPICK_ID // DateTimePicker
      ptrNMDateTimeChange := PTR(_CAST, oEvent:lPARAM)
      IF ptrNMDateTimeChange.NMHDR._code == DTN_DATETIMECHANGE
        SELF:OnDateChange()
        RETURN 1L
      ENDIF
    ENDIF
  ENDCASE
RETURN SUPER:dispatch(oEvent)

Note that VO20 doesn't include the message and structure, so if you
wnat
to use it there you have to declare:

STRUCTURE NMDATETIMECHANGE
  MEMBER nmhdr IS _winNMHDR
  MEMBER dwFlags AS DWORD
  MEMBER st IS _winSYSTEMTIME

DEFINE DTN_FIRST := (0U-760U)
DEFINE DTN_DATETIMECHANGE := DTN_FIRST + 1

Jamal added:

I figured out the problem. VO is setting focus back the DTPicker on
every change event, this caused my dispatch message not to react
properly. I removed oDTPicker:SetFocus() from the
DateTimeSelectionChanged() method of the WINDOW class
and now all fine.

Should solve your problem I think.

Dick
0
D
12/18/2016 5:01:36 PM
Hi Sebastian,

>
> One last question, is there is any way to know if the user click on < >,
> the year, or a month?
>

I have no idea why you need that, but here´s a quick shot ...


BTW. The result shown in the owner caption should be one of the MCHT_xxx
constants described here:

https://msdn.microsoft.com/en-us/library/windows/desktop/bb760927(v=vs.85).aspx

-------------

METHOD Dispatch(oEvent) CLASS BaseDateTimepicker
LOCAL pnMHDR AS _winNMHDR
LOCAL hMonthControl AS PTR
LOCAL struMCHitTest IS _winMCHITTESTINFO
LOCAL struPoint IS _winPoint


  DO CASE

  CASE oEvent:Message == WM_NOTIFY

          pnMHDR := PTR ( _CAST , oEvent:lParam )


          IF pnMHDR._code == MCN_VIEWCHANGE  .OR. pnMHDR._code ==
MCN_SELCHANGE


           hMonthControl := SendMessage(SELF:Handle() , DTM_GETMONTHCAL , 0
, 0L )

         GetCursorPos ( @struPoint )
         ScreenToClient (hMonthControl , @struPoint )


              struMCHitTest.cbSize := _SIZEOF ( _winMCHITTESTINFO )
              struMCHitTest.pt := struPoint

              SendMessage ( hMonthControl , MCM_HITTEST , 0 , LONG ( _CAST ,
@struMCHitTest  ) )

              SELF:owner:caption := NTrim ( struMCHitTest.uHit  )


          ENDIF

  ENDCASE


    RETURN SUPER:Dispatch(oEvent)

----------

regards
Karl-Heinz 

0
Karl
12/19/2016 7:58:16 AM
El lunes, 19 de diciembre de 2016, 4:59:28 (UTC-3), Karl-Heinz  escribi=C3=
=B3:
> Hi Sebastian,
>=20
> >
> > One last question, is there is any way to know if the user click on < >=
,
> > the year, or a month?
> >
>=20
> I have no idea why you need that, but here=C2=B4s a quick shot ...
>=20
>=20
> BTW. The result shown in the owner caption should be one of the MCHT_xxx
> constants described here:
>=20
> https://msdn.microsoft.com/en-us/library/windows/desktop/bb760927(v=3Dvs.=
85).aspx
>=20
> -------------
>=20
> METHOD Dispatch(oEvent) CLASS BaseDateTimepicker
> LOCAL pnMHDR AS _winNMHDR
> LOCAL hMonthControl AS PTR
> LOCAL struMCHitTest IS _winMCHITTESTINFO
> LOCAL struPoint IS _winPoint
>=20
>=20
>   DO CASE
>=20
>   CASE oEvent:Message =3D=3D WM_NOTIFY
>=20
>           pnMHDR :=3D PTR ( _CAST , oEvent:lParam )
>=20
>=20
>           IF pnMHDR._code =3D=3D MCN_VIEWCHANGE  .OR. pnMHDR._code =3D=3D
> MCN_SELCHANGE
>=20
>=20
>            hMonthControl :=3D SendMessage(SELF:Handle() , DTM_GETMONTHCAL=
 , 0
> , 0L )
>=20
>          GetCursorPos ( @struPoint )
>          ScreenToClient (hMonthControl , @struPoint )
>=20
>=20
>               struMCHitTest.cbSize :=3D _SIZEOF ( _winMCHITTESTINFO )
>               struMCHitTest.pt :=3D struPoint
>=20
>               SendMessage ( hMonthControl , MCM_HITTEST , 0 , LONG ( _CAS=
T ,
> @struMCHitTest  ) )
>=20
>               SELF:owner:caption :=3D NTrim ( struMCHitTest.uHit  )
>=20
>=20
>           ENDIF
>=20
>   ENDCASE
>=20
>=20
>     RETURN SUPER:Dispatch(oEvent)
>=20
> ----------
>=20
> regards
> Karl-Heinz

Hi Karl =C2=BFwhich is the value for MCN_VIEWCHANGE? I find MCN_VIEWCHANGE =
=3D MCN_FIRST - 4 with MCN_FIRST =3D -746, but in Visual Objects MCN_FIRDT =
=3D -750, then MCN_VIEWCHANGE:=3D MCN_FIRST?
Thanks.
0
ccyasa
12/20/2016 7:39:26 PM
Hi Sebastian,

>
> MCN_VIEWCHANGE:= MCN_FIRST?
>

Yes, following the logic of existing MCN_xxx defines like

DEFINE MCN_SELCHANGE       := (MCN_FIRST + 1)

the Viewchange define is:

DEFINE  MCN_VIEWCHANGE := (MCN_FIRST + 0) 


regards
Karl-Heinz

0
Karl
12/21/2016 5:47:56 AM
Reply: