可以做到吗???
解决方案 »
- 求助,我现在需要做直接从COM口打印,打印机是TM U220B,用VB.60 VB.net C#都行,请问有高手做过这方面的没有!!谢谢
- 一个工程可不可以用另一个工程中的Form
- 做系统的人为何看不起做网站的人,不都是写程序吗?真有区别吗?定位不同在何处呢?
- 关于vb6.0中如何锁定使其不能编辑的问题?
- setup factory打包问题
- 一个MDI的问题
- 请问在一个picture中可以同时显示很多张图片吗?
- 无效的数据库???明明是可以的呀!!!(新手问题)谢谢帮忙!!!
- 想知道如何制作向导?摸了半天向导管理器也不得要领
- 请问能不能用vb做一个不规则的窗体?
- [100分全部送]来者有份,决不食言!!
- (100分)其他语言调用VB生成的dll内存出错问题!
StretchBlt。Private Declare Function StretchBlt Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
Image1.Stretch = True
' 将图片在PictureBox控件中按比例缩放后,居中显示
'***************************************************
Public Sub PictureToCenter(tPic As Picture, PicBox As PictureBox)
Dim PicH As Long, PicW As Long
Dim PicBoxW As Long, PicBoxH As Long
Dim PicRate As Single, PicBoxRate As Single
Dim NewH As Long, NewW As Long
PicBoxH = PicBox.ScaleHeight
PicBoxW = PicBox.ScaleWidth
PicBoxRate = PicBoxW / PicBoxH
PicW = ScaleX(tPic.Width, vbHimetric, PicBox.ScaleMode)
PicH = ScaleY(tPic.Height, vbHimetric, PicBox.ScaleMode)
PicRate = PicW / PicH
PicBox.Cls
If PicH <= PicBoxH And PicW <= PicBoxW Then
PicBox.PaintPicture tPic, (PicBoxW - PicW) / 2, (PicBoxH - PicH) / 2
Exit Sub
End If
If PicBoxRate < PicRate Then
NewH = PicBoxW / PicRate
PicBox.PaintPicture tPic, 0, (PicBoxH - NewH) / 2, PicBoxW, NewH
Else
NewW = PicBoxH * PicRate
PicBox.PaintPicture tPic, (PicBoxW - NewW) / 2, 0, NewW, PicBoxH
End If
End Sub'这个过程是我在工程中使用的,可以适应任何比例的图片。
Private Sub Picture1_Click()
Dim p As StdPicture
Set p = LoadPicture("H:\My Documents\Img15644950.jpg")
PictureToCenter p, Picture1
End Sub
用painpicture函数不就行了
Sub ShowPicture(PcitureName As String)
Dim ZX As Single
Dim ZY As Single
With Image1
.Stretch = False
.Visible = False
.Picture = LoadPicture(PictureName)
ZX = .Width / 155 '假设目标宽度为155像素
ZY = .Height / 165 '假设目标高度为165像素
If ZX > ZY Then
ZY = ZX
Else
ZX = ZY
End If
.Stretch = True
.Width = Int(.Width / ZX)
.Height = Int(.Height / ZY)
.Visible = Ture
End With
End Sub