Public Sub GE_Flush(Extent_flag As Integer) '************************************************************************************ 'This procedure minimizes or closes the GE interface 'The input parameters are: ' Extent_flag = flag to indicate if minimization or closure is to be performed 'Notes on this procedure: ' None '************************************************************************************ 'Disable GE_interrogate timer GE_interrogate.Enabled = False 'Set up WINDOWPLACEMENT data type Dim wp As WINDOWPLACEMENT wp.Length = Len(wp) 'If GE not temporarily minimized... If Not GE_status_temp_minimize Then 'Get window characteristics from GE rc& = GetWindowPlacement(GE_main_window_handle, wp) 'If non-zero result then... If rc& <> 0 Then 'Extract them GE_savewindow_flags = wp.flags GE_savewindow_showCmd = wp.showCmd GE_savewindow_ptMinPositionX = wp.ptMinPosition.X GE_savewindow_ptMinPositionY = wp.ptMinPosition.Y GE_savewindow_ptMaxPositionX = wp.ptMaxPosition.X GE_savewindow_ptMaxPositionY = wp.ptMaxPosition.Y GE_savewindow_rcNormalPosition_Left = wp.rcNormalPosition.Left GE_savewindow_rcNormalPosition_Top = wp.rcNormalPosition.Top GE_savewindow_rcNormalPosition_Bottom = wp.rcNormalPosition.Bottom GE_savewindow_rcNormalPosition_Right = wp.rcNormalPosition.Right End If End If '************************************************************************************ 'Flush any current active kml files - if this is not done GE will generate an 'annoying message of the form "You have unsaved items in your Temporary Places 'folder. Would you like to save them..." and wait for the user to respond... '************************************************************************************ 'If chart currently overlaid on GE... If GE_last_chart <> "" Then 'Open minimal chart kml file for output File_xkm = FreeFile Open mydirectory + GE_last_chart + ".kml" For Output As #File_xkm 'Build minimal kml file data Print #File_xkm, GE_kml_header1 Print #File_xkm, GE_kml_header2 Print #File_xkm, "</kml>" 'Close minimal chart kml file Close #File_xkm 'Send minimal chart kml file to GE (this will flush the chart overlay from 'GE) and if successful flush name of last chart overlaid on GE If GE_Send_Kml(GE_last_chart) Then GE_last_chart = "" End If 'If GE vessels network link has been established... If GE_status_networklink Then 'Open minimal vessels link kml file for output File_xkm = FreeFile Open mydirectory + "C_wiz GE Vessels Link.kml" For Output As #File_xkm 'Build minimal kml file data Print #File_xkm, GE_kml_header1 Print #File_xkm, GE_kml_header2 Print #File_xkm, "</kml>" 'Close minimal vessels link kml file Close #File_xkm 'Send minimal vessels link kml file to GE (this will flush the vessels link 'from GE), saving inverted return code as the flag indicating the GE vessels 'network link state GE_status_networklink = Not GE_Send_Kml("C_wiz GE Vessels Link") End If '************************************************************************************ 'Minimize or close GE... '************************************************************************************ 'If closing... If Extent_flag Then 'Try up to 10 times... For i% = 1 To 10 'Kill GE by posting a message to its main window to close - use 'PostMessage rather than SendMessage because SendMessage waits for a 'response (which may never come if something is stuffed) while 'PostMessage just sends a message and doesn't wait rc& = PostMessage(GE_main_window_handle, WM_CLOSE, 0&, 0&) 'Wait a second Call Sleeper(1000) 'Quit loop if handle of main GE window no longer points to a window If IsWindow(GE_main_window_handle) = 0 Then Exit For Next 'Tidy up Call GE_Tidy 'Delete all kml files Kill mydirectory + "*.kml" 'Otherwise, only minimizing... Else 'Prepare to minimize GE window wp.showCmd = SW_SHOWMINIMIZED 'Fire at GE rc& = SetWindowPlacement(GE_main_window_handle, wp) 'Disable GE_interrogate timer GE_interrogate.Enabled = False End If 'Let the system have control DoEvents End Sub