Resolved How To Get The Value From Ocx Control

Pramod Nair

Member
I am using Microsoft Date and Time picker (SP6) for Date selection on standard window. When i use to get its selected date using (SCREEN-VALUE) it returns nothing. I displayed a message it shows (?). Can i use this ocx control in normal window or i have to use smart window for this. I have done a lot on my window but this date control putting me into trouble.

Help required.
 

Osborne

Active Member
Are you trying to get the value selected in the control? If so, then this should work:
Code:
MESSAGE chCtrlFrameTDDatePicker:DTPicker:Value VIEW-AS ALERT-BOX.
 

Pramod Nair

Member
Are you trying to get the value selected in the control? If so, then this should work:
Code:
MESSAGE chCtrlFrameTDDatePicker:DTPicker:Value VIEW-AS ALERT-BOX.
Hi Osborne
I am trying to get the control value from another button's choose trigger. While checking the syntax you mentioned is giving an error. "Unknown attribute DTPicker used in widget:attribute phrase.(3406)"
 

Osborne

Active Member
DTPicker is the name of the OCX control and it is likely you have it named differently - maybe even the control frame is also a different name. If you change to the name(s) you have it should work. If not try this:
Code:
MESSAGE DTPicker:DATETIME VIEW-AS ALERT-BOX.
 

Pramod Nair

Member
DTPicker is the name of the OCX control and it is likely you have it named differently - maybe even the control frame is also a different name. If you change to the name(s) you have it should work. If not try this:
Code:
MESSAGE DTPicker:DATETIME VIEW-AS ALERT-BOX.
my ocx control Name is DTPicker according to the property and when i access its trigger by CTRL+S shows
CtrlFrame DTPicker.
 

Osborne

Active Member
Do any of these work?:
Code:
MESSAGE CtrlFrame:DTPicker:Value VIEW-AS ALERT-BOX.
Code:
MESSAGE DTPicker:Value VIEW-AS ALERT-BOX.
 

Pramod Nair

Member
my ocx control Name is DTPicker according to the property and when i access its trigger by CTRL+S shows
CtrlFrame DTPicker.
No both of them shows error i.e. The first one shows Unknow attribute what i written in my previous reply and the second one shows Unknown Variable or field (if Only giving DTPicker). and this time i took new control and did not changed the name nor in previous control.
 

Osborne

Active Member
Do you have a variable like this?:
Code:
DEFINE VARIABLE chDatePicker AS COM-HANDLE NO-UNDO.
And an internal procedure called "initialize-controls" which does something like this?:
Code:
ASSIGN chDatePicker = chCtrlFrame:DTPicker.
If so, does this work?:
Code:
MESSAGE chDatePicker:Value VIEW-AS ALERT-BOX.
 

Pramod Nair

Member
Do you have a variable like this?:
Code:
DEFINE VARIABLE chDatePicker AS COM-HANDLE NO-UNDO.
And an internal procedure called "initialize-controls" which does something like this?:
Code:
ASSIGN chDatePicker = chCtrlFrame:DTPicker.
If so, does this work?:
Code:
MESSAGE chDatePicker:Value VIEW-AS ALERT-BOX.
Oh great...... Yes this works. Loads of thanks Osborne.
 

Pramod Nair

Member
Others may have better solutions as the only ones I know of are these and the last one is .NET:

Progress KB - How to extract the TIME portion from a DATETIME or DATETIME-TZ field

Code:
MESSAGE "Hour =" CAST(BOX(chDatePicker:Value),System.DateTime):Hour SKIP
  "Minute =" CAST(BOX(chDatePicker:Value),System.DateTime):Minute SKIP
  "Second =" CAST(BOX(chDatePicker:Value),System.DateTime):Second VIEW-AS ALERT-BOX.
I have character variable which has selected date now i have extracted the date part as you said but to extract time will the above given soln work or any other way to do.
 

Osborne

Active Member
As per the Progress article, the following will assign a character variable the current time:
Code:
DEF VAR tsdate AS DATETIME NO-UNDO.
DEF VAR vTime AS CHARACTER NO-UNDO.

tsdate = DATETIME(TODAY, MTIME).
vTime = STRING(INTEGER(TRUNCATE(MTIME(tsdate) / 1000, 0)), "HH:MM:SS").
MESSAGE vTime VIEW-AS ALERT-BOX.
So for the Date Time picker time just assign tsdate = chDatePicker:Value.
 

Pramod Nair

Member
As per the Progress article, the following will assign a character variable the current time:
Code:
DEF VAR tsdate AS DATETIME NO-UNDO.
DEF VAR vTime AS CHARACTER NO-UNDO.

tsdate = DATETIME(TODAY, MTIME).
vTime = STRING(INTEGER(TRUNCATE(MTIME(tsdate) / 1000, 0)), "HH:MM:SS").
MESSAGE vTime VIEW-AS ALERT-BOX.
So for the Date Time picker time just assign tsdate = chDatePicker:Value.
Thanks again Osborne.
 
Top