Access 2003 module not working on Vista?

Does anyone know why the attached code works on XP with Access 2003 and not on Vista with Access 2003?

Any help would be much appreciated.

Option Compare Database
Option Explicit
Private Const conGraphiixFolder As String * 11 = "\InterFace\"
Public Declare Function SetWindowRgn Lib "user32" ( _
                ByVal hWnd As Long, _
                    ByVal hRgn As Long, _
                        ByVal bRedraw As Boolean) As Long
Public Declare Function DeleteObject Lib "gdi32" ( _
                ByVal hObject As Long) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32" ( _
                    ByVal hDC As Long) As Long
Private Declare Function SelectObject Lib "gdi32" ( _
                    ByVal hDC As Long, _
                        ByVal hgdiObj As Long) As Long
Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" ( _
                    ByVal hdiObj As Long, _
                        ByVal cbBuffer As Long, _
                            lpvObject As Any) As Long
Private Declare Function CreateRectRgn Lib "gdi32" ( _
                    ByVal nLeftRect As Long, _
                        ByVal nTopRect As Long, _
                            ByVal nRightRect As Long, _
                                ByVal nBottomRect As Long) As Long
Private Declare Function CombineRgn Lib "gdi32" ( _
                    ByVal hRgnDest As Long, _
                        ByVal hRgnSrc1 As Long, _
                            ByVal hRgnSrc2 As Long, _
                                ByVal fnCombineMode As Long) As Long
Private Declare Function DeleteDC Lib "gdi32" ( _
                    ByVal hDC As Long) As Long
Private Declare Function GetPixel Lib "gdi32" ( _
                    ByVal hDC As Long, _
                        ByVal nXPos As Long, _
                            ByVal nYPos As Long) As Long
Private Type typPicStructure
    bmType As Long
    bmWidth As Long
    bmHeight As Long
    bmWidthBytes As Long
    bmPlanes As Integer
    bmBitsPixel As Integer
    bmBits As Long
End Type
Private Const RGN_OR As Long = 4
Public Function fInitFormShape( _
                    frm As Form, _
                        stPictureName As String, _
                            TransparentColor As Long, _
                                Optional FolderPath As String, _
                                    Optional IndexCollection As Boolean) As Boolean
'// dimension variables
Dim f As Form
Dim objBitmap As StdPicture
Dim hRgn As Long
'// in the event of an error process to our
'// predefined error handler
On Error GoTo Err_finitformshape
    '// set the new picture to scan
    Set objBitmap = fLoadShapedPicture(frm, stPictureName)
    '// first check if the image is found to avoid
    '// any errors down the line, if the image to be used
    '// is not a valid one then exit the function
    If objBitmap Is Nothing Then Exit Function
    '// create object instance
    '// of the form to be shaped
    Set f = frm
    '// reference the created instance
    With f
        '// function to create shaped region region
        '// and return the handle to the new shaped region
        '// which resides in the system's memory buffer
        hRgn = fCreateShapedRegion(objBitmap, TransparentColor)
        '// set the new shaped region of our form
        SetWindowRgn .hWnd, hRgn, True
        fInitFormShape = True
    End With
    '// clean up
    Set f = Nothing
    Set objBitmap = Nothing
    '// delete region from memory
    DeleteObject hRgn
    Exit Function
    '// notify user of error
    MsgBox Err.NUMBER & " : " & Err.Description, vbOKOnly, "Microsoft Access Error"
    '// resume to exit the funtion
    Resume Exit_finitformshape
End Function
Private Function fFileExists(stFileName) As Boolean
'// dimension variable(s)
Dim objFSO As Object
    '// create FileSystemObject
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    '// return True if file is found
    '// return False if not
    fFileExists = objFSO.FileExists(stFileName)
    '// clean up
    Set objFSO = Nothing
End Function
Private Function fLoadShapedPicture(frm As Form, PictureName As String) As StdPicture
'// dimension varible(s)
Dim stBitmapPath  As String
Dim iWidth As Integer
Dim iHeight As Integer
    '// assign picture name & path
    stBitmapPath = CurrentProject.Path & conGraphiixFolder & PictureName
    '// check for file
    If fFileExists(stBitmapPath) Then
        '// reference the background image control
        With frm.Controls("imgFormBG")
            '// load the picture to the form's
            '// background image control
            .Picture = stBitmapPath
            '// move image control to align to form
            '// if you ommit this you will some parts of
            '// image display the transparent color
            .top = 10
            .Left = 10
            '// get image dimensions
            iWidth = .ImageWidth
            iHeight = .ImageHeight
            '// rezise the form to match picture
            .Parent.InsideWidth = iWidth
            .Parent.InsideHeight = iHeight + 10
            '// resize image control to match image
            .Width = iWidth
            .Height = iHeight
        End With
        '// load and return the picture data
        Set fLoadShapedPicture = LoadPicture(stBitmapPath)
        '// notify user image was not found
        MsgBox "The background image for this form was not found.", vbOKOnly + vbInformation
    End If
End Function
Private Property Get fCreateShapedRegion( _
                        BitmapPicture As StdPicture, _
                            TransColor As Long) As Long
'// dimension variable(s)
Dim hRgn As Long
Dim tmpRgn As Long
Dim lngRow As Integer
Dim lngCol As Integer
Dim lngPosition As Integer
Dim hDC As Long
Dim pic As typPicStructure
Dim lngTransColor As Long
    '// assign transparent color
    lngTransColor = TransColor
    '// create a new memory DC(Device Context),
    '// where we will scan the picture
    hDC = CreateCompatibleDC(0)
    '// if the DC exist process procedure
    If hDC Then
        '// let the new DC select the Picture
        SelectObject hDC, BitmapPicture
        '// get the picture dimensions
        GetObject BitmapPicture, Len(pic), pic
        '// create a new empty rectangular region using the
        hRgn = CreateRectRgn(0, 0, pic.bmWidth, pic.bmHeight)
        '// scan the picture pixel by pixel from top to bottom
        For lngRow = 0 To pic.bmHeight
            '// scan the picture pixel by pixel from left to right
            For lngCol = 0 To pic.bmWidth
                '// scan and skip non-transparent pixels
                While lngCol <= pic.bmWidth And GetPixel(hDC, lngCol, lngRow) <> lngTransColor
                    '// add 1 to the variable lngCol
                    '// and we move to the next pixel
                    lngCol = lngCol + 1
                '// remember the position of the first transparent pixel
                lngPosition = lngCol
                '// scan a line for transparent pixels
                While lngCol <= pic.bmWidth And GetPixel(hDC, lngCol, lngRow) = lngTransColor
                    '// add 1 to the variable lngCol
                    '// and move to the next pixel
                    lngCol = lngCol + 1
                If lngPosition < lngCol Then
                    '// create a new temporary transparent region and return it's handle
                    tmpRgn = CreateRectRgn(lngPosition, lngRow, lngCol, lngRow + 1)
                    '// combine the two regions
                    CombineRgn hRgn, hRgn, tmpRgn, RGN_OR
                    '// release memory, delete temporary region
                    DeleteObject tmpRgn
                End If
            Next lngCol
        Next lngRow
        '// return the handle to the new shaped region
        fCreateShapedRegion = hRgn
        '// release memory by deleting the hDc
        DeleteObject SelectObject(hDC, BitmapPicture)
    End If
    '// clean up, release memory by deleting the created DC
    DeleteDC hDC
End Property

Open in new window

Who is Participating?
puppydogbuddyConnect With a Mentor Commented:
Does the code intract with the ms graphics filters? If so, then they are not installed when you only install Access, and may not be installed.

Take your Office CD and do a custom install;
- expand Office Shared Features
- expand converters and filters, install them.
Im wondering whether you have hit the problem identified here

weedavieAuthor Commented:
Apologies for not replying sooner, I haven't had an opportunity to test your suggestions.
I'll give it a go this afternoon / tomorrow.

Many thanks.

weedavieAuthor Commented:
Many thanks, sorry for the late reply
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.