C#的简单例子转成DELPHI的有关问题请问
C#的简单例子转成DELPHI的问题请教
请问如下的东东转成DELPHI的,为何截图是黑的:
private void PrintBu_Click(object sender, EventArgs e)
{
if (this.Title_tb.Text != " ")
{
IntPtr Wind_hwnd = Code.Win32Api.FindWindow( "SciCalc ", "计算器 ");
IntPtr hscrdc = Code.Win32Api.GetWindowDC(Wind_hwnd);
Code.Win32Api.RECT Rect = new PrintWindow.Code.Win32Api.RECT();
Code.Win32Api.GetWindowRect(Wind_hwnd,ref Rect);
IntPtr hbitmap = Code.Win32Api.CreateCompatibleBitmap(hscrdc, Rect.Right-Rect.Left, Rect.Bottom-Rect.Top);
IntPtr hmemdc = Code.Win32Api.CreateCompatibleDC(hscrdc);
Code.Win32Api.SelectObject(hmemdc, hbitmap);
Code.Win32Api.PrintWindow(Wind_hwnd, hmemdc, 0);
Bitmap bmp = Bitmap.FromHbitmap(hbitmap);
Code.Win32Api.DeleteDC(hscrdc);//删除用过的对象
Code.Win32Api.DeleteDC(hmemdc);//删除用过的对象
this.PhotoShow.Image = bmp;
this.PhotoShow.Refresh();
}
}
-------------------------------------------------
我转成DELPHI:
function PrintWindow(hwnd:HWND;hdcBlt:HWND;nFlags:word ):boolean;far;external 'user32.dll ';
....
procedure TForm1.Button3Click(Sender: TObject);
var
Wind_hwnd,hscrdc, hbitmap, hmemdc: Integer;
Rect: TRect;
Map: TBitMap;
begin
Map := TBitMap.Create;
Map.Width := 500;
Map.Height := 500;
请问如下的东东转成DELPHI的,为何截图是黑的:
private void PrintBu_Click(object sender, EventArgs e)
{
if (this.Title_tb.Text != " ")
{
IntPtr Wind_hwnd = Code.Win32Api.FindWindow( "SciCalc ", "计算器 ");
IntPtr hscrdc = Code.Win32Api.GetWindowDC(Wind_hwnd);
Code.Win32Api.RECT Rect = new PrintWindow.Code.Win32Api.RECT();
Code.Win32Api.GetWindowRect(Wind_hwnd,ref Rect);
IntPtr hbitmap = Code.Win32Api.CreateCompatibleBitmap(hscrdc, Rect.Right-Rect.Left, Rect.Bottom-Rect.Top);
IntPtr hmemdc = Code.Win32Api.CreateCompatibleDC(hscrdc);
Code.Win32Api.SelectObject(hmemdc, hbitmap);
Code.Win32Api.PrintWindow(Wind_hwnd, hmemdc, 0);
Bitmap bmp = Bitmap.FromHbitmap(hbitmap);
Code.Win32Api.DeleteDC(hscrdc);//删除用过的对象
Code.Win32Api.DeleteDC(hmemdc);//删除用过的对象
this.PhotoShow.Image = bmp;
this.PhotoShow.Refresh();
}
}
-------------------------------------------------
我转成DELPHI:
function PrintWindow(hwnd:HWND;hdcBlt:HWND;nFlags:word ):boolean;far;external 'user32.dll ';
....
procedure TForm1.Button3Click(Sender: TObject);
var
Wind_hwnd,hscrdc, hbitmap, hmemdc: Integer;
Rect: TRect;
Map: TBitMap;
begin
Map := TBitMap.Create;
Map.Width := 500;
Map.Height := 500;