(PowerBuilder Classic 12.5)
Workaround is related to the problem that the datepicker calendar part is being cut off (left right edge) when using themes other than Windows Classic. The problem becomes more extensive when using Week Numbers, leaving the control then more or less useless.
After searching around, I found this article(Setting calendar size when overriding DateTimePicker to add week numbers) that pointed me in the right direction.
The workaround is not extensively tested, but it seems to work pretty well on my computer (Win 7) in compiled code. Good effect with different resolutions and PPI. When changing to Windows Classic Theme, the calendar part gets some wider margins but not too much.
I see no reason why this code should not work with other PB Classic versions other than PB12.5 as long as they have the datepicker control..
<suggested implementation> - See attached file (rename to .sru and import into pbl library)
Create a standard visual userobject(u_ datepicker) based on the datepicker type, and place the code in the dropdown event. Also
add the structure and Local Extrernals Functions to the userobject. Then Place the standard visual userobject on your window.
<Local Extrernals Functions>
//FUNCTION long SendMessageGetCal (long hwnd, ulong wMsg, ulong wParam, long lParam) Library "user32.dll" Alias for "SendMessageA"
//FUNCTION boolean MoveWindow(long hwnd,int wx,int wy,int ww,int wh,boolean wflag) Library "user32.dll"
//FUNCTION ulong GetParent(ulong hWnd) Library "user32.dll"
//FUNCTION boolean GetWindowRect( ulong hWnd, REF str_rect lpRect ) LIBRARY "user32.dll"
<Structure>
type str_rect from structure
long left
long top
long right
long bottom
end type
<script in dropdown event on datepickert>
long ll_innerCalHwnd
long ll_outerCalHwnd
str_rect rc
CONSTANT ulong DTM_GETMONTHCAL = (4096 + 8) //(DTM_FIRST + 8)
// Get the handle to datepicker child month calendar control.
ll_innerCalHwnd = SendMessageGetCal(handle(this), DTM_GETMONTHCAL, 0, 0)
// Get the handel to the window containing the datepicker child month calendar control.
ll_outerCalHwnd = GetParent(ll_innerCalHwnd)
// Get the rectangle for the calendar window.
GetWindowRect(ll_outerCalHwnd, ref rc)
//Apply width adjustment to calendar window.
// Posting the MoveWindow function lets the calendar windows control render the changes.
// The datepicker child month calendar control is automatically rendered in center of the parent window.
post MoveWindow(ll_outerCalHwnd, rc.left, rc.top, (rc.Right + 28) - rc.left, rc.Bottom - rc.top, true)
Regards Bjarne Eian
Norway
Message was edited by: Bjarne Eian