DateTimePicker change available in EditFocusChange?

Public support forum for peer to peer support with related to the Visual Objects and Vulcan.NET products
jonhn
Posts: 86
Joined: Thu Feb 01, 2018 8:04 am
Location: New Zealand

DateTimePicker change available in EditFocusChange?

Post by jonhn »

Thanks Karl,
I made a small app to try your suggestion, but am not sure about a couple of things. I've copied your code almost literally, and it compiles and runs, but... I don't think it is ever calling the dispatch in my case.

1) oParent - where should this value come from? I have tried declaring it in the method below and taking _GetInst(), but I don't think it is right.
2) Where do I look for the results of these? - with the "?" ? oControlFocusChangeEvent:Control:Namesym , oControlFocusChangeEvent:GotFocus
Are these visible in the debugger?

Here's what I did...
METHOD Dispatch(oEvent) CLASS Control
LOCAL uRet AS USUAL

//PP-040421 Improved focus handling
IF oEvent:msg == WM_SETFOCUS .OR. oEvent:msg == WM_KILLFOCUS
//uRet := SELF:FocusChange(__ObjectCastClassPtr(oEvt, __pCFocusChangeEvent))
uRet := SELF:FocusChange(FocusChangeEvent{oEvent})
ENDIF

RETURN SUPER:Dispatch(oEvent)

METHOD FocusChange(oFocusChangeEvent) CLASS Control
//PP-040518 Update from S Ebert
LOCAL oParent AS OBJECT
oParent := _GetInst()

IF IsInstanceOf(oParent,#DataWindow) .OR. IsInstanceOf(oParent,#DialogWindow)
//RETURN oParent:ControlFocusChange(__ObjectCastClassPtr(oFocusChangeEvent, __pCControlFocusChangeEvent))
RETURN oParent:ControlFocusChange(ControlFocusChangeEvent{oFocusChangeEvent})
ELSEIF IsInstanceOf(oParent, #__FormWindow) //It's a browser of a DataWindow
IF oFocusChangeEvent:GotFocus
oParent:DataWindow:LastFocus := SELF
ENDIF
ENDIF

RETURN NIL
METHOD ControlFocusChange(oControlFocusChangeEvent) CLASS DATAWINDOW1

SUPER:ControlFocusChange(oControlFocusChangeEvent)

? oControlFocusChangeEvent:Control:Namesym , oControlFocusChangeEvent:GotFocus

IF IsInstanceOf ( oControlFocusChangeEvent:Control , #DATETIMEPICKER ) .and. oControlFocusChangeEvent:Control:NameSym == #DATETIMEPICKER2 .and. oControlFocusChangeEvent:GotFocus
?? "", oControlFocusChangeEvent:Control:SelectedDate

ENDIF

RETURN NIL
jonhn
Posts: 86
Joined: Thu Feb 01, 2018 8:04 am
Location: New Zealand

DateTimePicker change available in EditFocusChange?

Post by jonhn »

Thanks Jamal,
Can this also be use in X# for VO dialect?
User avatar
Chris
Posts: 4899
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

DateTimePicker change available in EditFocusChange?

Post by Chris »

Hi John,
jonhn post=24256 userid=4531 wrote:Thanks Jamal,
Can this also be use in X# for VO dialect?
Yes, the same should work in X# as well, you will just need to update the (same named) files in your XIDE folder.
If it's not working as intended, please let us know!
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am
Location: Germany

DateTimePicker change available in EditFocusChange?

Post by Karl-Heinz »

Hi Jonathan,

you may not add my posted "Class control" snippets to your app! I only posted this code, which is part of the VO Gui source code, to describe the message flow. All you need is your already created method:

Code: Select all

METHOD ControlFocusChange(oControlFocusChangeEvent) CLASS DATAWINDOW1

SUPER:ControlFocusChange(oControlFocusChangeEvent)

? oControlFocusChangeEvent:Control:Namesym , oControlFocusChangeEvent:GotFocus

IF IsInstanceOf ( oControlFocusChangeEvent:Control , #DATETIMEPICKER ) .and. oControlFocusChangeEvent:Control:NameSym == #DATETIMEPICKER2 .and. oControlFocusChangeEvent:GotFocus
?? "", oControlFocusChangeEvent:Control:SelectedDate

ENDIF

RETURN NIL


btw. ? or ?? sends the output to a console window. To make it work:

- If you use VO add the "TerminalLight" Lib.
- if you use X# change the Target from "Windows" to "Console"

regards
Karl-Heinz
jonhn
Posts: 86
Joined: Thu Feb 01, 2018 8:04 am
Location: New Zealand

DateTimePicker change available in EditFocusChange?

Post by jonhn »

Ahhhh, yes... thank you.
Now that you explained it slowly enough (and in a large font) for me, I've finally got it, and indeed it seems to be working at my end.
Thank you for the suggestion and clarification!
Post Reply