Shoutbox

[?] Setting the format of a DateTimeControl - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [?] Setting the format of a DateTimeControl (/showthread.php?tid=66010)

[?] Setting the format of a DateTimeControl by Matti on 09-09-2006 at 06:56 PM

Hey there! :)

I'm having trouble once again. :P
I'm currently trying to change the format of a DateTimeControl using the DTM_SETFORMAT message like this:

code:
var DTM_SETFORMAT = 0x1032;
Wnd.SendControlMessage('DatCDDate', DTM_SETFORMAT, 0, Language.WndSettings['DateFormat']);
where:
  • Wnd is the PlusWnd object containing the control
  • DatCDDate is the name of the DateTimeControl
  • Language.WndSettings['DateFormat'] is a string containing the new format (e.g.: "dd'/'MM'/'yyyy")
And the problem? It doesn't work. :dodgy:

Information about this message can be found on this MSDN page.

S.O.S.! :D
RE: [?] Setting the format of a DateTimeControl by Eljay on 09-09-2006 at 07:37 PM

umm the page you linked to answered it 8-)

quote:
lpszFormat
    Long pointer to a null-terminated format string...

You pass a pointer to the format string not the string itself.

So you should put the string in a databloc first and pass the pointer to that:
code:
var DTM_SETFORMAT = 0x1032;
var Format = Interop.Allocate(((Language.WndSettings['DateFormat'].length) * 2) + 2);
Format.WriteString(0, Language.WndSettings['DateFormat']);
Wnd.SendControlMessage('DatCDDate', DTM_SETFORMAT, 0, Format.DataPtr);

RE: [?] Setting the format of a DateTimeControl by Matti on 09-10-2006 at 07:16 AM

Yay! I already thought about a memory block pointer, but I never tried.
Thanks, Eljay! ;)

One thing left: Why can't I use tt to display AM/PM in my control? ^o)