IonicWind Software

Aurora Compiler => GUI => Topic started by: Bruce Peaslee on April 17, 2007, 05:34:16 PM

Title: Problem with CDTPicker
Post by: Bruce Peaslee on April 17, 2007, 05:34:16 PM
This crashes:

string s = "h:mm tt";
SendMessage(p_DTPicker->m_hwnd, DTM_SETFORMAT, 0, s);


That is the code used by the compiler.

Someone on the net said we need a pointer to a string so I tried this and it works:

string s = "h:mm tt";
SendMessage(p_DTPicker->m_hwnd, DTM_SETFORMAT, 0, &s);
Title: Re: Problem with CDTPicker
Post by: Rock Ridge Farm (Larry) on April 17, 2007, 05:48:45 PM
I think it is because SendMessage expects a pointer as the last arg.
Title: Re: Problem with CDTPicker
Post by: Bruce Peaslee on April 17, 2007, 11:27:34 PM
Quote from: Rock Ridge Farm (Larry) on April 17, 2007, 05:48:45 PM
I think it is because SendMessage expects a pointer as the last arg.

I think that's right.

But, looking at the source code (always the bargain), CDTPicker::SetFormat sends the string.
Title: Re: Problem with CDTPicker
Post by: Bruce Peaslee on April 20, 2007, 11:51:09 AM
Another peculiarity with the date-time picker has to do with setting just the time. I have the style of the control set to just display the time of day. When you send the message to set the time, the SYSTEMTIME structure has to be initialized with a date, even if we don't care about a date, or the API call fails.


SYSTEMTIME tm;
...
m_dlgItem.AddControl(CTDTPicker,"",142, 74, 90,20,ADTS_TIMEFORMAT, 0x200,ID_DTP_TIME);
...
tm.wHour   = StrToNum(StrLeft(sTime,StrFind(sTime,":")-1));
tm.wMinute = StrToNum(StrMid(sTime,StrFind(sTime,":")+1,2));
if((StrRight(sTime,2) == "PM") AND (tm.wHour < 12))
   tm.wHour += 12;
// need *some* value for date to get control to accept time
tm.wMonth = 1;
tm.wDay   = 1;
tm.wYear  = 2007;
SendMessage(p_dtpTime->m_hwnd, DTM_SETSYSTEMTIME , 0, &tm);


If it fails, the control sets to the local time.
Title: Re: Problem with CDTPicker
Post by: ludovico on August 27, 2008, 04:40:18 AM
I try to addcontrol this but nothing appears, I also tried to create it with cdtpicker.create but it doesn't work
Title: Re: Problem with CDTPicker
Post by: sapero on August 27, 2008, 06:16:10 AM
Bruce, you need to specify GDT_VALID in wParam:
SendMessage(p_dtpTime->m_hwnd, DTM_SETSYSTEMTIME, GDT_VALID, &tm);
Title: Re: Problem with CDTPicker
Post by: LarryMc on August 27, 2008, 06:18:50 AM
Quote from: ludovico on August 27, 2008, 04:40:18 AM
I try to addcontrol this but nothing appears, I also tried to create it with cdtpicker.create but it doesn't work
Show your code and someone will try to help you.

Larry
Title: Re: Problem with CDTPicker
Post by: ludovico on August 27, 2008, 10:26:13 AM
I think that it is cause that I try to add this into a MDIChild window
Title: Re: Problem with CDTPicker
Post by: ludovico on August 27, 2008, 02:05:33 PM
No problem, MonthCal works  ;D