commctl32 datetime updown control fix
Siim Karus
siim04 at ut.ee
Fri Jan 6 13:06:01 CST 2006
UpDown control of datetime control did not work properly:
* Often clicking on it did nothing (that was when it was in wrong position -
CVS version had it fixed).
* Clicking on it in the right location popped up Calendar control.
* It was possible to create datetime control for time without up-down control
but with calendar dropdown (which should never be possible).
So I added code to add DTS_UPDOWN style whenever DTS_DATETIME was used (as it
should be according to Platform SDK for Windows XP SP2 Documentation), to add
updown control better usable range and to process the notifications (the
processing it used before did not seem to work in effective way :( ). Also added
checks for calendar dropdown detection (why isn't it done by the actual dropdown
button instead of PtInRect call in DATETIME control?).
Tested with OSE (binary: http://www.ut.ee/~siim04/OSE/OSE.exe , source:
http://www.ut.ee/~siim04/OSE/OSE.cpp) that displays LOCALE datetime formats (for
system and user) and then allows you to use datetime control or even change its
styles.
Siim Karus
-------------- next part --------------
Index: wine/dlls/comctl32/datetime.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/datetime.c,v
retrieving revision 1.62
diff -u -p -r1.62 datetime.c
--- wine/dlls/comctl32/datetime.c 8 Nov 2005 12:52:35 -0000 1.62
+++ wine/dlls/comctl32/datetime.c 4 Jan 2006 20:52:10 -0000
@@ -444,6 +444,9 @@ static void
DATETIME_IncreaseField (DATETIME_INFO *infoPtr, int number, int delta)
{
SYSTEMTIME *date = &infoPtr->date;
+
+ if(infoPtr->hUpdown)
+ SendMessageW(infoPtr->hUpdown,UDM_SETPOS,0,1);
TRACE ("%d\n", number);
if ((number > infoPtr->nrFields) || (number < 0)) return;
@@ -669,7 +672,7 @@ DATETIME_HitTest (DATETIME_INFO *infoPtr
TRACE ("%ld, %ld\n", pt.x, pt.y);
- if (PtInRect (&infoPtr->calbutton, pt)) return DTHT_MCPOPUP;
+ if (!(infoPtr->dwStyle & DTS_UPDOWN) && PtInRect (&infoPtr->calbutton, pt)) return DTHT_MCPOPUP;
if (PtInRect (&infoPtr->checkbox, pt)) return DTHT_CHECKBOX;
for (i=0; i < infoPtr->nrFields; i++) {
@@ -849,6 +852,13 @@ DATETIME_Notify (DATETIME_INFO *infoPtr,
TRACE("Delta pos %d\n", lpnmud->iDelta);
infoPtr->pendingUpdown = lpnmud->iDelta;
}
+ /*if updown control is used*/
+ if(lpnmh->code == UDN_DELTAPOS) {
+ NMUPDOWN * lpnmud = (LPNMUPDOWN)lpnmh;
+ DATETIME_IncreaseField(infoPtr,infoPtr->select & DTHT_DATEFIELD,lpnmud->iDelta);
+ InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
+ DATETIME_SendDateTimeChangeNotify (infoPtr);
+ }
return 0;
}
@@ -1136,6 +1146,20 @@ DATETIME_StyleChanged(DATETIME_INFO *inf
wStyleType, lpss->styleOld, lpss->styleNew);
if (wStyleType != GWL_STYLE) return 0;
+
+ DWORD newStyle = lpss->styleNew;
+ /* if we use control for time, always show UpDown control (like in Windows) */
+ if(lpss->styleNew & DTS_TIMEFORMAT)
+ lpss->styleNew |= DTS_UPDOWN;
+ if(lpss->styleOld & DTS_TIMEFORMAT)
+ {
+ /*lpss->styleOld |= DTS_UPDOWN;*/
+ /* if you don't remove both up-down and timeformat, then you have made an error */
+ if(lpss->styleNew & DTS_UPDOWN)
+ {
+ lpss->styleNew |= DTS_TIMEFORMAT;
+ }
+ }
infoPtr->dwStyle = lpss->styleNew;
@@ -1150,8 +1174,23 @@ DATETIME_StyleChanged(DATETIME_INFO *inf
infoPtr->hwndCheckbut = 0;
}
if ( !(lpss->styleOld & DTS_UPDOWN) && (lpss->styleNew & DTS_UPDOWN) ) {
- infoPtr->hUpdown = CreateUpDownControl (WS_CHILD | WS_BORDER | WS_VISIBLE, 120, 1, 20, 20,
- infoPtr->hwndSelf, 1, 0, 0, UD_MAXVAL, UD_MINVAL, 0);
+ RECT rcWnd;
+ if(GetWindowRect(infoPtr->hwndSelf,&rcWnd))
+ {
+ infoPtr->hUpdown = CreateUpDownControl (
+ WS_CHILD | WS_BORDER | WS_VISIBLE, /* control style */
+ infoPtr->rcClient.right-infoPtr->rcClient.left-13, /* control x coordinate */
+ 1, /* control y coordinate */
+ 12, /* control width */
+ infoPtr->rcClient.bottom-2, /* control height */
+ infoPtr->hwndSelf, /* control parent */
+ 1, /* control id */
+ 0, /* instance handle */
+ 0, /* buddy handle */
+ 2, /* upper limit of control */
+ 0, /* lower limit of control */
+ 1); /* position of control */
+ }
}
if ( (lpss->styleOld & DTS_UPDOWN) && !(lpss->styleNew & DTS_UPDOWN) ) {
DestroyWindow(infoPtr->hUpdown);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: siim04.vcf
Type: text/x-vcard
Size: 165 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20060106/ce66023e/siim04.vcf
More information about the wine-patches
mailing list