谁能用VB帮我编一个简单的程序
用VB语言编写一个图片浏览程序,要求具有图形用户界面(如附件图),能够实现以下操作功能:1、能够显示bmp,jpg,tif格式图片;2、能够实现图片的缩放显示;3、能够浏...
用VB语言编写一个图片浏览程序,要求具有图形用户界面(如附件图),能够实现以下操作功能:
1、能够显示bmp,jpg,tif格式图片;
2、能够实现图片的缩放显示;
3、能够浏览打开指定的图片文件
4、通过TreeView控件对历史文件实现管理
5、除状态栏和标题栏,其它所有控件均可浮动显示
6、其它方便用户操作功能(要求其它功能越多越好)
7、对话框:程序应至少使用一个对话框,对话框中包括如下控件:
复选框、单选按钮、多行文本框、列表框(样式见附件)对话框应实现对程序参数的控制和调整。 展开
1、能够显示bmp,jpg,tif格式图片;
2、能够实现图片的缩放显示;
3、能够浏览打开指定的图片文件
4、通过TreeView控件对历史文件实现管理
5、除状态栏和标题栏,其它所有控件均可浮动显示
6、其它方便用户操作功能(要求其它功能越多越好)
7、对话框:程序应至少使用一个对话框,对话框中包括如下控件:
复选框、单选按钮、多行文本框、列表框(样式见附件)对话框应实现对程序参数的控制和调整。 展开
1个回答
展开全部
碰巧我也在做图片浏览器的程序,我能给你部分代码,有些你要比较难实现。
打开tiff文件的模块
Private Enum GpStatus
[OK] = 0
[GenericError] = 1
[InvalidParameter] = 2
[OutOfMemory] = 3
[ObjectBusy] = 4
[InsufficientBuffer] = 5
[NotImplemented] = 6
[Win32Error] = 7
[WrongState] = 8
[Aborted] = 9
[FileNotFound] = 10
[ValueOverflow ] = 11
[AccessDenied] = 12
[UnknownImageFormat] = 13
[FontFamilyNotFound] = 14
[FontStyleNotFound] = 15
[NotTrueTypeFont] = 16
[UnsupportedGdiplusVersion] = 17
[GdiplusNotInitialized ] = 18
[PropertyNotFound] = 19
[PropertyNotSupported] = 20
End Enum
'需要声明的结构:
Private Type GdiplusStartupInput
GdiplusVersion As Long
DebugEventCallback As Long
SuppressBackgroundThread As Long
SuppressExternalCodecs As Long
End Type
'具体做法如下:
Dim m_lngGraphics As Long
Dim m_lngInstance As Long
Dim m_lngPic As Long
Dim udtData As GdiplusStartupInput
Private Type PICTDESC
Size As Long
Type As Long
hBmpOrIcon As Long
hPal As Long
End Type
Private Declare Function GdiplusStartup Lib "gdiplus" (token As Long, inputbuf As GdiplusStartupInput, Optional ByVal outputbuf As Long = 0) As Long
Private Declare Function GdiplusShutdown Lib "gdiplus" (ByVal token As Long) As Long
Private Declare Function GdipDisposeImage Lib "gdiplus" (ByVal hImage As Long) As GpStatus
Private Declare Function GdipLoadImageFromFile Lib "gdiplus" (ByVal Filename As String, hImage As Long) As GpStatus
Private Declare Function GdipCreateHBITMAPFromBitmap Lib "gdiplus" (ByVal Bitmap As Long, hBmpReturn As Long, ByVal Background As Long) As GpStatus
Private Declare Function OleCreatePictureIndirect Lib "olepro32" (lpPictDesc As PICTDESC, riid As Any, ByVal fPictureOwnsHandle As Long, IPic As IPicture) As Long
Private Declare Function GdipCreateFromHDC Lib "gdiplus.dll" ( _
ByVal hdc As Long, ByRef graphics As Long _
) As GpStatus
Private Declare Function GdipDrawImage Lib "gdiplus.dll" ( _
ByVal graphics As Long, ByVal image As Long, _
ByVal x As Single, ByVal y As Single _
) As GpStatus
Public Function LoadPictureEx(ByVal sFilename As String) As StdPicture
Dim gplRet As Long
Dim hImg As Long
Dim hBmp As Long
Dim uPictDesc As PICTDESC
Dim aGuid(0 To 3) As Long
Dim tSI As GdiplusStartupInput
Dim lGDIP As Long
tSI.GdiplusVersion = 1 ' 初始化 GDI+
gplRet = GdiplusStartup(lGDIP, tSI)
'-- Load image
gplRet = GdipLoadImageFromFile(StrConv(sFilename, vbUnicode), hImg)
'-- Create bitmap
gplRet = GdipCreateHBITMAPFromBitmap(hImg, hBmp, vbBlack)
' Dim m_lngGraphics As Long
' gplRet = GdipCreateFromHDC(frmMain.Picture1.hdc, hImg)
' gplRet = GdipLoadImageFromFile(StrConv(sFilename, vbUnicode), m_lngGraphics)
' gplRet = GdipDrawImage(m_lngGraphics, hImg, 100, 100)
'-- Free image
gplRet = GdipDisposeImage(hImg)
If (gplRet = [OK]) Then
'-- Fill struct
With uPictDesc
.Size = Len(uPictDesc)
.Type = vbPicTypeBitmap
.hBmpOrIcon = hBmp
.hPal = 0
End With
'-- Fill in magic IPicture GUID {7BF80980-BF32-101A-8BBB-00AA00300CAB}
aGuid(0) = &H7BF80980
aGuid(1) = &H101ABF32
aGuid(2) = &HAA00BB8B
aGuid(3) = &HAB0C3000
'-- Create picture from bitmap handle
OleCreatePictureIndirect uPictDesc, aGuid(0), -1, LoadPictureEx
End If
GdiplusShutdown lGDIP '销毁 GDI+
End Function
针对图片缩放我没有通用的代码,但我有针对问题的代码。
浏览打开指定的图片文件 用CommonDialogControl
TreeView在VB6中与VB8中,使用方式有不同。
qq:453628001
打开tiff文件的模块
Private Enum GpStatus
[OK] = 0
[GenericError] = 1
[InvalidParameter] = 2
[OutOfMemory] = 3
[ObjectBusy] = 4
[InsufficientBuffer] = 5
[NotImplemented] = 6
[Win32Error] = 7
[WrongState] = 8
[Aborted] = 9
[FileNotFound] = 10
[ValueOverflow ] = 11
[AccessDenied] = 12
[UnknownImageFormat] = 13
[FontFamilyNotFound] = 14
[FontStyleNotFound] = 15
[NotTrueTypeFont] = 16
[UnsupportedGdiplusVersion] = 17
[GdiplusNotInitialized ] = 18
[PropertyNotFound] = 19
[PropertyNotSupported] = 20
End Enum
'需要声明的结构:
Private Type GdiplusStartupInput
GdiplusVersion As Long
DebugEventCallback As Long
SuppressBackgroundThread As Long
SuppressExternalCodecs As Long
End Type
'具体做法如下:
Dim m_lngGraphics As Long
Dim m_lngInstance As Long
Dim m_lngPic As Long
Dim udtData As GdiplusStartupInput
Private Type PICTDESC
Size As Long
Type As Long
hBmpOrIcon As Long
hPal As Long
End Type
Private Declare Function GdiplusStartup Lib "gdiplus" (token As Long, inputbuf As GdiplusStartupInput, Optional ByVal outputbuf As Long = 0) As Long
Private Declare Function GdiplusShutdown Lib "gdiplus" (ByVal token As Long) As Long
Private Declare Function GdipDisposeImage Lib "gdiplus" (ByVal hImage As Long) As GpStatus
Private Declare Function GdipLoadImageFromFile Lib "gdiplus" (ByVal Filename As String, hImage As Long) As GpStatus
Private Declare Function GdipCreateHBITMAPFromBitmap Lib "gdiplus" (ByVal Bitmap As Long, hBmpReturn As Long, ByVal Background As Long) As GpStatus
Private Declare Function OleCreatePictureIndirect Lib "olepro32" (lpPictDesc As PICTDESC, riid As Any, ByVal fPictureOwnsHandle As Long, IPic As IPicture) As Long
Private Declare Function GdipCreateFromHDC Lib "gdiplus.dll" ( _
ByVal hdc As Long, ByRef graphics As Long _
) As GpStatus
Private Declare Function GdipDrawImage Lib "gdiplus.dll" ( _
ByVal graphics As Long, ByVal image As Long, _
ByVal x As Single, ByVal y As Single _
) As GpStatus
Public Function LoadPictureEx(ByVal sFilename As String) As StdPicture
Dim gplRet As Long
Dim hImg As Long
Dim hBmp As Long
Dim uPictDesc As PICTDESC
Dim aGuid(0 To 3) As Long
Dim tSI As GdiplusStartupInput
Dim lGDIP As Long
tSI.GdiplusVersion = 1 ' 初始化 GDI+
gplRet = GdiplusStartup(lGDIP, tSI)
'-- Load image
gplRet = GdipLoadImageFromFile(StrConv(sFilename, vbUnicode), hImg)
'-- Create bitmap
gplRet = GdipCreateHBITMAPFromBitmap(hImg, hBmp, vbBlack)
' Dim m_lngGraphics As Long
' gplRet = GdipCreateFromHDC(frmMain.Picture1.hdc, hImg)
' gplRet = GdipLoadImageFromFile(StrConv(sFilename, vbUnicode), m_lngGraphics)
' gplRet = GdipDrawImage(m_lngGraphics, hImg, 100, 100)
'-- Free image
gplRet = GdipDisposeImage(hImg)
If (gplRet = [OK]) Then
'-- Fill struct
With uPictDesc
.Size = Len(uPictDesc)
.Type = vbPicTypeBitmap
.hBmpOrIcon = hBmp
.hPal = 0
End With
'-- Fill in magic IPicture GUID {7BF80980-BF32-101A-8BBB-00AA00300CAB}
aGuid(0) = &H7BF80980
aGuid(1) = &H101ABF32
aGuid(2) = &HAA00BB8B
aGuid(3) = &HAB0C3000
'-- Create picture from bitmap handle
OleCreatePictureIndirect uPictDesc, aGuid(0), -1, LoadPictureEx
End If
GdiplusShutdown lGDIP '销毁 GDI+
End Function
针对图片缩放我没有通用的代码,但我有针对问题的代码。
浏览打开指定的图片文件 用CommonDialogControl
TreeView在VB6中与VB8中,使用方式有不同。
qq:453628001
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询