Re: Scaling Euphoria MS Windows applications to font DPI
Andrew Katz wrote:
>
> Both Judith and Quark have complained about my Magic Designer application
> looking
> ugly. And the reason why this is, is because I designed it using my computer
> display at 96 DPI, and they both have theirs set at 120 DPI. So, I set mine
> at 120 DPI:
>
> Right click on Desktop and select Properties.
> Click Settings.
> Click Advanced.
> Set to Large Size (120 DPI)
> You will need to restart Windows.
>
> This issue is a HUGE one. I have noticed that some applications change and
> others
> do not! And some web pages change to the correct DPI and others do not. And
> in some cases, like Thunderbird email application, the user has the ability
> to adjust field lengths once they have established their DPI for fonts.
>
> With Magic Designer, I had carefully sized things using my standard 96 DPI to
> maximize the drawing area, for people with a 800 x 600 display. And now that
> I switched to 120 DPI, I can see where my application fails and where it is
> ugly.
>
snipped
>
> Andy Katz
> B.S. Computer Science, 1978
> Rensselaer Polytechnic Institute (RPI)
Hi Andy,
I've also seen and hate this problem.. I didn't find that particular article so
I haven't tried switching fonts. The code below is my (poor!) attempt at a fix,
just change your "Create" calls to the dpiCreate. I would be interested in
hearing if it helps your application at different DPIs.
Note the xGetDeviceCaps function does a divide by 96, this is because I design
at that setting, so have your window looking good at 96DPI then try switching to
a higher value..
include win32lib.ew
global constant
Centre = "Centre" -- for correct window centering on screen (win32lib
doesn't do this right for child windows - Note UK spelling of 'centre'!!)
constant
xPARAMS = 1,
yPARAMS = 2,
cxPARAMS = 3,
cyPARAMS = 4,
X = 1,
Y = 2
atom dc
atom cxDpi, cyDpi
dc = getDC ( Screen )
cxDpi=(w32Func(xGetDeviceCaps,{dc,LOGPIXELSX})/96)
cyDpi=(w32Func(xGetDeviceCaps,{dc,LOGPIXELSY})/96)
releaseDC(dc)
integer centerScreenX, centerScreenY
sequence ScreenSize
ScreenSize = getRect(Screen)
centerScreenX = floor( ScreenSize[3]/2 )
centerScreenY = floor( ScreenSize[4]/2 )
global function DI(integer Orientation, object pixels)
if Orientation = X then
return floor(pixels * cxDpi)
elsif Orientation = Y then
return floor(pixels * cyDpi)
end if
end function
global function dpiCreateEx(integer pControl, sequence caption, atom pOwner,
object x, object y, object cx, object cy, object styleFlags, object
exFlags )
sequence params
sequence IgnoreControls -- controls not needing change
params = {x, y, cx, cy}
IgnoreControls = {Menu, MenuItem}
if not find(pControl, IgnoreControls) then
if pControl != Window then -- if control is a Window then leave
position stuff alone
-- chk for relational positioning i.e. ix X < 1 then
-- x position must be a 0.x (%) value so leave alone
if integer(x) and x > 1 then
params[xPARAMS] = DI(X, x)
-- also handle w32lib constant calls like 'Center' and
{w32AltEdge. -20}
elsif sequence(x) and atom(x[2]) and length(x) = 2 then
params[xPARAMS] = x
params[xPARAMS][2] = DI(X, x[2])
end if
if integer(y) and y > 1 then
params[yPARAMS] = DI(Y, y)
elsif sequence(y) and atom(y[2]) and length(y) = 2 then
params[yPARAMS] = y
params[yPARAMS][2] = DI(Y, y[2])
end if
end if
if integer(cx) and cx > 1 then
params[cxPARAMS] = DI(X, cx)
elsif sequence(cx) and atom(cx[2]) and length(cx) = 2 then
params[cxPARAMS] = cx
params[cxPARAMS][2] = DI(X, cx[2])
end if
if pControl != SortedCombo then
if integer(cy) and cy > 1 then
params[cyPARAMS] = DI(Y, cy)
elsif sequence(cy) and atom(cy[2]) and length(cy) = 2 then
params[cyPARAMS] = cy
params[cyPARAMS][2] = DI(Y, cy[2])
end if
else
params[cyPARAMS] = cy
end if
end if
if pControl = Window then -- if control is a 'centered' Window then center
it!
if equal(x, Centre) then params[xPARAMS] = centerScreenX - floor(
params[cxPARAMS]/2 ) end if
if equal(y, Centre) then params[yPARAMS] = centerScreenY - floor(
params[cyPARAMS]/2 ) end if
end if
return createEx( pControl, caption, pOwner, params[xPARAMS],
params[yPARAMS],
params[cxPARAMS], params[cyPARAMS], styleFlags, exFlags)
end function
global function dpiCreate(integer pControl, sequence caption, atom pOwner,
object x, object y, object cx, object cy, object styleFlags )
return dpiCreateEx( pControl, caption, pOwner, x, y, cx, cy, styleFlags,
0)
end function
Regards PeteS
|
Not Categorized, Please Help
|
|