How can I create a dialog box that uses pixels instead of dialog units??
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. :)
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. :)
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
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
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.