[AccessD] 32/64 bit app; Getting closer

Rocky Smolin rockysmolin at bchacc.com
Tue Feb 12 13:25:58 CST 2019


Dear List:

Got the open file dialog box working in both 32 and 64 bit environments. 
However, the app compiles in 32 bit, and can create an accde, which is
necessary as the app is being distributed to customers.  However, the app
will not compile in 64 bit  Access. I’m not sure how the app is running in
64 bit at all – my experience is that if there’s a compile error the app
breaks on startup.

The code for this function – EnumFontNames  is posted below.

The error is:  Type Mismatch and it occurs in the line .lngType = lngType.  

If I comment that line out the next compile error is: Type Mismatch Array or
User Defined Type Expected.  And the line where the compile error occurs is
.lngSizeCount = adhRemoveDups(malngSizes) where malngSizes is highlighted.

If I comment out that line, the next line to produce a compile error says:
Can’t assign to array, and the line where the compile error occurs is
.alngSizes = malngSizes where .alngSizes is highlighted.

I stopped commenting out lines at that point.

I am not the primary programmer for this app any more but I’m trying to help
them find a solution as the primary programmer is on a crash project to
convert this whole app to a different platform.  

So.  Does anyone see the problem, here?  I’m trying not to go to conditional
compile if possible, but find code that will work in both environments.

MTIA

Rocky Smolin
Beach Access Software
760-683-5777
www.bchacc.com
www.e-z-mrp.com
Skype: rocky.smolin

Friend Function EnumFontNames(lf As LOGFONT, tm As TEXTMETRIC, _
ByVal lngType As LongPtr, lngParam As LongPtr) As LongPtr
    
    ' From Access 2000 Developer's Handbook, Volume I
    ' by Getz, Litwin, and Gilbert. (Sybex)
    ' Copyright 1999. All rights reserved.
    '
    ' This function is declared as "friend" so that
    ' if you move it to an ActiveX DLL, this function
    ' won't be available outside the project.
    On Error GoTo HandleErrors
    
    Const RASTER_FONTTYPE = &H1
    
    If lngParam = 0 Then
        ' If passed a 1, we're only counting
        ' sizes, not doing anything with them.
        mintFontCount = mintFontCount + 1
    Else
        ' lngParam contains LOGPIXELSY value.
        With mafiFonts(mintItems)
            .lngType = lngType
            .strFaceName = adhTrimNull(StrConv(lf.lfFaceName, vbUnicode))
            .fIsRasterFont = _
             ((.lngType And RASTER_FONTTYPE) = RASTER_FONTTYPE)
            If .fIsRasterFont Then
                lf.lfCharSet = DEFAULT_CHARSET
                mlngSizeCount = 0
                ' Get the number of fonts (passing
                ' 0 for the final parameter tells the
                ' callback that you only want to count
                ' sizes, not enumerate them.
                Call EnumFontFamilies(mhDC, .strFaceName, _
                 AddressOf EnumFontSizesProc, 0)
                ' Now mlngSizeCount should contain
                ' the number of items.
                Dim mlngSizeCountTemp As Integer
                mlngSizeCountTemp = mlngSizeCount
                ReDim malngSizes(0 To mlngSizeCount)
                mintFont = 0
                ' Fill in the array of font sizes. The final
                ' parameter contains the twips/pixel ratio,
                ' and by virtue of being non-zero indicates
                ' to the callback procedure that you want
                ' to enumerate the sizes.
                Call EnumFontFamilies(mhDC, .strFaceName, _
                 AddressOf EnumFontSizesProc, lngParam)
                ' Sort the array of font sizes.
                Call adhQuickSort(malngSizes)
                ' Remove duplicate font sizes (and there
                ' will be duplicates) and store the number
                ' of different sizes in lngSizeCount.
                .lngSizeCount = adhRemoveDups(malngSizes)
                
                ' Return the array of sizes itself.
                .alngSizes = malngSizes
            Else
                ' For TrueType fonts, return -1
                ' for the number of sizes.
                .lngSizeCount = -1
            End If
        End With
    End If
    mintItems = mintItems + 1
    
ExitHere:
    ' Return some non-zero value.
    EnumFontNames = True
    Exit Function
    
HandleErrors:
    Select Case Err.Number
        Case Else
            ' Stop enumerating.  Something's wrong!
            mintItems = False
            Resume ExitHere
    End Select
End Function
 





More information about the AccessD mailing list