DateControl in 64 bit application

Discussions related to Visual Prolog
Post Reply
Harrison Pratt
VIP Member
Posts: 257
Joined: 5 Nov 2000 0:01

DateControl in 64 bit application

Post by Harrison Pratt » 7 Dec 2017 18:24

The dateControl works when compiling to 32 bit Exe, but dateControl does NOT work when compiling to 64 bit Exe.

I can initialize display of control and set a date value with either platform, but dateControl events are not captured by the 64 bit application and the user-selected date cannot in the control cannot be retrieved.

I created a tiny test project which builds either a 32- or 64-bit EXE. The dateControl was initialized to 01/01/1900 for testing purposes. It has the following code:

Code: Select all

        stdio::write("\nCompiler version: ", compiler_version ),         stdio::write("\nPlatform bits: ", platform_bits, "  ", platform_name ),         stdio::write("\nDate formatted: ", dateControl_ctl:formatDate( "MM/dd/yyyy" ) ),         dateControl_ctl:getdate( Y,M,D ),         stdio::writef("\nDate as integers: %02/%02/%4", M,D,Y ).


The 32-bit application displays this:

Control initialized to: 01/01/1900
Compiler version: 7500
Platform bits: 32 Windows 32bits
Date formatted: 12/02/2017
Date as integers: 12/02/2017

and the 64-bit application displays this:

Control initialized to: 01/01/1900
Compiler version: 7500
Platform bits: 64 Windows 64bits
Date formatted: 01/01/1900
Date as integers: 01/01/1900

Comments in other forums suggest that this may be a Windows issue and not a VP quirk. For the time being, I am using my own less-elegant control for 64 bit apps.

Harrison Pratt

User avatar
Thomas Linder Puls
VIP Member
Posts: 2327
Joined: 28 Feb 2000 0:01

Re: DateControl in 64 bit application

Post by Thomas Linder Puls » 7 Dec 2017 21:31

I do believe the problem is in our part of the code, basically the second argument of a nmhdr should be an unsignedNative:

Code: Select all

domains     nmhdr = tagnmhdr(vpiDomains::windowHandle, unsignedNative, unsigned).
That field is repeated in the nmdatetimechange and the problem is also there.

It does however seem more natural to rewrite the nmdatetimechange like this (given the current language possibilities):

Code: Select all

domains     nmhdr = tagnmhdr(vpiDomains::windowHandle, unsignedNative, unsigned).     nmdatetimechange = nmdatetimechange(nmhdr NMHDR [inline], unsigned Flags, time_native::systemtime ST [inline]).


All in all there is a certain section of the code that should now look like this:

Code: Select all

domains     nmhdr = tagnmhdr(vpiDomains::windowHandle, unsignedNative, unsigned).     nmdatetimechange = nmdatetimechange(nmhdr NMHDR [inline], unsigned Flags, time_native::systemtime ST [inline]).   predicates     onControlNative : nativeMessageHandler. clauses     onControlNative(_, gui_native::wm_notify, _, LParam) = _ :-         uncheckedConvert(nmhdr, LParam) = tagnmhdr(_, _, Code),         dispatchNotify(Code, LParam).       onControlNative(_, _M, _W, _L) = defaultNativeHandling.   predicates     dispatchNotify : (unsigned, gui_native::lParam) failure. clauses     dispatchNotify(dtn_dropdown, _) :-         CalendarHwnd =             uncheckedConvert(vpiDomains::windowHandle, vpi::winSendEvent(hwnd_fact, e_Native(dtm_getmonthcal, gui_api::wNull, gui_api::lNull))),         dropDownListener_db(Listener),         Listener(This, CalendarHwnd),         fail.       dispatchNotify(dtn_closeup, _) :-         closeUpListener_db(Listener),         Listener(This),         fail.       dispatchNotify(dtn_datetimechange, LParam) :-         uncheckedConvert(nmdatetimechange, LParam) = nmdatetimechange(_, gdt_valid, time_native::systemtime(Year, Month, _, Day, Hour, Min, Sec, _)),         time::setDateAndTime(convert(integer, Year), convert(integer, Month), convert(integer, Day), convert(integer, Hour), convert(integer, Min),             convert(integer, Sec)),         dateTimeChangedListener_db(Listener),         Listener(This),         fail.
You can update the code in the installation, or you can make a shadow file in: "<YourProject>\pfc\gui\controls\dateControl\dateControl.pro"
Regards Thomas Linder Puls
PDC

Harrison Pratt
VIP Member
Posts: 257
Joined: 5 Nov 2000 0:01

Re: DateControl in 64 bit application

Post by Harrison Pratt » 8 Dec 2017 13:41

Works great - and thanks for the hint on using shadow files! I see that it is possible to do quick A:B testing by changing the order of the Include Directories in Project Settings > Directories. :D

User avatar
Thomas Linder Puls
VIP Member
Posts: 2327
Joined: 28 Feb 2000 0:01

Re: DateControl in 64 bit application

Post by Thomas Linder Puls » 14 May 2018 11:17

This problem is solved in Visual Prolog 8 - Build 802.
Regards Thomas Linder Puls
PDC

Post Reply