AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Monitore und dessen Positionen anzeigen (Bildschirmanordnung)
Thema durchsuchen
Ansicht
Themen-Optionen

Monitore und dessen Positionen anzeigen (Bildschirmanordnung)

Ein Thema von dGeek · begonnen am 18. Feb 2015 · letzter Beitrag vom 19. Feb 2015
 
dGeek
(Gast)

n/a Beiträge
 
#19

AW: Monitore und dessen Positionen anzeigen (Bildschirmanordnung)

  Alt 18. Feb 2015, 22:47
Ok also ich habe wirklich Eigeninitiative gezeigt und lasse mir nicht alles vorkauen.

Aber nun bin ich am Ende und besser bekomme ich es nicht hin.
(Einfach in eine Form packen die etwa 500px hoch und 400p breit ist).

Wenn mir nun noch jemand helfen könnte die Skalierung richtig hinzubekommen sodass alle Monitore (Shapes) richtig auf der Form angezeigt werden können, wäre ich sehr dankbar.

Delphi-Quellcode:
procedure TForm2.FormShow(Sender: TObject);
const
  aScale = 7;
var
  p: TPoint;
  iMostTop, iPrimaryX, iPrimaryY, iPrimary, i: Integer;
  aShape: TShape;
  aLabel: TLabel;
  procedure drawScreen(iMonCnt: Integer; bPrimary: Boolean = False);
  begin
    p := Point(Screen.Monitors[iMonCnt].Left, Screen.Monitors[iMonCnt].Top);

    if Assigned((FindComponent('aScreen' + IntToStr(iMonCnt + 1)) as TShape)) then
      (FindComponent('aScreen' + IntToStr(iMonCnt + 1)) as TShape).Free;

    aShape := TShape.Create(Self);
    aShape.Parent := Self;
    aShape.Name := 'aScreen' + IntToStr(iMonCnt + 1);
    aShape.Anchors := [];

    aShape.Width := prozentwert(Screen.Monitors[iMonCnt].Width, aScale);
    aShape.Height := prozentwert(Screen.Monitors[iMonCnt].Height, aScale);

    if bPrimary then
    begin
      aShape.Left := (Self.Width div 2) - (aShape.Width div 2);
      aShape.Top := iMostTop; // (Self.Height div 2) - (aShape.Height div 2);
      iPrimaryX := aShape.Left;
      iPrimaryY := aShape.Top;
    end
    else
    begin
      aShape.Left := prozentwert(p.X, aScale) + iPrimaryX;
      aShape.Top := prozentwert(p.Y, aScale) + iPrimaryY;
    end;

    if Assigned((FindComponent('aLabel' + IntToStr(iMonCnt + 1)) as TLabel)) then
      (FindComponent('aLabel' + IntToStr(iMonCnt + 1)) as TLabel).Free;

    aLabel := TLabel.Create(Self);
    aLabel.Parent := Self;
    aLabel.Name := 'aLabel' + IntToStr(iMonCnt + 1);
    aLabel.Anchors := aShape.Anchors;
    aLabel.Font.Size := -13;
    aLabel.Font.Style := [fsBold];
    aLabel.AutoSize := False;
    aLabel.Left := aShape.Left + 1;
    aLabel.Top := aShape.Top + (aShape.Height div 2) - (aLabel.Height div 2);
    aLabel.Width := aShape.Width - 2;
    aLabel.Alignment := taCenter;
    aLabel.Caption := IntToStr(iMonCnt + 1);
    aLabel.Visible := True;
    aLabel.BringToFront;

    Repaint;
  end;

begin
  iMostTop := 0;
  for i := 0 to Screen.MonitorCount - 1 do
  begin
    if Screen.Monitors[i].Top < iMostTop then
      iMostTop := Screen.Monitors[i].Top;
  end;
  iMostTop := iMostTop + 20;

  for i := 0 to Screen.MonitorCount - 1 do
  begin
    if Screen.Monitors[i].Primary then
    begin
      iPrimary := i;
      drawScreen(i, True);
      break;
    end;
  end;

  for i := 0 to Screen.MonitorCount - 1 do
  begin
    if i = iPrimary then
      Continue;

    drawScreen(i);
  end;
end;
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:17 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz