Datepicker Refresh

HMG Samples and Enhancements

Moderator: Rathinagiri

Post Reply
rogerl
Posts: 38
Joined: Tue Nov 19, 2013 7:02 am

Datepicker Refresh

Post by rogerl »

Hi,
I'm back after being away some time!
I'm working through the HMG Wiki tutorial again and I'm currently trying the Data Controls II example. The only change I have made to the code in the tutorial is to remove the lines putting a PICTURE on each button (as I don't have the .bmp files), otherwise it is a straight 'cut and paste' into HMGIDE. I am running on a 64 bit Windows 7 laptop and have recently installed HMG 3.3.1 - I also created a table from within my HMGIDE project for the exercise also.
All works fine except ..
The datepicker control always displays the current date - the table contains a different date - if I replace the datepicker field with a textbox (date) field I get the correct date displayed. Is this a bug (perhaps just in my environment) or am I doing something wrong - any clues? All other controls work fine.
Thanks for any help,
Roger L
Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México

Re: Datepicker Refresh

Post by Javier Tovar »

Hola Roger L,

Tendrias que subir un demo para ver lo que haces o lo que hace, ya que por los datos que das, se supone que te tendria que dar bien las fechas.

-Revisa que en la DBF sea un campo tipo Date, o si es Texto que uses las funciones Form_1.DatePicker.VALUE := CToD(Table->cFecha)

Saludos

/////////////////////////////////////////////////////////////////////////////////////////////////
Hi Roger L,

You would have to upload a demo to see what you do or what you do, and that the information you give, it is assumed that you would have to give good dates.

-Check That the DBF is a type Date field, or if you use the Form_1.DatePicker.VALUE : = CTOD (Table->cDate)

Regards
rogerl
Posts: 38
Joined: Tue Nov 19, 2013 7:02 am

Re: Datepicker Refresh

Post by rogerl »

Thankyou for your quick reply - the database seems correct as if I replace the datepicker with a textbox(date) it works Ok. If I replace the refresh with a value clause nothing changes (ie still get current date). I have listed the program code below as the forum does not seem to accept these file types as attachments.

#include "hmg.ch"
Function Main

DEFINE WINDOW Win_1 ;
AT 0,0 ;
WIDTH 640 ;
HEIGHT 480 ;
TITLE 'Tutor 21: Data-Bound Controls Test' ;
MAIN ;
ON INIT OpenTables() ;
ON RELEASE CloseTables()

DEFINE TOOLBAR ToolBar_1 BUTTONSIZE 100,30 FLAT RIGHTTEXT BORDER

BUTTON TOP ;
CAPTION '&Top' ;
ACTION ( DbGoTop() , Refresh() )

BUTTON PREVIOUS ;
CAPTION '&Previous';
ACTION ( DbSkip(-1) , Refresh() )

BUTTON NEXT ;
CAPTION '&Next';
ACTION ( DbSkip(1) , if ( eof() , DbGoBottom() , Nil ) , Refresh() )

BUTTON BOTTOM ;
CAPTION '&Bottom' ;
ACTION ( DbGoBottom() , Refresh() )

BUTTON SAVE ;
CAPTION '&Save' ;
ACTION ( Save() , Refresh() )

BUTTON UNDO ;
CAPTION '&Undo' ;
ACTION ( Refresh() )

END TOOLBAR

@ 50,10 LABEL LABEL_1 VALUE 'Code:'
@ 80,10 LABEL LABEL_2 VALUE 'First Name'
@ 110,10 LABEL LABEL_3 VALUE 'Last Name'
@ 140,10 LABEL LABEL_4 VALUE 'Birth Date:'
@ 170,10 LABEL LABEL_5 VALUE 'Married:'
@ 200,10 LABEL LABEL_6 VALUE 'Bio:'

@ 50,200 TEXTBOX TEXT_1;
FIELD TEST->CODE ;
NUMERIC ;
MAXLENGTH 10

@ 80,200 TEXTBOX TEXT_2;
FIELD TEST->FIRST ;
MAXLENGTH 30

@ 110,200 TEXTBOX TEXT_3;
FIELD TEST->LAST ;
MAXLENGTH 30

@ 140,200 DATEPICKER DATE_4 ;
FIELD Test->Birth

@ 170,200 CHECKBOX CHECK_5 ;
CAPTION '' ;
FIELD Test->Married

@ 200,200 EDITBOX EDIT_6 ;
FIELD Test->Bio ;
HEIGHT 100

END WINDOW

Win_1.Text_1.SetFocus

ACTIVATE WINDOW Win_1

Return Nil

Procedure Refresh

Win_1.Text_1.Refresh
Win_1.Text_2.Refresh
Win_1.Text_3.Refresh
Win_1.Date_4.Refresh
Win_1.Check_5.Refresh
Win_1.Edit_6.Refresh
Win_1.Text_1.SetFocus

Return

Procedure Save

Win_1.Text_1.Save
Win_1.Text_2.Save
Win_1.Text_3.Save
Win_1.Date_4.Save
Win_1.Check_5.Save
Win_1.Edit_6.Save

Return

Procedure OpenTables
USE TEST
Return

Procedure CloseTables
USE
Return
Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México

Re: Datepicker Refresh

Post by Javier Tovar »

To add a file, you need to do click on the "Full Editor & Preview"
Below the edit box where you type the message is a "Tab" click "Attachments" tab and there you can attach the * .zip or * .rar

hope you upload your database for testing.

regards
Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México

Re: Datepicker Refresh

Post by Javier Tovar »

OK Rogerl,

Ya consegui la *.dbf que es ejemplo que viene con HMG,

Solo agrega lo que se indica aquí:

DEFINE WINDOW Win_1 ;
AT 0,0 ;
WIDTH 640 ;
HEIGHT 480 ;
TITLE 'Tutor 21: Data-Bound Controls Test' ;
MAIN ;
ON INIT (OpenTables(), Refresh() ) ;
ON RELEASE CloseTables()


Saludos
rogerl
Posts: 38
Joined: Tue Nov 19, 2013 7:02 am

Re: Datepicker Refresh

Post by rogerl »

Thanks Javier - that fixed it (the refresh() ON INIT) - and it looks obvious (once you see it!). Perhaps the tutorial code should be updated. In the meantime I had created my own separate project using the gui builder in HMGIDE and a date field to make a simple birthdays list and got it to work OK - so all is well!
Thanks Again!
Roger L
Post Reply