delphi2007 教程

delphi2007 教程

首页 新随笔 联系 聚合 管理
  1013 Posts :: 0 Stories :: 28 Comments :: 0 Trackbacks
这个问题有点难。 Delphi / Windows SDK/API
http://www.delphi2007.net/DelphiMultimedia/html/delphi_20061104112712179.html
我想得到其它应用程序的窗口大小和区域,不知道怎么办?请高手指点。  
  最好能有源代码。

var   aRect:   TRect;  
  begin  
      GetWindowRect(Handle,aRect);  
      ShowMessage(Format('(%d,%d,%d,%d)   Height:%d   Width:%d',[aRect.Left,aRect.Top,aRect.Right,aRect.Bottom,aRect.Bottom-aRect.Top,aRect.Right-aRect.Left]));  
  end;

楼上的是用窗口句柄取得窗口大小  
   
  别的应用程序的窗口句柄用   FindWindow   取得  
   
  Handle   :=   FindWindow(nil,   '窗口的标题');  
   
  如果窗口标题相同就没办法了,   会找到第一个相同的窗口

恩,高手。谢谢你们。  
  不过我还有一个问题,我想鼠标移动到一个窗口上的时候,把它的边框加粗(用颜色显示出来),这个通过你们的提示已经可以实现了,可是,我想在鼠标离开的时候就还原,怎么对别的应用程序的窗口实现这个功能,感觉一画上去就不知道怎么还原了,给点提示。谢谢了。。。  
 

我还想问一个问题。用什么方法可以通过句柄得到其它窗口边框的颜色。谢谢各位的参与。  
 

越问越多了哈  
   
  COLORREF   GetPixel(  
          HDC   hdc, //   handle   of   device   context      
          int   XPos, //   x-coordinate   of   pixel    
          int   nYPos   //   y-coordinate   of   pixel    
        );  
  得到定点处的   Color  
   
  要的参数是   DC  
   
  HDC   GetDC(  
      HWND   hWnd   //   handle   of   window      
        );  
  用你的窗口句柄取得

忘了说   上面   getdc   是取得客户区的,   想取得整个窗口可以用    
   
  HDC   GetDCEx(  
   
          HWND   hWnd, //   handle   of   window    
          HRGN   hrgnClip, //   handle   of   clip   region      
          DWORD   flags   //   device-context   creation   flags    
        );  
     
  怕你还问,   再说,   那两个   pos   是相对于窗口的,   相对于屏幕的   pos   要作一次转换  
   
  BOOL   ClientToScreen(  
   
          HWND   hWnd, //   window   handle   for   source   coordinates    
          LPPOINT   lpPoint   //   pointer   to   structure   containing   screen   coordinates      
        );  
  用的是(delphi)TPoint   结构  
   
  取得   mouse   当前位置的是    
   
  BOOL   GetCursorPos(  
   
          LPPOINT   lpPoint   //   address   of   structure   for   cursor   position      
        );  
  相对   delphi   参数应该是   var   Point:   TPoint,   这个取得的是相对屏幕的   mouse   cursor   位置

上面   ClientToScreen   说倒了,   你要用   ScreenToClient

posted on 2008-11-05 09:37 delphi2007 阅读(248) 评论(0)  编辑 收藏 引用
只有注册用户登录后才能发表评论。