這個問題有點難。

來源:互聯網
上載者:User
這個問題有點難。 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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.