Common Dialog issue (1 Viewer)

KeKeR

New member
Local time
Today, 22:57
Joined
Jun 11, 2009
Messages
4
Show the 'Choose a Color' Common Dialog
To show the choose color common dialog, use the following function:
Option Explicit
Private Declare ptrSafe Function ChooseColorA Lib "comdlg32.dll" (pChoosecolor As tChooseColor) As Long
Private Declare ptrSafe Function GetActiveWindow Lib "user32" () As Long Private 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

'Purpose : Shows the Choose Color Dialog 'Inputs : N/A 'Outputs : Returns -1 if the user pressed cancel, else returns the selected color
Function ShowColor() As Long
Dim tColor As tChooseColor
Dim Custcolor(16) As Long
Dim lReturn As Long, lThisColor As Long
Dim abytCustomColors(0 To 16 * 4 - 1) As Byte
For lThisColor = LBound(abytCustomColors) To UBound(abytCustomColors)
abytCustomColors(lThisColor) = 0
Next

tColor.lStructSize = Len(tColor)
tColor.hwndOwner = GetActiveWindow 'or Me.hwnd in VB
tColor.hInstance = 1 'or App.hInstance in VB 'Convert the custom colors to Unicode
tColor.lpCustColors = StrConv(abytCustomColors, vbUnicode)
tColor.flags = 0 'Show the dialog

If ChooseColorA(tColor) <> 0 Then
ShowColor = tColor.rgbResult
Else
ShowColor = -1
End If
End Function

I have managed to use this function successfully in Access 2010 on a Win7 Machine.
However when I try to run the same function in Access 2013 on a Win8 machine the dialog box fails to show up.

Anyone any ideas why?
Is this a Win8 issue or an Access 2013 issue?
Steve.
 

Users who are viewing this thread

Top Bottom