Page 1 of 2

calendar not run ( DBLCLICK)

PostPosted: Sat May 20, 2023 5:11 pm
by Silvio.Falconi
I use a get to select date

@ nRow, 70 GET aGet[1] VAR ddatacambio SIZE 100,24 PIXEL OF oDlgSub;
BITMAP "date.bmp" ACTION ( Selecdata(@ddatacambio, aGet[1]),aGet[1]:refresh())

the calendar run but when I double click it not run
i.e. it doesn't close the dialog and it doesn't refresh the date in the get

Code: Select all  Expand view

#include "FiveWin.ch"
#include "calendar.ch"

Function SelecData(dFechaPres, oGet)

   local oDlg, oButton1, oButton2, oSayFecha, oCalendar
   local lOk := .f.
   local dFecha
   local aPoint := AdjustWnd(oGet, 97*2, 88*2)

    local nWd  := GetSysMetrics(0) * .20
    local nHt  := (GetSysMetrics(1) / 5 )

   IF Empty(dFechaPres)
      dFecha := Date()
   ELSE
      dFecha := dFechaPres
   ENDIF

   DEFINE DIALOG oDlg SIZE nWd, nHt   PIXEL TRUEPIXEL ;
   COLOR CLR_BLACK,  RGB( 245,245,235)  ;
   TITLE "Selezione data"

   oDlg:lHelpIcon = .f.
   *oDlg:SetFont(oApp():oFont)

   @ 0,1 CALENDAR oCalendar VAR dFecha ;
         SIZE 200, 170 OF oDlg ;
         DBLCLICK  ( lOk := .t., oDlg:End())
 *  oCalendar:SetFont(oApp():oFont)
   oCalendar:oCursor := TCursor():New(,'HAND')

   ACTIVATE DIALOG oDlg               ;
      ON PAINT ( oDlg:Move(aPoint[1], aPoint[2],,,.t.), ;
                 oCalendar:SetFocus(.t.) )

   if lOK
      oGet:cText( oCalendar:dDate )
      sysrefresh()
   endif

return NIL
function AdjustWnd( oBtn, nWidth, nHeight )

   local nMaxWidth, nMaxHeight
   local aPoint

   aPoint := { oBtn:nTop + oBtn:nHeight(), oBtn:nLeft }
   clientToScreen( oBtn:oWnd:hWnd, @aPoint )

   nMaxWidth  := GetSysMetrics(0)
   nMaxHeight := GetSysMetrics(1)

   if  aPoint[2] + nWidth > nMaxWidth
      aPoint[2] := nMaxWidth -  nWidth
   endif

   if  aPoint[1] + nHeight > nMaxHeight
      aPoint[1] := nMaxHeight - nHeight
   endif

   return aPoint

 

Re: calendar not run ( DBLCLICK)

PostPosted: Sat May 20, 2023 5:42 pm
by Jimmy
hi Silvio,

try
Code: Select all  Expand view
  DBLCLICK MsgInfo( oCalendar:GetDate() ) ;

Re: calendar not run ( DBLCLICK)

PostPosted: Sat May 20, 2023 5:56 pm
by karinha

Re: calendar not run ( DBLCLICK)

PostPosted: Sat May 20, 2023 7:10 pm
by Silvio.Falconi


I not understood How resolve it
no entendi como solucionarlo


this is the test
Code: Select all  Expand view


#include "FiveWin.ch"
#include "calendar.ch"



Function Test()
   local oFont,oBold
   local oDlgSub,oBarSub
   local nRecord
   local oBtnAnnulla,oBtnAiuto,oBtnConferma
   local oCursorBtn :=TCursor():New(,'HAND')

   local nWd  := GetSysMetrics(0) * .35
   local nHt  := (GetSysMetrics(1) / 5 )

   local ddatacambio:=ctod("  /  /  "),cGiorno:="",nCambio:=""

   local nRow:= 0,nCol:= 10
   local nInterlinea := 30
   local oBtnGetExchange
   local cMoneta_azienda:="EUR"

   local oSay:=array(2)
   local aGet:=array(2)

   oFont := TFont():New( "Tahoma", 0, 14,, )
   oBold := TFont():New( "Tahoma", 0, 14,,.t. )

   DEFINE DIALOG oDlgSub SIZE nWd, nHt   PIXEL TRUEPIXEL ;
   COLOR CLR_BLACK,  RGB( 245,245,235)  FONT oFont  ;
   TITLE "test"


   nRow+=8
   @ nRow, 10 SAY oSay[1] PROMPT  "Data " SIZE 100,25  PIXEL OF oDlgSub  TRANSPARENT  FONT oFont
   nRow-=2
   @ nRow, 70 GET aGet[1] VAR ddatacambio SIZE 100,24 PIXEL OF oDlgSub;
      BITMAP "CALEND" ACTION ( SelecFecha(@ddatacambio, aGet[1]),aGet[1]:refresh())


ACTIVATE DIALOG oDlgSub CENTER
return nil
//---------------------------------------------------------------------------------//


Function SelecFecha(dFechaPres, oGet)

   local oDlg,  oSayFecha, oCalendar
   local lOk := .f.
   local dFecha
   local aPoint := AdjustWnd(oGet, 97*2, 88*2)

    local nWd  := GetSysMetrics(0) * .18
    local nHt  := (GetSysMetrics(1) / 5 )

   IF Empty(dFechaPres)
      dFecha := Date()
   ELSE
      dFecha := dFechaPres
   ENDIF

   DEFINE DIALOG oDlg SIZE nWd, nHt   PIXEL TRUEPIXEL ;
   COLOR CLR_BLACK,  RGB( 245,245,235)  ;
   TITLE "Selezione data"
   oDlg:lHelpIcon = .f.

   @ 0,1 CALENDAR oCalendar VAR dFecha ;
         SIZE 200, 170 OF oDlg    ;
         DBLCLICK ( MsgInfo('Dobleclick'), lOk := .T., oDlg:End() )

        oCalendar:bLDblClick := {|| ( MsgInfo('Dobleclick'), lOk := .T., oDlg:End() ) }
       oCalendar:oCursor := TCursor():New(,'HAND')

   ACTIVATE DIALOG oDlg               ;
      ON PAINT ( oDlg:Move(aPoint[1], aPoint[2],,,.t.), ;
                 oCalendar:SetFocus(.t.) )

   if lOK
      oGet:cText( oCalendar:dDate )
      sysrefresh()
   endif

   return NIL

     function AdjustWnd( oBtn, nWidth, nHeight )

   local nMaxWidth, nMaxHeight
   local aPoint

   aPoint := { oBtn:nTop + oBtn:nHeight(), oBtn:nLeft }
   clientToScreen( oBtn:oWnd:hWnd, @aPoint )

   nMaxWidth  := GetSysMetrics(0)
   nMaxHeight := GetSysMetrics(1)

   if  aPoint[2] + nWidth > nMaxWidth
      aPoint[2] := nMaxWidth -  nWidth
   endif

   if  aPoint[1] + nHeight > nMaxHeight
      aPoint[1] := nMaxHeight - nHeight
   endif

   return aPoint

 


¿Funciona para ti?
does it work for you?

Re: calendar not run ( DBLCLICK)

PostPosted: Sat May 20, 2023 7:30 pm
by karinha
What I understood in the topic is that you need to report the problem to Master Antônio, so he can send an update. Explain the problem to Liñares, please.

Lo que entendí en el tema es que debe informar el problema al maestro Antônio para que envíe una actualización. Explíquele el problema a Liñares, por favor.

Regards, saludos.

Re: calendar not run ( DBLCLICK)

PostPosted: Sat May 20, 2023 8:18 pm
by Jimmy
hi Silvio,

you use the wrong Control ;)
you have to use DTPICKER instead of CALENDAR :!:

in CLASS TCALENDAR is
Code: Select all  Expand view
METHOD HandleEvent() VIRTUAL

which "disable" Event like to "close" it ... i don´t understand "why" ...

CALENDAR can show more the 1 Month
Image
you can "mark" DateStart to DateEnd so you do not need 2 x DTPICKER

p.s. as CLASS TCALENDAR seem not "hardcode" somewhere else you can make a copy and delete METHOD HandleEvent()

Re: calendar not run ( DBLCLICK)

PostPosted: Sun May 21, 2023 11:26 am
by Silvio.Falconi
Jimmy,

if i use datepick instead of calendar then i don't get empty date.

why do i need the date to be empty?

because I have to lock the btnbmp control in fact the btnbmp control is active only when the data field is not empty.

Do you understand now why I have to use a control other than datepick?

Re: calendar not run ( DBLCLICK)

PostPosted: Sun May 21, 2023 4:45 pm
by Silvio.Falconi
Please someone can tell me where is the error ?
I need to use tcalendar and not datepick because I need the empty date on the get


Image


Code: Select all  Expand view
#include "FiveWin.ch"
#include "calendar.ch"



Function Test()
   local oFont,oBold
   local oDlgSub,oBarSub
   local nRecord
   local oBtnAnnulla,oBtnAiuto,oBtnConferma
   local oCursorBtn :=TCursor():New(,'HAND')

   local nWd  := GetSysMetrics(0) * .35
   local nHt  := (GetSysMetrics(1) / 5 )

   local ddatacambio:=ctod("  /  /  "),cGiorno:="",nCambio:=""

   local nRow:= 0,nCol:= 10
   local nInterlinea := 30
   local oBtnGetExchange
   local cMoneta_azienda:="EUR"

   local oSay:=array(2)
   local aGet:=array(2)

   oFont := TFont():New( "Tahoma", 0, 14,, )
   oBold := TFont():New( "Tahoma", 0, 14,,.t. )

   DEFINE DIALOG oDlgSub SIZE nWd, nHt   PIXEL TRUEPIXEL ;
   COLOR CLR_BLACK,  RGB( 245,245,235)  FONT oFont  ;
   TITLE "test"


   nRow+=8
   @ nRow, 10 SAY oSay[1] PROMPT  "Data " SIZE 100,25  PIXEL OF oDlgSub  TRANSPARENT  FONT oFont
   nRow-=2
   @ nRow, 70 GET aGet[1] VAR ddatacambio SIZE 100,24 PIXEL OF oDlgSub;
      BITMAP "CALEND" ACTION ( SelecFecha(@ddatacambio, aGet[1]),aGet[1]:refresh())


ACTIVATE DIALOG oDlgSub CENTER
return nil
//---------------------------------------------------------------------------------//


Function SelecFecha(dFechaPres, oGet)

   local oDlg,  oSayFecha, oCalendar
   local lOk := .f.
   local dFecha
   local aPoint := AdjustWnd(oGet, 97*2, 88*2)

    local nWd  := (GetSysMetrics(0) * .18) -30
    local nHt  := (GetSysMetrics(1) / 4 )-20

   IF Empty(dFechaPres)
      dFecha := Date()
   ELSE
      dFecha := dFechaPres
   ENDIF

   DEFINE DIALOG oDlg SIZE nWd, nHt   PIXEL TRUEPIXEL ;
   COLOR CLR_BLACK,  RGB( 245,245,235)  ;
   TITLE "Selezione data"
   oDlg:lHelpIcon = .f.

   @ 0,1 CALENDAR oCalendar VAR dFecha ;
         SIZE 200, 200 OF oDlg
        * DBLCLICK ( MsgInfo('Dobleclick'), lOk := .T., oDlg:End() )

        oCalendar:bLDblClick := {|| ( MsgInfo('Dobleclick'), lOk := .T., oDlg:End() ) }
       oCalendar:oCursor := TCursor():New(,'HAND')

   ACTIVATE DIALOG oDlg               ;
      ON PAINT ( oDlg:Move(aPoint[1], aPoint[2],,,.t.), ;
                 oCalendar:SetFocus(.t.) )

   if lOK
      oGet:cText( oCalendar:dDate )
      sysrefresh()
   endif

   return NIL

     function AdjustWnd( oBtn, nWidth, nHeight )

   local nMaxWidth, nMaxHeight
   local aPoint

   aPoint := { oBtn:nTop + oBtn:nHeight(), oBtn:nLeft }
   clientToScreen( oBtn:oWnd:hWnd, @aPoint )

   nMaxWidth  := GetSysMetrics(0)
   nMaxHeight := GetSysMetrics(1)

   if  aPoint[2] + nWidth > nMaxWidth
      aPoint[2] := nMaxWidth -  nWidth
   endif

   if  aPoint[1] + nHeight > nMaxHeight
      aPoint[1] := nMaxHeight - nHeight
   endif

   return aPoint

 

Re: calendar not run ( DBLCLICK)

PostPosted: Sun May 21, 2023 5:00 pm
by Jimmy
hi Silvio,

the "Error" is "by Concept" of TCalendar which have
METHOD HandleEvent ( ) VIRTUAL

so it will NOT react on Event like Dblclick or other :!:

you can make a copy of CLASS TCalendar(), modify and include it in you App

---

as you say you want a "empty" Input Field
but why do you "overlay" GET with Calendar / DTPicker when do "no Input yet" :?:

you can use a Button to "show" Calendar / DTPicker
you can use WHEN to "popup" Calendar / DTPicker

Re: calendar not run ( DBLCLICK)

PostPosted: Sun May 21, 2023 7:06 pm
by Silvio.Falconi
Jimmy wrote:hi Silvio,

the "Error" is "by Concept" of TCalendar which have
METHOD HandleEvent ( ) VIRTUAL

so it will NOT react on Event like Dblclick or other :!:

you can make a copy of CLASS TCalendar(), modify and include it in you App

---

as you say you want a "empty" Input Field
but why do you "overlay" GET with Calendar / DTPicker when do "no Input yet" :?:

you can use a Button to "show" Calendar / DTPicker
you can use WHEN to "popup" Calendar / DTPicker



>you can use a Button to "show" Calendar / DTPicker
>you can use WHEN to "popup" Calendar / DTPicker
As I allready explain U I not want use datepick


I add this
Code: Select all  Expand view
#define WM_MOUSELEAVE       675

METHOD HandleEvent( nMsg, nWParam, nLParam ) CLASS TCalendar

   if nMsg == WM_MOUSELEAVE
      return ::Super:MouseLeave( nHiWord( nLParam ), nLoWord( nLParam ), nWParam )
   endif


return ::Super:HandleEvent( nMsg, nWParam, nLParam )

but not run

Re: calendar not run ( DBLCLICK)

PostPosted: Sun May 21, 2023 7:50 pm
by Jimmy
hi Silvio,
Silvio.Falconi wrote:I add this
Code: Select all  Expand view
#define WM_MOUSELEAVE       675

METHOD HandleEvent( nMsg, nWParam, nLParam ) CLASS TCalendar

   if nMsg == WM_MOUSELEAVE
      return ::Super:MouseLeave( nHiWord( nLParam ), nLoWord( nLParam ), nWParam )
   endif


return ::Super:HandleEvent( nMsg, nWParam, nLParam )

but not run

how you did this :?:

i have made a copy and "disable" METHOD HandleEvent() to "react" on Event like VK_ESCAPE

Re: calendar not run ( DBLCLICK)

PostPosted: Sun May 21, 2023 8:08 pm
by Silvio.Falconi
METHOD HandleEvent( nMsg, nWParam, nLParam ) CLASS TCalendar

// TODO: Verify others messages

if nMsg==WM_LBUTTONUP
::Super:HandleEvent( nMsg, nWParam, nLParam )
endif
return nil



wich is the message for doubleclick ? ( wm_ ?)

Re: calendar not run ( DBLCLICK) - Resolved - !!!!!

PostPosted: Sun May 21, 2023 8:20 pm
by Silvio.Falconi
Resolved !!!! from Cristobal on December 2022 topic https://forums.fivetechsupport.com/viewtopic.php?f=6&t=42588&hilit=handleevent&sid=be8d4e36fad4faadc29be0a06fc6690c&sid=be8d4e36fad4faadc29be0a06fc6690c#p256286

Antonio, why not corrected it into fwh package ???


Code: Select all  Expand view
//METHOD HandleEvent()  VIRTUAL
   METHOD HandleEvent( nMsg, nWParam, nLParam )


Code: Select all  Expand view

METHOD HandleEvent( nMsg, nWParam, nLParam ) CLASS TCalendar

   Do Case

      case nMsg == WM_LBUTTONDOWN
           return ::LButtonDown( nHiWord( nLParam ), nLoWord( nLParam ), nWParam )

      case nMsg == WM_LBUTTONUP
           return ::LButtonUp( nHiWord( nLParam ), nLoWord( nLParam ), nWParam )

   EndCase

return ::Super:HandleEvent( nMsg, nWParam, nLParam )


on line 619 METHOD LButtonDown rem the called to isoverday
IF ! ::lDblClick //.and. IsOverDay( ::hWnd, nRow, nCol )
on line 651 METHOD LButtonUp rem the called to isoverday

Code: Select all  Expand view
IF ValType( ::nRowDbl ) == "N" /*.and. IsOverDay( ::hWnd, nRow, nCol )*/ .AND. ;
            Abs( ::nRowDbl - nRow  ) <= HEIGHTDBLCLICK .AND. Abs( ::nColDbl - nCol ) <= WIDTHDBLCLICK



run the DBLCLICK but then the calendar not run because I cannot change mounth or years

Re: calendar not run ( DBLCLICK) - Resolved - !!!!!

PostPosted: Mon May 22, 2023 6:12 am
by Antonio Linares
Dear Silvio,

> Antonio, why not corrected it into fwh package ???
> run the DBLCLICK but then the calendar not run because I cannot change mounth or years

You answered yourself

Try this:
Code: Select all  Expand view
METHOD HandleEvent( nMsg, nWParam, nLParam ) CLASS TCalendar

   Do Case

      case nMsg == WM_LBUTTONDOWN
           return ( ::LButtonDown( nHiWord( nLParam ), nLoWord( nLParam ), nWParam ), nil )

      case nMsg == WM_LBUTTONUP
           return ( ::LButtonUp( nHiWord( nLParam ), nLoWord( nLParam ), nWParam ), nil )

   EndCase

Re: calendar not run ( DBLCLICK)

PostPosted: Mon May 22, 2023 8:04 pm
by Jimmy
hi Antonio,

how to use those modification with CLASS TCalendar() :?:

do i make a copy of tcalenda.prg and include it in my App
or make a won CLASS FROM
or how to build new LIB with modify Source :?: