| In this case you typically must display the chart using a modal chart display form. See the description of the bShowModal argument to PQCrDef.Display() in the SDK documentation.
An alternate approach is to programmatically ask the Windows shell to use the "CHARTrunner Command Line" program (CrCmdLineNN.exe) to display the chart definition for you. Since CrCmdLineNN.exe executes as a separate process the resulting chart display window is not restricted to being a modal window. For an example of this approach see the VBA code in the Microsoft Access sample database that comes with the CHARTrunner SDK. A code snippet that demonstrates this technique follows:
Private Declare Function ShellExecute Lib "shell32.dll" _ Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _ ByVal lpFile As String, ByVal lpParameters As String, _ ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Sub DrawNonModalChart(sChartFile As String)
' Draw the CHARTrunner chart specified by 'sChartFile' in a separate window. ' ' This uses the Windows API ShellExecute function to ask the application that is ' setup as the "Default" for a file of type .CRF to perform the default action on ' the chart on our behalf. When CHARTrunner is installed, it registers CrCmdLineNN.exe ' (i.e. the command line version of CHARTrunner) as the "Default" for .CRF files, so ' that when a .CRF file is double-clicked in Windows Explorer a chart is displayed. ' ' Using CrCmdLineNN.exe to draw the chart gets around the problem where the chart window ' must be modal when it is displayed from code in Microsoft Access, a scripting engine, ' or other environments.
Dim lRtn As Long Dim sError As String Dim sMsg As String lRtn = ShellExecute(0&, vbNullString, sChartFile, vbNullString, vbNullString, vbNormalFocus)
If lRtn <= 32 Then ' We had an error in ShellExecute. Select Case lRtn Case 1 sError = "The associated program for the chart was not found." Case 2 sError = "The chart definition file does not exist." Case 31 sError = "No association for the chart file was found." Case Else sError = "ShellExecute Error = " & CStr(lRtn) End Select If Len(sError) > 0 Then sMsg = "Unable to run CrCmdLine to draw the chart:" _ & vbCrLf & vbCrLf _ & sChartFile _ & vbCrLf & vbCrLf _ & sError MsgBox sMsg, vbExclamation End If
End If End Sub 'DrawNonModalChart' |