How can I create a dialog box that uses pixels instead of dialog units??
Posted on 2002-03-12 13:29:02 by Hel
Uhh!, I think your going to create a dialog box through a resource editoy like under a MS-VC++(unless you want to hard code the data for your .rc file)? if your using DialogBoxIndirectParam / DialogBoxIndirect / CreateDialogIndirect / CreateDialogIndirectParam that I don't know(haven't tried creating dialog boxes on the fly). Maybe these conversions might help. This is from Platform SDK under GetDialogBaseUnits function:

Each horizontal base unit is equal to 4 horizontal dialog template units; each vertical base unit is equal to 8 vertical dialog template units. Therefore, to convert dialog template units to pixels, use the following formulas:

pixelX = MulDiv( templateunitX, baseunitX, 4 );
pixelY = MulDiv( templateunitY, baseunitY, 8 );

Similarly, to convert from pixels to dialog template units, use the following formulas:

templateunitX = MulDiv( pixelX, 4, baseunitX );
templateunitY = MulDiv( pixelY, 8, baseunitY );

BTW, MulDiv is a Win32API function. Don't ask me how since I haven't done this before. I just copy and pasted some info from PSDK. :)
Posted on 2002-03-12 13:57:55 by stryker
Hel,

I think you are stuck with dialog units if you want to use a dialog box made with a resource editor but if you create the window you need with CreateWindowEx(), you handle all of the window display yourself and it is in pixels.

With a dialog box, you could size it with MoveWindow() or SetWindowPos() in the WM_INITDIALOG message processing but you would also have to handle all of the controls on the dialog as well.

Regards,

hutch@movsd.com
Posted on 2002-03-12 17:43:19 by hutch--
KetilO, has a cool tool with RadASM that will convert a dialog created with the dialog editor into code that creates the dialog at run-time. This seems like it would be a quick start for your situation.
Posted on 2002-03-12 18:07:11 by bitRAKE