home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CommonDial18020462001.psc / OpenImage.ctl < prev    next >
Encoding:
Text File  |  2001-04-07  |  3.8 KB  |  94 lines

  1. VERSION 5.00
  2. Begin VB.UserControl OpenImage 
  3.    ClientHeight    =   480
  4.    ClientLeft      =   0
  5.    ClientTop       =   0
  6.    ClientWidth     =   480
  7.    InvisibleAtRuntime=   -1  'True
  8.    Picture         =   "OpenImage.ctx":0000
  9.    ScaleHeight     =   480
  10.    ScaleWidth      =   480
  11.    ToolboxBitmap   =   "OpenImage.ctx":0104
  12.    Begin VB.Timer Timer1 
  13.       Enabled         =   0   'False
  14.       Interval        =   100
  15.       Left            =   1320
  16.       Top             =   2760
  17.    End
  18.    Begin VB.PictureBox Picture1 
  19.       AutoRedraw      =   -1  'True
  20.       AutoSize        =   -1  'True
  21.       Height          =   1095
  22.       Left            =   2400
  23.       ScaleHeight     =   69
  24.       ScaleMode       =   3  'Pixel
  25.       ScaleWidth      =   85
  26.       TabIndex        =   0
  27.       Top             =   2040
  28.       Width           =   1335
  29.    End
  30. End
  31. Attribute VB_Name = "OpenImage"
  32. Attribute VB_GlobalNameSpace = False
  33. Attribute VB_Creatable = True
  34. Attribute VB_PredeclaredId = False
  35. Attribute VB_Exposed = False
  36. 'This API is used by timer1 to draw the selected image
  37. 'and print the file details on the commondialog
  38. Option Explicit
  39. Private Declare Function SetRect Lib "user32" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
  40. Private Declare Function DrawEdge Lib "user32" (ByVal hdc As Long, qrc As RECT, ByVal edge As Long, ByVal grfFlags As Long) As Long
  41. Const BDR_SUNKENOUTER = &H2
  42. Const BDR_RAISEDINNER = &H4
  43. Const EDGE_ETCHED = (BDR_SUNKENOUTER Or BDR_RAISEDINNER)
  44. Const BF_BOTTOM = &H8
  45. Const BF_LEFT = &H1
  46. Const BF_RIGHT = &H4
  47. Const BF_TOP = &H2
  48. Const BF_RECT = (BF_LEFT Or BF_TOP Or BF_RIGHT Or BF_BOTTOM)
  49. Private Type RECT
  50.    Left As Long
  51.    Top As Long
  52.    Right As Long
  53.    Bottom As Long
  54. End Type
  55.  
  56. Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
  57. Private Declare Function SetBkMode Lib "gdi32" (ByVal hdc As Long, ByVal nBkMode As Long) As Long
  58. Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
  59. Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
  60. Private Declare Function CreateFont Lib "gdi32" Alias "CreateFontA" (ByVal nHeight As Long, ByVal nWidth As Long, ByVal nEscapement As Long, ByVal nOrientation As Long, ByVal fnWeight As Long, ByVal fdwItalic As Boolean, ByVal fdwUnderline As Boolean, ByVal fdwStrikeOut As Boolean, ByVal fdwCharSet As Long, ByVal fdwOutputPrecision As Long, ByVal fdwClipPrecision As Long, ByVal fdwQuality As Long, ByVal fdwPitchAndFamily As Long, ByVal lpszFace As String) As Long
  61. Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long
  62. Const TRANSPARENT = 1
  63. Dim mFilter As String
  64. Dim mflags As Long
  65. Dim mInitDir As String
  66. Dim mTitle As String
  67. Dim parent As Long
  68.  
  69. Private Sub Timer1_Timer()
  70. Dim h As Long, w As Long, hTxt As String, wTxt As String, szTxt As String
  71. Dim RT As RECT
  72. 'gather some numbers so we can draw a thumbnail
  73. 'and maintain aspect ratio
  74. If Picture1.Width >= Picture1.Height Then
  75.     w = 80
  76.     h = 80 * Picture1.Height / Picture1.Width
  77. Else
  78.     h = 80
  79.     w = 80 * Picture1.Width / Picture1.Height
  80. End If
  81. 'create a rectangular region for the panel below the standard dialog
  82. SetRect RT, 10, 242, mCdlW - 18, 335
  83. 'draw a frame to hold the image and file details
  84. DrawEdge mDC, RT, EDGE_ETCHED, BF_RECT
  85. 'paint the thumbnail in the panel
  86. StretchBlt mDC, 320, 250, w, h, Picture1.hdc, 0, 0, Picture1.ng, ByVal to2Derdfpk   h = 80 * Picture1.Height / P":" panel
  87. Stretch3nLong
  88. C>fpk   h = 80 * Picturk"
  89.   2
  90.    RiCHED, BF_RECT
  91. 'paint the t ure1.TL( "gdndtec "e= 80 * Picturk"
  92. doi BF_RECT
  93. 'pai_RECT
  94. wEdge mDC, 7kCT
  95. 'mDC, 7kCT
  96. 'mDC