home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 March / Chip_2002-03_cd1.bin / zkuste / delphi / kompon / d56 / MSYSINFO.ZIP / Demos / GUI / WindowProps.pas < prev   
Pascal/Delphi Source File  |  2001-05-23  |  5KB  |  155 lines

  1. unit WindowProps;
  2.  
  3. interface
  4.  
  5. uses 
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls, ExtCtrls, ComCtrls;
  8.  
  9. type
  10.   TpropWindow = class(TFrame)
  11.     pc: TPageControl;
  12.     tsGeneral: TTabSheet;
  13.     stText: TEdit;
  14.     Label24: TLabel;
  15.     stHandle: TStaticText;
  16.     Label26: TLabel;
  17.     stProcess: TStaticText;
  18.     Bevel6: TBevel;
  19.     winIcon: TImage;
  20.     Bevel7: TBevel;
  21.     Label22: TLabel;
  22.     stInst: TStaticText;
  23.     Label25: TLabel;
  24.     stID: TStaticText;
  25.     Label28: TLabel;
  26.     stProc: TStaticText;
  27.     Label23: TLabel;
  28.     stParent: TStaticText;
  29.     Label27: TLabel;
  30.     stData: TStaticText;
  31.     Label32: TLabel;
  32.     stClient: TStaticText;
  33.     Label35: TLabel;
  34.     stRect: TStaticText;
  35.     Label49: TLabel;
  36.     stThread: TStaticText;
  37.     tsStyle: TTabSheet;
  38.     tsClass: TTabSheet;
  39.     Label29: TLabel;
  40.     stAtom: TStaticText;
  41.     Label31: TLabel;
  42.     stCBytes: TStaticText;
  43.     Bevel8: TBevel;
  44.     Label36: TLabel;
  45.     stCName: TEdit;
  46.     Label38: TLabel;
  47.     stCInst: TStaticText;
  48.     Label42: TLabel;
  49.     stCWndproc: TStaticText;
  50.     Label44: TLabel;
  51.     stWBytes: TStaticText;
  52.     Label30: TLabel;
  53.     stHBkg: TStaticText;
  54.     Label37: TLabel;
  55.     stHCur: TStaticText;
  56.     Label46: TLabel;
  57.     stHIcon: TStaticText;
  58.     Bevel10: TBevel;
  59.     Bevel9: TBevel;
  60.     lbcs: TListBox;
  61.     lbws: TListBox;
  62.     lbwes: TListBox;
  63.     Label1: TLabel;
  64.     Label2: TLabel;
  65.     Label3: TLabel;
  66.     bVisible: TButton;
  67.     procedure cmVisible(Sender: TObject);
  68.   private
  69.     FWindow: TObject;
  70.   public
  71.     property Window: TObject read FWindow write FWindow;
  72.     procedure Refresh;
  73.   end;
  74.  
  75. implementation
  76.  
  77. uses MiTec_Routines;
  78.  
  79. {$R *.DFM}
  80.  
  81. { TpropWindow }
  82.  
  83. procedure TpropWindow.Refresh;
  84. begin
  85.   with MiTeC_Routines.PWindow(Window)^ do begin
  86.     if IsWindowVisible(PWindow(Window)^.Handle) then
  87.       bVisible.Caption:='&Hide'
  88.     else
  89.       bVisible.Caption:='&Show';
  90.     bVisible.Enabled:=IsWindow(Handle);
  91.     stText.Text:=Text;
  92.     stHandle.Caption:=Format('%d (0x%0:x)',[Handle]);
  93.     stProcess.Caption:=Format('%d (0x%0:x)',[Process]);
  94.     stThread.Caption:=Format('%d (0x%0:x)',[Thread]);
  95.     stParent.Caption:=Format('%d (0x%0:x)',[ParentWin]);
  96.     stProc.Caption:=Format('%d (0x%0:x)',[WndProc]);
  97.     stInst.Caption:=Format('%d (0x%0:x)',[Instance]);
  98.     stID.Caption:=Format('%d (0x%0:x)',[ID]);
  99.     stData.Caption:=Format('%d (0x%0:x)',[UserData]);
  100.     stRect.Caption:=Format('(%d,%d)-(%d,%d), %dx%d',[Rect.Left,Rect.Top,
  101.                                                      Rect.Right,Rect.Bottom,
  102.                                                      Rect.Right-Rect.Left,
  103.                                                      Rect.Bottom-Rect.Top]);
  104.     stClient.Caption:=Format('(%d,%d)-(%d,%d), %dx%d',[ClientRect.Left,ClientRect.Top,
  105.                                                        ClientRect.Right,ClientRect.Bottom,
  106.                                                        ClientRect.Right-ClientRect.Left,
  107.                                                        ClientRect.Bottom-ClientRect.Top]);
  108.  
  109.     with lbWS, Items do begin
  110.       BeginUpdate;
  111.       Clear;
  112.       AddStrings(Styles);
  113.       EndUpdate;
  114.     end;
  115.     with lbWES, Items do begin
  116.       BeginUpdate;
  117.       Clear;
  118.       AddStrings(ExStyles);
  119.       EndUpdate;
  120.     end;
  121.  
  122.     stCName.Text:=ClassName;
  123.     stAtom.Caption:=Format('%d (0x%0:x)',[Atom]);
  124.     stCBytes.Caption:=Format('%d (0x%0:x)',[ClassBytes]);
  125.     stWBytes.Caption:=Format('%d (0x%0:x)',[WinBytes]);
  126.     stCWndProc.Caption:=Format('%d (0x%0:x)',[ClassWndProc]);
  127.     stCInst.Caption:=Format('%d (0x%0:x)',[ClassInstance]);
  128.     stHBkg.Caption:=Format('%d (0x%0:x)',[Background]);
  129.     stHCur.Caption:=Format('%d (0x%0:x)',[Cursor]);
  130.     stHIcon.Caption:=Format('%d (0x%0:x)',[Icon]);
  131.     with lbCS, Items do begin
  132.       BeginUpdate;
  133.       Clear;
  134.       AddStrings(ClassStyles);
  135.       EndUpdate;
  136.     end;
  137.   end;
  138.   winIcon.Picture.Icon.Handle:=SendMessage(PWindow(Window)^.Handle,WM_GETICON,ICON_BIG,0);
  139. end;
  140.  
  141. procedure TpropWindow.cmVisible(Sender: TObject);
  142. var
  143.   Flags :Longword;
  144. begin
  145.   if IsWindowVisible(PWindow(Window)^.Handle) then
  146.     Flags:=SWP_NOZORDER+SWP_NOMOVE+SWP_NOSIZE+SWP_HIDEWINDOW
  147.   else
  148.     Flags:=SWP_NOZORDER+SWP_NOMOVE+SWP_NOSIZE+SWP_SHOWWINDOW;
  149.   if not SetWindowPos(PWindow(Window)^.Handle,HWND_TOP,0,0,0,0,Flags) then
  150.     MessageDlg('This window no longer exists.',mtwarning,[mbok],0);
  151.   Refresh;
  152. end;
  153.  
  154. end.
  155.