----------------------------------------------------代码一
用SetWindowPos
例:SetWindowPos(form2.handle,HWND_TOPMOST,form1.Left,form1.Top,form1.Width,form1.Height,0);
-----------------------------------------------------代码二
你可以用程序的方法实现:
首先获取该窗口的句柄。Gettopwindow();如果中是想把该窗口中
画面的部分抓取,则需要得到它的 DC ,可用getdc();得到。
然后用函数抓取就可以了。bitblt();函数可以复制窗体。
-----------------------------------------------------代码三
下面,是抓图源代码,里面有你要的代码:
你自己试试看吧。
{our callback function prototype}
function EnumerateWindows(hWnd: HWND; lParam: LPARAM): BOOL; stdcall;
var
Form1: TForm1;
implementation
procedure TForm1.Button1Click(Sender: TObject);
begin
{empty the listbox that will hold the window names}
ListBox1.Items.Clear;
{enumerate all the top-level windows in the system}
EnumWindows(@EnumerateWindows,0);
end;
{these steps execute for every top-level window in the system}
function EnumerateWindows(hWnd: HWND; lParam: LPARAM): BOOL;
var
TheText: Array[0..255] of char; // this holds the window text
begin
{if the window does not have any text...}
if (GetWindowText(hWnd, TheText, 255)=0) then
{...display the window handle and a note...}
Form1.ListBox1.Items.Add(Format('%d = {This window has no text}',[hWnd]))
else
{otherwise display the window handle and the window text}
Form1.ListBox1.Items.Add(Format('%d = %s',[hWnd,TheText]));
{continue enumeration}
Result:=TRUE;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
FoundWindow: HWND;
WindowText: array[0..255] of char;
begin
{find a TEdit child window}
FoundWindow:=FindWindowEx(Form1.Handle, 0, 'TEdit',nil);
{get its text...}
GetWindowText(FoundWindow, WindowText, 255);
{...and display it}
Label1.Caption:='FindWindowEx found window handle '+IntToStr(FoundWindow)+
': '+WindowText;
end;