DatePicker Color & (big) Font

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
AUGE_OHR
Posts: 2061
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

DatePicker Color & (big) Font

Post by AUGE_OHR »

hi

based on Kevins Thread about MonthCalendar https://www.hmgforum.com/viewtopic.php?f=5&t=6607
i have play with c:\hmg.3.4.4\SAMPLES\Basics\TUTORIAL\TUTOR12.PRG DatePicker and found out that i can "re-size" Calender Part :o

when inspect Calender Part using WinID i recognize that it is a MONTHCAL_CLASS :idea:
so i try to get Color and (big) Font but it does not work ... wrong Handle

---

when press Button to Pop-Up Calender DTN_DROPDOWN Notify Event is fired
now DTM_GETMONTHCAL can be send to get MONTHCAL_CLASS handle

c:\hmg.3.4.4\SOURCE\h_windows.prg

Code: Select all

   * DatePicker Process ..................................
   if _HMG_SYSDATA [1] [i] = "DATEPICK"
      * DatePicker Change ............................
      If ( GetNotifyCode ( lParam ) == DTN_DATETIMECHANGE ...

// need add           
      If ( GetNotifyCode ( lParam ) == DTN_DROPDOWN
         nHwnd := SendMessage( _HMG_SYSDATA [ 3 ] [i] ,DTM_GETMONTHCAL,0,0 )
         SetWindowTheme(nHwnd,CHR(0),CHR(0))

         SendMessageA(nHwnd,MCM_SETCOLOR,MCSC_MONTHBK     , ::CalendarBackColor)
         SendMessageA(nHwnd,MCM_SETCOLOR,MCSC_TEXT        , ::CalendarForeColor)
         SendMessageA(nHwnd,MCM_SETCOLOR,MCSC_TITLEBK     , ::CalendarTitleBackColor)
         SendMessageA(nHwnd,MCM_SETCOLOR,MCSC_TITLETEXT   , ::CalendarTitleForeColor)
         SendMessageA(nHwnd,MCM_SETCOLOR,MCSC_TRAILINGTEXT, ::CalendarTrailingForeColor)

         // get Calender Coordinate
         GetWindowRect(nHwnd,@rcs)
         // new Size of Calender
         rcs[3] := (::oFont:width  *  30 )
         rcs[4] := (::oFont:height *  11 )

         hParent := GetParent(nHwnd)
         MoveWindow(hParent, rcs[1],rcs[2],rcs[3],rcs[4], .t.)
as you see in this "Dummy" Code i still have some "self" ( :: ) while i don´t know which _HMG_SYSDATA can hold the Data of Color and Font.

please help me to enhance DatePicker to use Color & (big) Font under HMG
DXE_Font.jpg
DXE_Font.jpg (57.72 KiB) Viewed 2776 times
have fun
Jimmy
User avatar
kcarmody
Posts: 152
Joined: Tue Oct 07, 2014 11:13 am
Contact:

Re: DatePicker Color & (big) Font

Post by kcarmody »

AUGE_OHR wrote: Sun Sep 20, 2020 9:47 pm based on Kevins Thread about MonthCalendar https://www.hmgforum.com/viewtopic.php?f=5&t=6607
i have play with c:\hmg.3.4.4\SAMPLES\Basics\TUTORIAL\TUTOR12.PRG DatePicker and found out that i can "re-size" Calender Part :o

when inspect Calender Part using WinID i recognize that it is a MONTHCAL_CLASS :idea:
so i try to get Color and (big) Font but it does not work ... wrong Handle
AUGE_OHR wrote: Sun Sep 20, 2020 9:47 pmplease help me to enhance DatePicker to use Color & (big) Font under HMG
This is interesting but confusing. First you say that you can resize the calendar part of a DatePicker. Then you say it did not work, posted pseudo-code, and asked for help.

Did you or did you not succeed in resizing the calendar part of the DatePicker in the PRG you cited? If so, please post the code that worked. If not, please state that you only tried. In that case, it might help if you posted the key part of the code that you tried.
User avatar
AUGE_OHR
Posts: 2061
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: DatePicker Color & (big) Font

Post by AUGE_OHR »

hi
kcarmody wrote: Mon Sep 21, 2020 1:20 am This is interesting but confusing. First you say that you can resize the calendar part of a DatePicker. Then you say it did not work, posted pseudo-code, and asked for help.

Did you or did you not succeed in resizing the calendar part of the DatePicker in the PRG you cited? If so, please post the code that worked. If not, please state that you only tried. In that case, it might help if you posted the key part of the code that you tried.
i have a working Xbase++ Solution but no HMG Solution

when use a Different Front Calender Part still have Original Size and a small Frame where you can use Mouse to re-Size
i have try to "maximize" Frame but did not find right Way

now it try to "SetSize" and use Font Size for calculation ...

Code: Select all

         // get Calender Coordinate
         GetWindowRect(nHwnd,@rcs)
         // new Size of Calender
         rcs[3] := (::oFont:width  *  30 )
         rcs[4] := (::oFont:height *  11 )
but how get Font Size under HMG :?:

Code: Select all

   _HMG_SYSDATA[ 27 ] [ k ] := fontname
   _HMG_SYSDATA[ 28 ] [ k ] := fontsize
   _HMG_SYSDATA[ 29 ] [ k ] := { bold, italic, underline, strikeout }
   _HMG_SYSDATA[ 36 ] [ k ] := FontHandle
i can see _HMG_SYSDATA[ 28 ] but that is not width/height of Font so how to get it :idea:

under Xbase++ it is a Font Object and have Member (DATA) width/height which my Xbase++ Code use.

---

other "Problem" is how to enhance #xcommand to use new Property for Color :idea:
have fun
Jimmy
User avatar
gfilatov
Posts: 1067
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: DatePicker Color & (big) Font

Post by gfilatov »

AUGE_OHR wrote: Sun Sep 20, 2020 9:47 pm hi
...
please help me to enhance DatePicker to use Color & (big) Font under HMG
Hi Jimmy,

Thanks for ALL your efforts :!:

I've done these modifications in the MiniGUI Ex core and a resull is showed below:
capture.png
capture.png (12.92 KiB) Viewed 2720 times
The sample source code is

Code: Select all

#include "minigui.ch"

Function Main
	Local ctrl

	SET CENTURY ON
	SET DATE GERMAN

	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 600 HEIGHT 400 ;
		TITLE "MiniGUI DatePicker Demo" ;
		MAIN ;
		FONT "Arial" SIZE 10

		DEFINE DATEPICKER Date_1
			ROW	10
			COL	10
			VALUE Date()
			TOOLTIP 'DatePicker Control' 
			SHOWNONE .F.
			TITLEBACKCOLOR {154,180,210}
			TITLEFONTCOLOR BLACK
			TRAILINGFONTCOLOR {100,100,130}
		END DATEPICKER

		@ 10,310 DATEPICKER Date_2 ;
		VALUE Date() ;
		TOOLTIP "DatePicker Control ShowNone RightAlign" ;
		SHOWNONE ;
		RIGHTALIGN

		@ 230,10 DATEPICKER Date_3 ;
		VALUE Date() ;
		TOOLTIP "DatePicker Control UpDown" ;
		UPDOWN

		@ 230,310 DATEPICKER Date_4 ;
		VALUE Date() ;
		TOOLTIP "DatePicker Control ShowNone UpDown" ;
		SHOWNONE ;
		UPDOWN

		ON KEY F2 ACTION ( ctrl := ThisWindow.FocusedControl, MsgInfo( Form_1.&ctrl..Value ) ) 

	END WINDOW

	Form_1.Date_1.FontColor := {0,228,255}
	Form_1.Date_1.BackColor := {0,0,254}

	CENTER WINDOW Form_1

	ACTIVATE WINDOW Form_1

Return Nil
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
kcarmody
Posts: 152
Joined: Tue Oct 07, 2014 11:13 am
Contact:

Re: DatePicker Color & (big) Font

Post by kcarmody »

gfilatov wrote: Mon Sep 21, 2020 9:58 am I've done these modifications in the MiniGUI Ex core
Thanks for pointing this out, Grigory. It's MiniGui, not HMG, but since MiniGui is a fork of HMG, there is much overlap between the sources, and it might be possible to put the MiniGui enhancements into HMG without much problem.
User avatar
kcarmody
Posts: 152
Joined: Tue Oct 07, 2014 11:13 am
Contact:

Re: DatePicker Color & (big) Font

Post by kcarmody »

AUGE_OHR wrote: Mon Sep 21, 2020 2:00 am i have a working Xbase++ Solution but no HMG Solution
Ah, XBase++, not HMG.
AUGE_OHR wrote: Mon Sep 21, 2020 2:00 am i can see _HMG_SYSDATA[ 28 ] but that is not width/height of Font so how to get it :idea:
It's possible that there are no entries in _HMG_SYSDATA for attributes of the calendar. You have probably already discovered that the entries you mention are only for the base line.
AUGE_OHR wrote: Mon Sep 21, 2020 2:00 am other "Problem" is how to enhance #xcommand to use new Property for Color :idea:
That's pretty simple once we have C and PRG code.
User avatar
AUGE_OHR
Posts: 2061
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: DatePicker Color & (big) Font

Post by AUGE_OHR »

hi,
gfilatov wrote: Mon Sep 21, 2020 9:58 am I've done these modifications in the MiniGUI Ex core and a resull is showed below:
have you found a Way to use big Font and "re-size" Calender :?:

i have try to calculate new Size but it seems to small

Code: Select all

   // Xbase++ using Ot4xb Syntax
      hDC := @user32:GetDC(::hMonthCal)
      cText    := "00 Mo Di Mi Do Fr Sa So"
      nWidth   :=  0
      nHeight  :=  0
      @GDI32:SelectObject( hDC , ::hFont_Active )
      GetTextExtents( hDC, cText, @nWidth, @nHeight )
      xFaktor := @Gdi32:GetDeviceCaps(hDC,LOGPIXELSX)
      yFaktor := @Gdi32:GetDeviceCaps(hDC,LOGPIXELSY)
      @user32:ReleaseDC( ::hMonthCal,hDC)
      hDC := 0
have fun
Jimmy
User avatar
kcarmody
Posts: 152
Joined: Tue Oct 07, 2014 11:13 am
Contact:

Re: DatePicker Color & (big) Font

Post by kcarmody »

gfilatov wrote: Mon Sep 21, 2020 9:58 am I've done these modifications in the MiniGUI Ex core and a resull is showed below:
I compiled the same code in the current version of MiniGui Ex and got this:
 
MiniGuiDatePickerDemo.png
MiniGuiDatePickerDemo.png (35.64 KiB) Viewed 2646 times

So your solution does work at least in Windows 7.

Just now I read that the calendar part of the date picker is created dynamically when you click the little icon and is destroyed when the calendar disappears.

https://stackoverflow.com/questions/361 ... er-control

This means that the handle to the calendar is not available when the date picker is created. It is only available while the calendar is active. This is why attempts to change any attributes of the calendar at the time of definition do not work. You have to get the handle during an event handler for the calendar. I don't see anything in either HMG or MiniGui Ex that does this.

MiniGui Ex has two date picker demos. Demo 1 is the only one that attempts to set colors of the calendar. Below is the code where this happens. As you can see, this demo does not attempt to set calendar colors in Vista or later.

Code: Select all

		DEFINE DATEPICKER Date_1
			ROW	10
			COL	10
			VALUE Date()
			TOOLTIP 'DatePicker Control' 
			SHOWNONE .F.
		IF ! ISVISTAORLATER()
			TITLEBACKCOLOR BLACK
			TITLEFONTCOLOR YELLOW
			TRAILINGFONTCOLOR PURPLE
		ENDIF
		END DATEPICKER
		...
	IF ! ISVISTAORLATER()
		Form_1.Date_1.FontColor := RED
		Form_1.Date_1.BackColor := YELLOW
	ENDIF
User avatar
AUGE_OHR
Posts: 2061
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: DatePicker Color & (big) Font

Post by AUGE_OHR »

hi,
kcarmody wrote: Mon Sep 21, 2020 9:08 pm Just now I read that the calendar part of the date picker is created dynamically when you click the little icon and is destroyed when the calendar disappears.
RIGHT :!:

as i say you need to grab DTN_DROPDOWN Notify Event when Button is press for Pop-Up Calender
than you can send DTM_GETMONTHCAL to geht MonthCalendar Handle
next is to disable visual Style

so you need to add this (for HMG using _HMG_SYSDATA )

Code: Select all

         If ( GetNotifyCode ( lParam ) == DTN_DROPDOWN
            nHwnd := SendMessage( _HMG_SYSDATA [ 3 ] [i] ,DTM_GETMONTHCAL,0,0 )
            SetWindowTheme(nHwnd,CHR(0),CHR(0))
in

Code: Select all

HMG c:\hmg.3.4.4\SOURCE\h_windows.prg

      IF _HMG_SYSDATA[ 1 ] [ i ] = "DATEPICK"
            //  DatePicker Change ............................

Code: Select all

Ext c:\MiniGUI\SOURCE\h_events.prg

      IF _HMG_aControlType [i] == "DATEPICK" .OR. _HMG_aControlType [i] == "TIMEPICK"
            // DatePicker Change ............................
---

in your Picture i "see" visual Style of Windows 7 so Color will not work.
have fun
Jimmy
User avatar
gfilatov
Posts: 1067
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: DatePicker Color & (big) Font

Post by gfilatov »

AUGE_OHR wrote: Mon Sep 21, 2020 7:44 pm hi,
gfilatov wrote: Mon Sep 21, 2020 9:58 am I've done these modifications in the MiniGUI Ex core and a resull is showed below:
have you found a Way to use big Font and "re-size" Calender :?:
...
Hi Jimmy,

Sure. Hint: take a look for the WinAPI C-function MonthCal_GetMinReqRect(hmonthcal, &rc) which will do a trick :idea:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
Post Reply