Autor Beitrag
NeoInDerMATRIX
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 245

Win95, Win98(+se), WinNT, Win2000, WinME, WinXP(+pro), VISTA, Linux(SuSe), DOS [MultiMon(3)], Vista
D6 PeE + (FP 2.0l) + D3 Pe + D2005+ D2006 Arch
BeitragVerfasst: Fr 21.01.05 02:26 
Hallo,

ich habe mal wieder ein Problem mit dem Monitor. Und zwar möchte ich wissen wie ich per API auslesen kann wo sich ein Monitor ausgehend vom Primären sich befindet.
Die werte lese ich folgender massen aus.
ausblenden Delphi-Quelltext
1:
GetMonitorInfo(MonitorHandle, MonInfo);					

Alleerdings befindet sich im MonInfo nur die größe des Monitors, aber nicht die Position. Laut SDK sollte dort aber auch die Prosition stehen. Oder habe ich mich da verlesen. Wenn ja kann mir einer sagen wie oder besser wo ich die Position von einem Monitor her bekomme?
Und ich möchte keine Komponente oder die Monitors.pas von DElphie benutzen. Benötige das direckt als API lösung.
Das brauche ich um ein fenster auf einen Anderen Monitor zu schicken!

Thx & Cu
Neo
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Fr 21.01.05 02:53 
msdn.microsoft.com/l...gdi/monitor_8woj.asp

ich sehe dort nur funktionen zum auslesen aller möglichen posis, aber keine funktionen zum setzen ala SetWindowMonitor oder so...
NeoInDerMATRIX Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 245

Win95, Win98(+se), WinNT, Win2000, WinME, WinXP(+pro), VISTA, Linux(SuSe), DOS [MultiMon(3)], Vista
D6 PeE + (FP 2.0l) + D3 Pe + D2005+ D2006 Arch
BeitragVerfasst: Fr 21.01.05 14:53 
Hi,

also, soweit ich das weis, liest man die Position mit "GetMonitorInfo" aus. In die strucktur MonitorInfoEx. Unteer rcMonitor oder rcWork. Aber beio Position wird bei mir bei jedem Monitor immer NULL zurückgegeben.

Cu
Neo
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Fr 21.01.05 15:50 
ok, aber das eigentlich problem ist doch wie du das fenster dann auf den andren schirm kriegst ?
NeoInDerMATRIX Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 245

Win95, Win98(+se), WinNT, Win2000, WinME, WinXP(+pro), VISTA, Linux(SuSe), DOS [MultiMon(3)], Vista
D6 PeE + (FP 2.0l) + D3 Pe + D2005+ D2006 Arch
BeitragVerfasst: Fr 21.01.05 16:15 
Hi,

ne das kannst du machen in dem man SetWindowPos oder so verwendest, da windows mit Virtuallen Desktops arbeitet! Nur muss ich dazu wissen ab wo welcher monitor anfängt.

Cu
Neo
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Fr 21.01.05 20:25 
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
unit Unit1;

interface

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

type

  TForm1 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

Function MonitorFromWindow(AWindowHandle: HWND; AFlags: DWORD): cardinal; stdcallExternal 'User32.dll';

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var c,m: cardinal;
    h:pointer;
begin
   c:=findwindow(nil,pchar(edit1.Text));
   m:=MonitorFromWindow(c,0);
   showmessage(inttostr(m));
end;

end.

öffne zum testen z.b. solitär schiebs von einem moni auf den andren und tippe bei eidt1 solitär ein
NeoInDerMATRIX Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 245

Win95, Win98(+se), WinNT, Win2000, WinME, WinXP(+pro), VISTA, Linux(SuSe), DOS [MultiMon(3)], Vista
D6 PeE + (FP 2.0l) + D3 Pe + D2005+ D2006 Arch
BeitragVerfasst: Fr 21.01.05 23:50 
Ja, das geht schon! Aber ich habe eine Auswahl wo die Monitore gelistet sind! Dort wählt man dann direckt auf welchen monitor das fenster gehen soll! Also kann ich das leider nicht so machen! Aber trotzdem danke! Ich muss irgend wie die Position relativ vom Primären monitor raus bekommen! Das muss ja gehen da es bei den System einstelungen auch eingestellt werden kann! Ich weiss nur nicht wie.

Cu
Neo
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Sa 22.01.05 04:05 
probiers mal so: bei dem beispiel wird dir einiges angezeigt, so z.b. das Rect des Monitors. mit dem und der funktion monitorfrompoint kannst du dann leicht überprüfen ob beispielsweise der punkt 0,0 auf schirm 1 oder 2 liegt.

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
unit Unit1;

interface

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

type

  TForm1 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    Timer1: TTimer;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

    TMONITORINFO = record
      cbSize:DWORD;
      rcMonitor:TRECT;
      rcWork:TRECT;
      dwFlags:DWORD;
     end;
    pmonitorinfo = ^TMonitorinfo;

Function GetMonitorInfo(AMonitorHandle: pointer; Var ADataRecord: TMonitorInfo): Boolean; stdcallExternal 'User32.dll' Name 'GetMonitorInfoA'overload;
//Function GetMonitorInfo(AMonitorHandle: HMONITOR; Var ADataRecord: TMonitorInfoEx): Boolean; stdcall; External 'User32.dll' Name 'GetMonitorInfoA'; overload;

Function MonitorFromPoint(APoint: TPoint; AFlags: DWORD): pointer; stdcallExternal 'User32.dll';

Function MonitorFromWindow(AWindowHandle: HWND; AFlags: DWORD): pointer; stdcallExternal 'User32.dll';

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
timer1.Enabled:=true;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var c,m: cardinal;
    p,p2:pointer;
    a:trect;
    cp:^cardinal;
//    mon:pmonitor;
    tmon:tmonitorinfo;
begin
   c:=findwindow(nil,pchar(edit1.Text));
   p:=MonitorFromWindow(c,1);
//   mon := p;
   cp:=p;
   tmon.cbSize := sizeof(tMONITORINFO);
   getmonitorinfo(p, tmon);
   label1.caption := inttohex(cp^,8);      //mon.ID );
   GetwindowRect(c,a);
   label2.Caption := ' t:'+inttostr(a.Top) + ' l:'+inttostr(a.left) +
     ' b:'+inttostr(a.Bottom ) + ' r:'+inttostr(a.right);
//   if mon <> nil then
   a := tmon.rcMonitor ;
   label3.caption:=  ' t:'+inttostr(a.Top) + ' l:'+inttostr(a.left) +
     ' b:'+inttostr(a.Bottom ) + ' r:'+inttostr(a.right);

end;

end.