Public CcWz As String
Public Yxdate As Date
Public PbCn As Connection
Dim AqRec As Recordset '安全记录集Private Sub CboDw_Click()
Dim idz As Integer
AqRec.Open "select id from dwb where dwmc='" & CboDw.Text & "'", PbCn, adOpenDynamic, adLockReadOnly
idz = AqRec(0)
AqRec.Close
GrdAqTs.Rows = 1
AqRec.Open "select aqxm.aqxm,jzrq,xsbz from aqts,aqxm where aqts.xm=aqxm.id and dw=" & idz, PbCn, adOpenDynamic, adLockReadOnly '打开安全天数表
Do While Not AqRec.EOF
GrdAqTs.Rows = GrdAqTs.Rows + 1
GrdAqTs.Row = GrdAqTs.Rows - 1
GrdAqTs.TextArray(GrdAqTs.Cols * GrdAqTs.Row) = GrdAqTs.Row
GrdAqTs.TextArray(GrdAqTs.Cols * GrdAqTs.Row + 1) = Trim(AqRec(0))
GrdAqTs.TextArray(GrdAqTs.Cols * GrdAqTs.Row + 2) = AqRec(1)
GrdAqTs.TextArray(GrdAqTs.Cols * GrdAqTs.Row + 3) = Date - AqRec(1)
If AqRec(2) Then
GrdAqTs.TextArray(GrdAqTs.Cols * GrdAqTs.Row + 4) = "是"
Else
GrdAqTs.TextArray(GrdAqTs.Cols * GrdAqTs.Row + 4) = "否"
End If
AqRec.MoveNext
Loop
AqRec.Close
End SubPrivate Sub Form_Activate()
Dim idz As Integer
Dim wjm As String
Dim i As Integer
Dim pb As Boolean
For i = 0 To CboDw.ListCount - 1
AqRec.Open "select id,scwjm from dwb where dwmc='" & CboDw.List(i) & "'", PbCn, adOpenDynamic, adLockReadOnly
idz = AqRec(0)
wjm = Trim(AqRec(1))
AqRec.Close
pb = False
PicXs.Cls
PicXs.FontBold = True
PicXs.FontSize = 15
PicXs.CurrentY = PicXs.TextHeight(CboDw.Text) + 9
PicXs.FontBold = False
PicXs.FontSize = 12
GrdAqTs.Rows = 1
AqRec.Open "select aqxm.aqxm,jzrq,xsbz from aqts,aqxm where aqts.xm=aqxm.id and dw=" & idz, PbCn, adOpenDynamic, adLockReadOnly '打开安全天数表
Do While Not AqRec.EOF
If AqRec("xsbz") Then
PicXs.CurrentX = 0
PicXs.Print Trim(AqRec(0)) + Space(2 * (9 - Len(Trim(AqRec(0))))) & Space(4 - Len(Date - AqRec(1))) & Date - AqRec(1) & "天";
PicXs.CurrentY = PicXs.CurrentY + PicXs.TextHeight(Trim(AqRec(0))) + 8
pb = True
End If
AqRec.MoveNext
Loop
AqRec.Close
If pb = True Then
PicXs.FontBold = True
PicXs.FontSize = 15
PicXs.CurrentX = (PicXs.Width - PicXs.TextWidth(CboDw.List(i)))
If PicXs.CurrentX < 0 Then
PicXs.FontSize = 14
PicXs.CurrentX = (PicXs.Width - PicXs.TextWidth(CboDw.List(i)))
End If
If PicXs.CurrentX < 0 Then
PicXs.FontSize = 13
PicXs.CurrentX = (PicXs.Width - PicXs.TextWidth(CboDw.List(i)))
End If
PicXs.CurrentY = 2
PicXs.Print CboDw.List(i)
SavePicture PicXs.Image, CcWz & "\" & wjm & ".jpg"
End If
Next i
EndEnd SubPrivate Sub Form_Load()
Dim Csql As String
If Dir(App.Path & "\gcc.ini") <> "" Then
Open App.Path & "\gcc.ini" For Input As #1
Line Input #1, CcWz
Close #1
Else
MsgBox " 系统配置文件gcc.ini不存在! ", 0, App.Title
End
End If
Yxdate = Date
Set PbCn = New Connection
Csql = "driver=MicroSoft Access Driver (*.mdb);dbq=" & App.Path & "\aqts.mdb" & ";UID=admin;"
PbCn.Open Csql
With GrdAqTs
For i = 0 To .Cols - 1 '网格行列对中
.ColAlignment(i) = 4
.FixedAlignment(i) = 4
Next i
'以下定义网格的列宽和行高
.ColWidth(0) = 1000
.ColWidth(1) = 3000
.ColWidth(2) = 2000
.ColWidth(3) = 2000
.ColWidth(4) = 1950
.Row = 0
.TextArray(0) = "序号" '以下定义网格的列名
.TextArray(1) = "安全揭示项目"
.TextArray(2) = "基准日期"
.TextArray(3) = "安全天数"
.TextArray(4) = "是否显示"
End With
Set AqRec = New Recordset
AqRec.Open "dwb", PbCn, adOpenDynamic, adLockReadOnly '打开单位表
Do While Not AqRec.EOF
CboDw.AddItem AqRec("dwmc")
AqRec.MoveNext
Loop
AqRec.CloseEnd Sub
这段代码执行后生成一幅192×192的BMP文件,黑底白字。现在需要生成1024×768的白底黑字的图片,该如何修改?
Public Yxdate As Date
Public PbCn As Connection
Dim AqRec As Recordset '安全记录集Private Sub CboDw_Click()
Dim idz As Integer
AqRec.Open "select id from dwb where dwmc='" & CboDw.Text & "'", PbCn, adOpenDynamic, adLockReadOnly
idz = AqRec(0)
AqRec.Close
GrdAqTs.Rows = 1
AqRec.Open "select aqxm.aqxm,jzrq,xsbz from aqts,aqxm where aqts.xm=aqxm.id and dw=" & idz, PbCn, adOpenDynamic, adLockReadOnly '打开安全天数表
Do While Not AqRec.EOF
GrdAqTs.Rows = GrdAqTs.Rows + 1
GrdAqTs.Row = GrdAqTs.Rows - 1
GrdAqTs.TextArray(GrdAqTs.Cols * GrdAqTs.Row) = GrdAqTs.Row
GrdAqTs.TextArray(GrdAqTs.Cols * GrdAqTs.Row + 1) = Trim(AqRec(0))
GrdAqTs.TextArray(GrdAqTs.Cols * GrdAqTs.Row + 2) = AqRec(1)
GrdAqTs.TextArray(GrdAqTs.Cols * GrdAqTs.Row + 3) = Date - AqRec(1)
If AqRec(2) Then
GrdAqTs.TextArray(GrdAqTs.Cols * GrdAqTs.Row + 4) = "是"
Else
GrdAqTs.TextArray(GrdAqTs.Cols * GrdAqTs.Row + 4) = "否"
End If
AqRec.MoveNext
Loop
AqRec.Close
End SubPrivate Sub Form_Activate()
Dim idz As Integer
Dim wjm As String
Dim i As Integer
Dim pb As Boolean
For i = 0 To CboDw.ListCount - 1
AqRec.Open "select id,scwjm from dwb where dwmc='" & CboDw.List(i) & "'", PbCn, adOpenDynamic, adLockReadOnly
idz = AqRec(0)
wjm = Trim(AqRec(1))
AqRec.Close
pb = False
PicXs.Cls
PicXs.FontBold = True
PicXs.FontSize = 15
PicXs.CurrentY = PicXs.TextHeight(CboDw.Text) + 9
PicXs.FontBold = False
PicXs.FontSize = 12
GrdAqTs.Rows = 1
AqRec.Open "select aqxm.aqxm,jzrq,xsbz from aqts,aqxm where aqts.xm=aqxm.id and dw=" & idz, PbCn, adOpenDynamic, adLockReadOnly '打开安全天数表
Do While Not AqRec.EOF
If AqRec("xsbz") Then
PicXs.CurrentX = 0
PicXs.Print Trim(AqRec(0)) + Space(2 * (9 - Len(Trim(AqRec(0))))) & Space(4 - Len(Date - AqRec(1))) & Date - AqRec(1) & "天";
PicXs.CurrentY = PicXs.CurrentY + PicXs.TextHeight(Trim(AqRec(0))) + 8
pb = True
End If
AqRec.MoveNext
Loop
AqRec.Close
If pb = True Then
PicXs.FontBold = True
PicXs.FontSize = 15
PicXs.CurrentX = (PicXs.Width - PicXs.TextWidth(CboDw.List(i)))
If PicXs.CurrentX < 0 Then
PicXs.FontSize = 14
PicXs.CurrentX = (PicXs.Width - PicXs.TextWidth(CboDw.List(i)))
End If
If PicXs.CurrentX < 0 Then
PicXs.FontSize = 13
PicXs.CurrentX = (PicXs.Width - PicXs.TextWidth(CboDw.List(i)))
End If
PicXs.CurrentY = 2
PicXs.Print CboDw.List(i)
SavePicture PicXs.Image, CcWz & "\" & wjm & ".jpg"
End If
Next i
EndEnd SubPrivate Sub Form_Load()
Dim Csql As String
If Dir(App.Path & "\gcc.ini") <> "" Then
Open App.Path & "\gcc.ini" For Input As #1
Line Input #1, CcWz
Close #1
Else
MsgBox " 系统配置文件gcc.ini不存在! ", 0, App.Title
End
End If
Yxdate = Date
Set PbCn = New Connection
Csql = "driver=MicroSoft Access Driver (*.mdb);dbq=" & App.Path & "\aqts.mdb" & ";UID=admin;"
PbCn.Open Csql
With GrdAqTs
For i = 0 To .Cols - 1 '网格行列对中
.ColAlignment(i) = 4
.FixedAlignment(i) = 4
Next i
'以下定义网格的列宽和行高
.ColWidth(0) = 1000
.ColWidth(1) = 3000
.ColWidth(2) = 2000
.ColWidth(3) = 2000
.ColWidth(4) = 1950
.Row = 0
.TextArray(0) = "序号" '以下定义网格的列名
.TextArray(1) = "安全揭示项目"
.TextArray(2) = "基准日期"
.TextArray(3) = "安全天数"
.TextArray(4) = "是否显示"
End With
Set AqRec = New Recordset
AqRec.Open "dwb", PbCn, adOpenDynamic, adLockReadOnly '打开单位表
Do While Not AqRec.EOF
CboDw.AddItem AqRec("dwmc")
AqRec.MoveNext
Loop
AqRec.CloseEnd Sub
这段代码执行后生成一幅192×192的BMP文件,黑底白字。现在需要生成1024×768的白底黑字的图片,该如何修改?
http://community.csdn.net/Expert/topic/4177/4177204.xml?temp=.2139551
SavePicture PicXs.Image, CcWz & "\" & wjm & ".jpg"
尽管你保存的文件的扩展名是jpg,但SavePicture语句保存的其实还是bmp文件,想保存为jpg文件,就看我给你的链接第二,你的要求还不明确,将图片大小更改之后,文字的大小是否随之改变,不过,不管怎么样,你都可以考虑这样:
先创建一个内存设备场景 (用CreateCompatibleDC,然后创建一个设备有关位图(用CreateCompatibleBitmap),接着为DC选定bitmap(SelectObject),然后根据背景色填充DC(先创建一个画刷(CreateSolidBrush),然后调用FillRect),接着将你的picturebox上的图形复制到DC上(用bitblt,如果需要缩放的话就用StretchBlt),然后根据DC,保存图片(需要根据bmp的文件格式写,可以参考:http://search.csdn.net/Expert/topic/1538/1538596.xml?temp=.5703699),最后进行清理工作,释放调用的对象
A:将一个128*128的bmp所方成一个1024*768的BMP
B:原来程序生成的是128*128的BMP,现在想改成生成1024*768的BMP
如果是B,将PictureBox的大小改成1024*768像素就行了,只不过坐标计算代码要稍微修改一下。如果想让字体变大,修改PictureBox的Font属性就行了。至于改变颜色,修改PictureBox的BackColor、ForeColor属性