Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Corrected - Re: Why isn't this SendMessage( DTM_GETDATETIMEPICKERINFO) working?

141 views
Skip to first unread message

Larry Lindstrom

unread,
Oct 25, 2011, 8:29:57 PM10/25/11
to
Hi Folks:

This is an correction of my original post, which mistakenly used a
combo box instead of a date time picker.

Developing 32 bit app on Win 7/64 system, VS 2010 Pro.

A call to SendMessage DTM_GETDATETIMEPICKERINFO returns with the
DATETIMEPICKERINFO structure zeroed out. Unchanged from it's state
before the call.

I've read the documentation and I'm not seeing what I'm doing wrong.

Here is a 63 line program that illustrates the problem:

------------------------------------
#include <windows.h>
#include <commctrl.h>
#include "resource.h"

INT_PTR CALLBACK picker_get_info_problem_dialog_box(HWND hdlg,
UINT message,
WPARAM wParam,
LPARAM lParam);

int WINAPI WinMain (HINSTANCE hinstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
INT_PTR dialogbox_return = 0;

SetLastError(0);

dialogbox_return =
DialogBox(hinstance,
L"IDD_DIALOG",
NULL,
(DLGPROC)picker_get_info_problem_dialog_box);
}

INT_PTR CALLBACK picker_get_info_problem_dialog_box(HWND hdlg,
UINT message,
WPARAM wParam,
LPARAM lParam)
{
DATETIMEPICKERINFO picker_record;
HWND picker_control_handle = NULL;

switch (message)
{
case WM_INITDIALOG:

memset(&picker_record, 0x00, sizeof picker_record);
picker_record.cbSize = sizeof picker_record;
picker_control_handle = GetDlgItem(hdlg, IDC_DATETIMEPICKER);
SendMessage(picker_control_handle, DTM_GETDATETIMEPICKERINFO, 0,
LPARAM(&picker_record));

return FALSE;

case WM_COMMAND:

switch(LOWORD (wParam))
{
case IDCANCEL:

switch(HIWORD(wParam))
{
case BN_CLICKED:

SetLastError(0);
EndDialog(hdlg, true);

break;
}

return 0;
}
}

return 0;
}

------------------------------------

Here is the .rc

------------------------------------

// Microsoft Visual C++ generated resource script.
//
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// English (United States) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE
BEGIN
"resource.h\0"
END

2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END

3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END

#endif // APSTUDIO_INVOKED


/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//

IDD_DIALOG DIALOGEX 0, 0, 124, 102
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Dialog"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
PUSHBUTTON "Cancel",IDCANCEL,36,81,50,14
CONTROL
"",IDC_DATETIMEPICKER,"SysDateTimePick32",DTS_RIGHTALIGN |
WS_TABSTOP,7,7,100,15
END


/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//

#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
"IDD_DIALOG", DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 117
TOPMARGIN, 7
BOTTOMMARGIN, 95
END
END
#endif // APSTUDIO_INVOKED

#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////



#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//


/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED



------------------------------------

Is the resource.h file helpfull?

------------------------------------

//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by picker_get_info_problem.rc
//
#define IDC_DATETIMEPICKER1 1003
#define IDC_DATETIMEPICKER 1003

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 103
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1004
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

------------------------------------

What am I doing wrong?

Thanks
Larry

Timo Kunze

unread,
Oct 27, 2011, 4:42:12 PM10/27/11
to
Make sure (by providing a manifest) your app uses version 6.x of
comctl32.dll.
The docs say that you need Windows Vista for this message. I'm pretty
sure that Microsoft did not implement it for v5.x of comctl32.dll (which
also is part of Vista, so the docs are not accurate).

Timo
--
www.TimoSoft-Software.de - Unicode controls for VB6
"Those who sacrifice freedom for safety deserve neither."
"Demokratie ist per Definition unsicher. Ihr Schutz entsteht aus der
Überzeugung, dass die demokratischen Kräfte überwiegen und sich – auf
demokratischem Wege – durchsetzen."

Larry Lindstrom

unread,
Oct 28, 2011, 1:04:42 AM10/28/11
to
On 10/27/2011 1:42 PM, Timo Kunze wrote:
> Make sure (by providing a manifest) your app uses version 6.x of
> comctl32.dll.
> The docs say that you need Windows Vista for this message. I'm pretty
> sure that Microsoft did not implement it for v5.x of comctl32.dll (which
> also is part of Vista, so the docs are not accurate).
>
> Timo
Thanks Timo:

The Microsoft doc at

http://msdn.microsoft.com/en-us/library/bb761755%28v=VS.85%29.aspx

doesn't mention a necessary library.

I added Comctl32.lib to the linker input.

Now the DTM_GETDATETIMEPICKERINFO record has a value for stateCheck
and rcButton.

Everything else in the structure is unchanged from zero, including
hwndEdit and the other handles.

I'm developing on Win 7, but many are using XP, and I'd like to be
compatible with that OS.

Is there a technique to find the edit window that works in XP and
Win 7, or works at all?

Thanks
Larry

Timo Kunze

unread,
Oct 28, 2011, 9:11:16 AM10/28/11
to
Hi Larry,

Am 28.10.2011 07:04, schrieb Larry Lindstrom:
> The Microsoft doc at
>
> http://msdn.microsoft.com/en-us/library/bb761755%28v=VS.85%29.aspx
>
> doesn't mention a necessary library.
>
> I added Comctl32.lib to the linker input.
>
> Now the DTM_GETDATETIMEPICKERINFO record has a value for stateCheck
> and rcButton.

You misunderstood me. Starting with Windows XP Windows comes with two
different versions of comctl32.dll: Version 5.8x which does not support
XP themes and is pretty much the same version as the one that was part
of Windows 2000. And there's version 6.x which is required if you want
your app to be themed. Version 6.x also supports many additional
features like list view groups.
By default your app will use version 5.8x. To make it use 6.x you need
to provide a manifest. See the docs for details. Newer versions of
Visual C++ will include this manifest into your app by default.
So what I tried to tell you is that you need to make sure that your app
uses version 6.x instead of 5.8x of comctl32.dll.

> Everything else in the structure is unchanged from zero, including
> hwndEdit and the other handles.
>
> I'm developing on Win 7, but many are using XP, and I'd like to be
> compatible with that OS.
>
> Is there a technique to find the edit window that works in XP and Win
> 7, or works at all?

Comctl32.dll 6.x is not redistributable and according to the docs the
DTM_GETDATETIMEPICKERINFO message has been introduced with Windows
Vista. So if your code has to work on Windows XP as well,
DTM_GETDATETIMEPICKERINFO cannot be used (at least not for XP - maybe
you could use it on Vista/7 and somehow emulate it for XP).

Regards

Larry Lindstrom

unread,
Oct 30, 2011, 7:44:58 AM10/30/11
to
Thanks Timo

Larry
0 new messages