Click to See Complete Forum and Search --> : Wrong dialog dimensions in DLGTEMPLATE structure.


Sh@dow
November 6th, 2009, 01:49 PM
I'm using VS2005.Pure API.There is a dialog resource.I'm trying to determine it's dimensions.

HRSRC hrsrc = FindResource(GetModuleHandle(0), MAKEINTRESOURCE(IDD_CONTAINER), RT_DIALOG);
HGLOBAL hglb = LoadResource(GetModuleHandle(0), hrsrc);
DLGTEMPLATE* t1 = (DLGTEMPLATE *) LockResource(hglb);


The t1->cx = -32568; t1->cy=2.
It's very strange because the dialog is 300x180 size;

MrViggy
November 6th, 2009, 03:33 PM
I haven't worked with dialogs this way, but my first guess would be that those dimensions are initialized after the dialog is shown. So far, all you've done is load the resource into memory.

Viggy

JohnCz
November 18th, 2009, 01:00 PM
There is nothing wrong with your code. You should get legitimate values.
Is a dialog template available? Try to rebuild the whole project.

Just a reminder: Dimensions of a dialog template are in dialog units, not pixels.

Igor Vartanov
November 18th, 2009, 02:59 PM
DLGTEMPLATE* t1 = (DLGTEMPLATE *) LockResource(hglb);
Well, did you ever hear about DLGTEMPLATEEX (http://msdn.microsoft.com/en-us/library/ms645398(VS.85).aspx) and the way you can distinguish between the two?

signature
Indicates whether a template is an extended dialog box template. If signature is 0xFFFF, this is an extended dialog box template. In this case, the dlgVer member specifies the template version number. If signature is any value other than 0xFFFF, this is a standard dialog box template that uses the DLGTEMPLATE and DLGITEMTEMPLATE structures.

Sh@dow
December 12th, 2009, 11:42 AM
Thanks a lot.DLGTEMPLATEEX solved the problem.