Search
Important Notes for Visual Basic Users

Windowed activation

FlowChartX supports both windowless and windowed activation, the latter is default. Visual Basic creates controls windowless if they support the IOleInPlaceObjectWindowless interface. This interface is hidden so that VB instantiates the control in its own window. It is easier to use the control in windowed mode due to following reasons:

  • the built-in scrollbars can be created and used only if FlowChartX has its own window;
  • VB erases the background of windowless controls when they are invalidated, which results in screen flickering;
  • windowless controls rely on their containers to forward Windows messages to them, but VB does not forward certain messages. This prevents FlowChartX from detecting the WM_MOUSEWHEEL message for example; therefore, the MouseWheel event is not raised in windowless mode.

The COM way to prohibit windowless activation is to return false from the CanWindowlessActivate method of the container's IOleInPlaceSiteWindowless interface. Since this interface is implemented internally by VB and cannot be overridden, we have devised a work-around method to create the control windowed, and still support windowless activation. When FlowChartX is being created it checks if a named semaphore called "FCX_windowless" exists in the system. If the semaphore exists, the control reports that it supports windowless activation when asked about it. Otherwise, it hides this fact and is created in its own window. If for any reason you want to use the control in windowless mode you can do it as shown below:

VB  Copy Code

Private Declare Function CreateSemaphoreA Lib "Kernel32" (ByVal sec As Long, ByVal a As Long, ByVal b As Long, ByVal s As String) As Long
Private Declare Function CloseHandle Lib "Kernel32" (ByVal handle As Long) As Long

Sub Main()
    Dim smph As Long

    'the semaphore should be created before the form
    'that contains FlowChartX is loaded
    smph = CreateSemaphoreA(0, 0, 1, "FCX_windowless")

    'load and display the main form
    Form1.Show

    'close the semaphore
    CloseHandle smph

End Sub

Drag-and-drop

Another important issue with VB is to control programmatically the drag-and-drop operations. The events raised in drProgrControl mode cannot be used with VB, because the IDataObject pointer passed as their argument is not automation-compatible. You should use drProgrControlVB mode and will receive similar set of events, but having as parameter automation-compatible IVBDataObject pointer. See DragDropMode property for more info.