Board index » kylix » Kylix equivalent to Delphi Screen.Workarea?

Kylix equivalent to Delphi Screen.Workarea?


2005-07-21 06:59:39 PM
kylix0
Hi,
As the subject asks.
I've tried the help and Google. Maybe I didn't use the right key word but
I couldn't find anything useful.
I have an application which starts with 4 forms and I would like to
position them sensibly. I can use Screen.Height/Width, but these ignore
the task bar and main menu if present.
I know we are getting into the realms of window managers here, but I would
have thought that the information would be made available somewhere.
TIA,
Dave
 
 

Re:Kylix equivalent to Delphi Screen.Workarea?

Here's what I use.
procedure TfrmCustomGoPhast.FormShow(Sender: TObject);
var
// According to the documentation, the height of the form should
// take into account the boder, menu, caption, etc. However that
// doesn't work correctly so call QWidget_frameGeometry to get the
// correct form height.
FrameHeight: integer;
FrameWidth: integer;
AFrameGeom: TRect;
WorkAreaRect: TRect;
begin
{$IFDEF LINUX}
//if not QWidget_isVisible(Widget) then Exit;
{$ENDIF}
{$IFDEF MSWINDOWS}
// Because the CLX Screen.Height doesn't take the taskbar into
account,
// use the VCL Screen object instead under windows to determine the
available
// space on the screen.
WorkAreaRect := Forms.Screen.WorkAreaRect;
{$ELSE}
{$IFDEF LINUX}
// With Linux, the screen area and the available work area are the
same.
// Use the CLX screen object to determine them.
WorkAreaRect.Top := 0;
WorkAreaRect.Left := 0;
WorkAreaRect.Right := Screen.Width;
WorkAreaRect.Bottom := Screen.Height;
{$ELSE}
Assert(False);
{$ENDIF}
{$ENDIF}
QWidget_frameGeometry(Handle, @AFrameGeom);
FrameHeight := AFrameGeom.Bottom - AFrameGeom.Top;
FrameWidth := AFrameGeom.Right - AFrameGeom.Left;
// Try to make sure the form is never off the screen.
// However, this does not resize the form to fit it on the screen.
// If the form is wider or taller than the screen, some of it will
// be off the screen.
if Left + FrameWidth>WorkAreaRect.Right then
begin
Left := WorkAreaRect.Right - FrameWidth;
end;
if Top + FrameHeight>WorkAreaRect.Bottom then
begin
Top := WorkAreaRect.Bottom - FrameHeight;
end;
if Left < WorkAreaRect.Left then
begin
Left := WorkAreaRect.Left;
end;
if Top < WorkAreaRect.Top then
begin
Top := WorkAreaRect.Top;
end;
end;
Richard B. Winston
XXXX@XXXXX.COM
water.usgs.gov/nrp/gwsoftware/
703-648-5988
on Fridays: 301 474-2762
"Dave Parsons" < XXXX@XXXXX.COM >wrote:
Quote
Hi,

As the subject asks.
I've tried the help and Google. Maybe I didn't use the right key word but
I couldn't find anything useful.

I have an application which starts with 4 forms and I would like to
position them sensibly. I can use Screen.Height/Width, but these ignore
the task bar and main menu if present.

I know we are getting into the realms of window managers here, but I would
have thought that the information would be made available somewhere.

TIA,

Dave
 

Re:Kylix equivalent to Delphi Screen.Workarea?

On Thu, 21 Jul 2005 12:31:15 UTC, rbwinston < XXXX@XXXXX.COM >wrote:
Quote
Here's what I use.

procedure TfrmCustomGoPhast.FormShow(Sender: TObject);
var
// According to the documentation, the height of the form should
// take into account the boder, menu, caption, etc. However that
// doesn't work correctly so call QWidget_frameGeometry to get the
// correct form height.
I had a feeling that it might involve looking a bit deeper.
Many thanks for the idea, I'll give it a try.
Dave
 

{smallsort}