社区
Delphi
帖子详情
为什么我用stringgrid的paintto方法打印出来的控件只有在左上角的一小块
baxp
2001-07-20 12:28:32
为什么我用stringgrid的paintto方法打印出来的控件只有在左上角的一小块
控件缩小了好多倍,而且canvas的大小也缩小了好多,大概只有2*3厘米
...全文
168
6
打赏
收藏
为什么我用stringgrid的paintto方法打印出来的控件只有在左上角的一小块
为什么我用stringgrid的paintto方法打印出来的控件只有在左上角的一小块 控件缩小了好多倍,而且canvas的大小也缩小了好多,大概只有2*3厘米
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
6 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
guig
2001-07-21
打赏
举报
回复
试试这个:
//******* unit1.dfm ************
object Form1: TForm1
Left = 192
Top = 168
Width = 544
Height = 375
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PrintScale = poNone
PixelsPerInch = 96
TextHeight = 13
object StringGrid1: TStringGrid
Left = 40
Top = 112
Width = 337
Height = 209
TabOrder = 0
end
object Button1: TButton
Left = 224
Top = 48
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 1
OnClick = Button1Click
end
end
//******* unit1.pas ************
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Grids;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses
Printers;
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
tb:TBitmap;
Info: PBitmapInfo;
InfoSize: DWORD;
Image: Pointer;
ImageSize: DWORD;
Bits: HBITMAP;
DIBWidth, DIBHeight: Longint;
PrintWidth, PrintHeight: Longint;
begin
Tb := TBitmap.Create;
try
Tb.Width := StringGrid1.Width;
Tb.Height := StringGrid1.Height;
Tb.Canvas.Brush := StringGrid1.Brush;
Tb.Canvas.FillRect(Rect(0,0,Tb.Width,Tb.Height));
Tb.Canvas.Lock;
try
StringGrid1.PaintTo(Tb.Canvas.Handle, 0, 0);
finally
Tb.Canvas.Unlock;
end;
except
Tb.Free;
raise;
end;
Printer.BeginDoc;
try
try
{ Paint bitmap to the printer }
with Printer do
begin
Bits := Tb.Handle;
GetDIBSizes(Bits, InfoSize, ImageSize);
Info := AllocMem(InfoSize);
try
Image := AllocMem(ImageSize);
try
GetDIB(Bits, 0, Info^, Image^);
with Info^.bmiHeader do
begin
DIBWidth := biWidth;
DIBHeight := biHeight;
end;
PrintWidth := MulDiv(DIBWidth, GetDeviceCaps(Handle,
LOGPIXELSX), PixelsPerInch);
PrintHeight := MulDiv(DIBHeight, GetDeviceCaps(Handle,
LOGPIXELSY), PixelsPerInch);
StretchDIBits(Canvas.Handle, 0, 0, PrintWidth, PrintHeight, 0, 0,
DIBWidth, DIBHeight, Image, Info^, DIB_RGB_COLORS, SRCCOPY);
finally
FreeMem(Image, ImageSize);
end;
finally
FreeMem(Info, InfoSize);
end;
end;
finally
end;
finally
tb.free;
Printer.EndDoc;
end;
end;
end.
baxp
2001-07-20
打赏
举报
回复
to: Apollo47(阿波罗)
怎么用,能不能给个例子看看?谢了
Apollo47
2001-07-20
打赏
举报
回复
这是因为打印机和屏幕的单位不同。
GetDriveCaps().
baxp
2001-07-20
打赏
举报
回复
kkkk
Apollo47
2001-07-20
打赏
举报
回复
这里有你想要的:
http://www.csdn.net/expert/topic/201/201720.shtm
baxp
2001-07-20
打赏
举报
回复
help me
reprint
打印
控件
(
打印
datasource,db
grid
,
string
grid
)
本人长期使用delphi做数据库的开发,报表
控件
使用Quickrpt,在
打印
上经常遇到一些问题,于是自己经常编写一部分
打印
的程序,经过总结开发了这个
控件
。 本
控件
可
打印
datasource,db
grid
,
string
grid
. 一 、
控件
...
delphi 在
string
Grid
控件
中嵌入ComboBox
delphi7 在
string
Grid
控件
中嵌入ComboBox;可以直接运行。通过选择ComboBox来修改
string
Grid
的值。代码非常少
Delphi将
String
grid
指定行添加到Memo
控件
中.rar
Delphi将
String
grid
指定行添加到Memo
控件
中,选中
String
Grid
中的行,点击右下角的“添加”按钮,即可将选中的
String
Grid
行数据添加到下边的Memo
控件
中显示。部分源代码如下: procedure TForm1.FormCreate(Sender:...
Delphi为
String
Grid
控件
增加Combobox下拉框.rar
Delphi为
String
Grid
网格显示
控件
中增加下拉框功能,也就是在
Grid
控件
中添加Combobox下拉列表的功能,在任意列显示一个ComboBox功能,如演示截图所示,可大大扩展
Grid
的功能。生成列表: with Sender as TComboBox ...
RePrint表格
打印
控件
(
打印
datasource,db
grid
,
string
grid
)
二 、
控件
方法
: (1) preview 预览 (2) print
打印
(3) SaveToFile() 保存为报表文件 (4) SaveToStream() 保存为流(然后就可把整个报表存到数据库了很方便哦! ~_~) (5) PrintFile()
打印
报表文件 (6) ...
Delphi
5,386
社区成员
262,729
社区内容
发帖
与我相关
我的任务
Delphi
Delphi 开发及应用
复制链接
扫一扫
分享
社区描述
Delphi 开发及应用
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章