home *** CD-ROM | disk | FTP | other *** search
- Attribute VB_Name = "Draw"
- 'this module contains some functions and WinAPI declarations needed
- 'in this application: For displaying Open and SaveAs dialogs, ChooseColor
- 'dialog and some other functions
-
- Public Declare Function ChooseColor Lib "comdlg32.dll" Alias "ChooseColorA" (pChoosecolor As TChooseColor) As Long
- Public Const CC_RGBINIT = &H1
-
- Public Type TChooseColor
- lStructSize As Long
- hwndOwner As Long
- hInstance As Long
- rgbResult As Long
- lpCustColors As String
- flags As Long
- lCustData As Long
- lpfnHook As Long
- lpTemplateName As String
- End Type
-
-
- Public Type POINTAPI
- x As Long
- y As Long
- End Type
-
-
- Type OPENFILENAME
- lStructSize As Long
- hwndOwner As Long
- hInstance As Long
- lpstrFilter As String
- lpstrCustomFilter As String
- nMaxCustFilter As Long
- nFilterIndex As Long
- lpstrFile As String
- nMaxFile As Long
- lpstrFileTitle As String
- nMaxFileTitle As Long
- lpstrInitialDir As String
- lpstrTitle As String
- flags As Long
- nFileOffset As Integer
- nFileExtension As Integer
- lpstrDefExt As String
- lCustData As Long
- lpfnHook As Long
- lpTemplateName As String
- End Type
-
-
- Public Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
- Public Declare Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (pOpenfilename As OPENFILENAME) As Long
- Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
-
- Public Function OpenPDRFile(strFilter) As String
- Dim fnFileName As OPENFILENAME
-
- With fnFileName
- .lStructSize = Len(fnFileName)
- .hwndOwner = 0
- .lpstrDefExt = "*.pdr"
- .nMaxFile = 256
- .lpstrFilter = strFilter
- .lpstrFile = String(255, " ")
- End With
-
- If GetOpenFileName(fnFileName) Then
- fnFileName.lpstrFile = RTrim(fnFileName.lpstrFile)
- OpenPDRFile = fnFileName.lpstrFile
- Else
- OpenPDRFile = ""
- End If
- End Function
- Public Function SavePDRFile(strFilter) As String
- Dim fnFileName As OPENFILENAME
-
- With fnFileName
- .lStructSize = Len(fnFileName)
- .hwndOwner = 0
- .lpstrDefExt = "*.pdr"
- .nMaxFile = 256
- .lpstrFilter = strFilter
- .lpstrFile = String(255, " ")
- End With
-
- If GetSaveFileName(fnFileName) Then
- fnFileName.lpstrFile = RTrim(fnFileName.lpstrFile)
- SavePDRFile = fnFileName.lpstrFile
- Else
- SavePDRFile = ""
- End If
- End Function
-
-
- Public Function SetColor(crInitColor As OLE_COLOR) As OLE_COLOR
- 'this function displays dialog box for choosing color and returns the color selected
-
- Dim CustomColours() As Byte ' Define array for custom colours.
- ReDim CustomColours(0 To 15) As Byte ' Resize the array to hold the elements.
- Dim structChooseColour As TChooseColor
-
- With structChooseColour
- .hwndOwner = 0
- .lpCustColors = StrConv(CustomColours, vbUnicode)
- ' Pass the custom colours array after converting
- ' it to Unicode using the StrConv function.
- .rgbResult = crInitColor
- .flags = CC_RGBINIT
- .lStructSize = Len(structChooseColour)
- End With
- If ChooseColor(structChooseColour) <> 0 Then
- SetColor = structChooseColour.rgbResult
- Else
- SetColor = crInitColor
- End If
-
- End Function
- Public Function NumberGreaterThanZero(varValue As Variant) As Boolean
-
- If IsNumeric(varValue) Then
- If varValue > 0 Then
- NumberGreaterThanZero = True
- Exit Function
- End If
- End If
-
- MsgBox "You must enter a numeric value, greater than zero!", vbCritical
- NumberGreaterThanZero = False
-
- End Function
-
-