How to set the date in a date/time picker

Discuss topics that apply across the products, such as the PocketC language, or development in general

Postby FrappyDan on Fri Dec 20, 2002 1:13 am

I'm writing an Expense manager and I have two systemtimedatepickers to select the start date and the end date. I figured this would be the "classy" way to get this info. It works but both controls always initially show with todays date in them or the last date selected. I want to set the start date calendar to a couple of weeks before the end date calendar and the end date calendar to the last date entered for a "quick summary" before showing them. I've checked windowsce docs and don't see a method or function for simply setting the date nor the message needed to initiate this action. Can anyone help?:?::?:

Posts: 16
Joined: Mon Nov 25, 2002 4:09 am
Location: USA

Postby guy on Fri Dec 20, 2002 11:09 am

This should do it for you:

Code: Select all

// You need CEAPI to build the correct parameter for sendmsg():

#include "/pocketc/winbase.h"       // Defines SYSTEMTIME
#include "/pocketc/commctrl.h"      // Defines Date/time control messages

#define DSC_SYSTEMTIME "wwwwwwww"   // System time structure is 8 words

SYSTEMTIME rTime ;                  // Struct to hold date/time to set
LPVOID lpData ;                     // Pointer to binary version in real memory

rTime.wYear         = 2003 ;
rTime.wMonth        = 1 ;           // January
rTime.wDayOfWeek    = 0 ;           // You might have to work this out. 0=sunday
rTime.wDay          = 1 ;           // So January-1-2003
rTime.wHour         = 11 ;
rTime.wMinute       = 25 ;          // at 11:25
rTime.wSecond       = 0 ;           //  exactly
rTime.wMilliseconds = 0 ;           //   really, really exactly

// Allocate some real memory for a date/time struct

lpData = LocalAlloc(LPTR, sizeofx(DSC_SYSTEMTIME)) ;

// Copy the PocketC struct into real memory

memwriteStruct(&rTime, DSC_SYSTEMTIME, lpData) ;

// Send the date/time picker control a message to set its time

sendmsg(guiid_of_date_time_ctrl, DTM_SETSYSTEMTIME, lpData, GDT_VALID) ;

// Free up the real memory

LocalFree(lpData) ;

// All done

PocketC CE API interface:
PCForm and CE API forum:
PocketC CE API interface:
PCForm and CE API forum:
Posts: 879
Joined: Thu Dec 07, 2000 8:58 am
Location: United Kingdom

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest