?
Solved

Delphi screen enumeration

Posted on 2007-08-01
6
Medium Priority
?
605 Views
Last Modified: 2013-11-23
In Delphi, how do you get the left most screen?

For example, using a form that you want to remain hidden, you can set the Left to a negative width:

Self.Left := -Width;

The page this is for contains a TWebBrowser control, and therefore cannot have its visibility set to false, otherwise the pages do not fully load. Per Microsoft, the Left should be assigned -Width.

This is simple on a single screen. However, and for example, I have two screens. My left screen starts at -1440.. so if I set the form left position to -Width, it just appears on my left screen.

How do you enumerate all screens, and get the left most position?
0
Comment
Question by:akede2001
  • 2
  • 2
  • 2
6 Comments
 
LVL 10

Expert Comment

by:dinilud
ID: 19608021
you mean using multiple desktop?
0
 

Author Comment

by:akede2001
ID: 19608049
Perhaps, if that's the correct terminology for it.

I'm running Windows. I have two monitors hooked up; same system, same OS. Each monitor shows a desktop, and windows can be drug around the two screens.
0
 
LVL 21

Accepted Solution

by:
ziolko earned 2000 total points
ID: 19608076
check out:
Screen.Monitors[...]

ziolko.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:akede2001
ID: 19608105
Awesome. That's what I needed. And with that, we have:

function GetMostLeft(): Integer;
var
  x: Integer;
begin
  Result := 0;

  for x := 0 to Screen.MonitorCount - 1 do
    if (Screen.Monitors[x].Left < Result) then
      Result := Screen.Monitors[x].Left;
end;


Works like a charm.
0
 
LVL 21

Expert Comment

by:ziolko
ID: 19608144
glad i could help:)

ziolko.
0
 
LVL 10

Expert Comment

by:dinilud
ID: 19608179
Can you tell output this program in each screen(screen1 and screen2).



//////////////.////

Unit1.dfm
=======

object Form1: TForm1
  Left = 195
  Top = 228
  Width = 338
  Height = 190
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Button1: TButton
    Left = 40
    Top = 48
    Width = 177
    Height = 41
    Caption = 'Button1'
    TabOrder = 0
    OnClick = Button1Click
  end
end

Unit1.pas
========

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
   ShowMessage('Left : '+IntToStr(Left)+'      Top : '+IntToStr(Top));
   ShowMessage('Screen Width : '+IntToStr(Screen.Width)+'      Screen Height : '+IntToStr(Screen.Height));
end;

end.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question