Page 1 of 1
Auto fits/sorts controls of dialog in different resolutions
Posted: Fri Jun 16, 2006 1:46 am
by ShumingWang
Dear All,
Our dialog resources in dll designed to 800*600 resolution , now we write a small function( called on dialog init) to auto fit/sort controls of dialog according different resolution as 1024*768,1280*1024, all the controls seems OK, but -1 ids (static text, groups) seems not exists in odialog:acontrols,how to detect these -1 ids ?
rsl0:=getsysmetrics(0)/800
rsl1:=getsysmetrics(1)/600
for i:=1 TO LEN(odlg:acontrols)
oCtrol = odlg:aControls
aRect = GetCoors( oCtrol:hWnd )
oCtrol:Move( aRect[1]*rsl0, aRect[2]*rsl1, (aRect[4] - aRect[2])*rsl0, (aRect[3] - aRect[1])*rsl1, .t. )
next
Best regard!
Shuming Wang
Re: Auto fits/sorts controls of dialog in different resoluti
Posted: Fri Jun 16, 2006 7:18 pm
by Enrico Maria Giordano
ShumingWang wrote:how to detect these -1 ids ?
You can't, as far as I know.
EMG
Re: Auto fits/sorts controls of dialog in different resoluti
Posted: Mon Jun 19, 2006 4:07 pm
by Maurilio Viana
Wang, the best way to do it is create a ID to each control. I use any like it and I create an ID to each "say", then I do a "pseudo redefine" like this:
redefine say id 51 of oDlg
redefine say id 52 of oDlg
(...)
For while is hard to redefine each say but is only way I found. Or you can create a function and refer to say's IDs in an array. Any like this
MyRedefineSay({51,52,52,53}, oDlg)
...
function MyRedefineSay(aID, oDlg)
local n
FOR n := 1 to len(aID)
TSay():Redefine(aId[n] ......... )
NEXT
return
//-----------------------------------
Only a suggest
Bast regards,
Maurilio
Posted: Mon Jun 19, 2006 4:28 pm
by James Bott
Shuming,
I found the text below in my notes. You might give it a try.
James
-----------------------------------------
6/21/2004 9:00 PM
If you change the size of the dialog font in Workshop, then the dialog is automatically resized to accomodate the new font. This resizing occurs both in Workshop and in the application. Note that in Workshop the dialog is displayed larger than it will be in the application.
[Note: WS defaults to a MS Sans Serif, 8 point font when you define a new dialog.]
The automatic resizing happens inside the dialogBox() function called in TDialog:activate(). This seems to be inside the Win API. There is no built-in way to force the dialog to resize by changing the font after the dialog has been initialized.
You can change the font of a dialog via code if you do it before activating the dialog:
define dialog oDlg...
oDlg:setFont(oFont)
activate dialog oDlg
However, I find that the font is about 4 points smaller on the screen that it is if you define the font in Workshop. E.G. you would have to use a 16point font via setFont() in order to get the same sized font on the screen that you would get if you defined a 12point font in WS. I think this must be a bug somewhere.