April 23, 2024, 08:02:07 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Problem with CDTPicker

Started by Bruce Peaslee, April 17, 2007, 05:34:16 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Bruce Peaslee

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);
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Rock Ridge Farm (Larry)

I think it is because SendMessage expects a pointer as the last arg.

Bruce Peaslee

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.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Bruce Peaslee

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.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

ludovico

I try to addcontrol this but nothing appears, I also tried to create it with cdtpicker.create but it doesn't work

sapero

Bruce, you need to specify GDT_VALID in wParam:
SendMessage(p_dtpTime->m_hwnd, DTM_SETSYSTEMTIME, GDT_VALID, &tm);

LarryMc

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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

ludovico

I think that it is cause that I try to add this into a MDIChild window

ludovico