Re: Windows control size

new topic     » goto parent     » topic index » view thread      » older message » newer message

I'll try again...

Hi All, You may remember a short time ago I was wondering how I could get my
windows gui's to look good on both 96 and 120 dpi, well I've got a simple routine
that uses dialog box base units.
I've included in the code below a sample window with 2 sets of buttons and text,
one set is sized with the routines, the other in pixels as normal, both
are exactly the same size and do not clip their text when run on 96 dpi screen,
but on 120 dpi the 'normal' set are too small and clip their text...whilst the
'sized' set look fine...

include win32lib.ew

global constant
 user32 = open_dll("user32.dll"),
 xGetDialogBaseUnits = define_c_func( user32, "GetDialogBaseUnits", {}, C_LONG )
 
global function GetDialogBaseUnits()
 return c_func( xGetDialogBaseUnits,  {} )
end function

-- Width/Height = number of Dialog base units
-- returns number of Pixels for Width/Height 
global function DialogX(atom Width)
atom  tWidth 
	tWidth  = w32lo_word(GetDialogBaseUnits()) -- establish the width
	return (tWidth * Width)/4
end function

global function DialogY(atom Height)
atom tHeight
	tHeight = w32hi_word(GetDialogBaseUnits()) -- establish the height
	return (tHeight * Height)/8
end function

constant Main = create(Window, "test", 0, 0.2, 0.3, DialogX(90), DialogY(120),
0)
-- with sizing
constant text = create(LText, "testing 123", Main, 0.2, 0.1, DialogX(26),
DialogY(6), 0)
constant But = create(Button, "CLOSE", Main, 0.1, 0.2, DialogX(20), DialogY(9),
0)
constant But2 = create(Button, "BUTTONXXX", Main, 0.5, 0.2, DialogX(35),
DialogY(9), 0)
-- without sizing
constant xtext = create(LText, "testing 123", Main, 0.2, 0.4, 52, 12, 0)
constant xBut = create(Button, "CLOSE", Main, 0.1, 0.5, 40, 18, 0)
constant xBut2 = create(Button, "BUTTONXXX", Main, 0.5, 0.5, 70, 18, 0)

WinMain(Main, Normal)


regards Pete

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu