Putting Google Earth in A Form

darbid

Registered User.
Local time
Today, 12:55
Joined
Jun 26, 2008
Messages
1,428
I did start a thread here but it is (i think) a totally different topic and shows my inexperience.
http://www.access-programmers.co.uk/forums/showthread.php?t=167295

I have a feeling I am getting further by using Google Earth itself.

The idea is to get just the earth part (Rendered) of the google earth program and put it on a form. I can do this but as I am not experience enough I am not getting any further. IMO all that I need is someone that can manipulate windows with the API.

Maybe someone here is interested in doing something like this. Of course the goal is that with this on a form I can feed it kml files based on peoples choices etc and intend to fly around these choices.

I was thinking the next steps would be to hide the rest of Google Earth and I thought I could do that with ShowWindowAsync.

Move my new rendered section on my form to where I want it.

Code:
Option Compare Database
Option Explicit

Private Declare Function ShowWindowAsync Lib "user32" ( _
ByVal hwnd As Long, _
ByVal nCmdShow As Long) _
As Boolean

Private Declare Function GetWindowPlacement Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
 Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
   
Public GE_interface As Object
Public GE_interface_view As Object
Public GEParentHrender As Long
Public GE_main_window_handle As Long
Public GE_render_Window_handle As Long


Private Const SW_HIDE = 0
Private Const SW_SHOW = 5

    Private Type POINTAPI
        x As Integer
       y As Integer
    End Type

     Private Type RECT
        Left As Integer
         Top As Integer
         Right As Integer
         Bottom As Integer
    End Type

     Private Type WINDOWPLACEMENT
        Length As Integer
         flags As Integer
         showCmd As Integer
         ptMinPosition As POINTAPI
         ptMaxPosition As POINTAPI
         rcNormalPosition As RECT
    End Type

Private Sub Form_Load()

Dim bCmdShow As Boolean

bCmdShow = False
    
       Set GE_interface = CreateObject("GoogleEarth.ApplicationGE")
        Set GE_interface_view = CreateObject("GoogleEarth.CameraInfoGE")
        'Loop forever...
        Do
            If GE_interface.IsInitialized Then Exit Do
        Loop
        GE_render_Window_handle = GE_interface.GetRenderHwnd
        GE_main_window_handle = GE_interface.GetMainHwnd
        GEParentHrender = GetParent(GE_render_Window_handle)
        MoveWindow GE_render_Window_handle, 0, 0, 600, 400, True
        
        SetParent GE_render_Window_handle, Me.hwnd
        
        'ShowWindowAsync GE_main_window_handle, IIf(bCmdShow, SW_SHOW, SW_HIDE)
        'ShowWindowAsync GE_render_Window_handle, SW_SHOW
        
   End Sub
Of course you will need to have google earth and then to reference googleearth.exe.
 
get rid of the rest of google earth does not seem to be a drama I think it is gone with

Code:
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, _
     ByVal nCmdShow As Long) As Long
Code:
ShowWindow GE_main_window_handle, SW_HIDE
 
Ok I think I have got a handle on playing with the rendered window size of google earth as well.

You cannot just change its size.

Here is this part.

Code:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWND As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Sub SetWindowPos Lib "user32" (ByVal hWND As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hWND As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Private Const HWND_TOP    As Long = &H0
Private Const WM_COMMAND  As Long = &H111
Private Const WM_QT_PAINT As Long = &HC2DC
Private Const WM_PAINT    As Long = &HF&
Private Const WM_SIZE     As Long = &H5
Private Const SWP_FRAMECHANGED As Long = &H20
Code:
SendMessage GE_main_window_handle, WM_COMMAND, WM_PAINT, 0

PostMessage GE_main_window_handle, WM_QT_PAINT, 0, 0

SetWindowPos GE_main_window_handle, HWND_TOP, 0, 0, Me.WindowWidth, Me.WindowHeight, SWP_FRAMECHANGED

SendMessage GE_main_window_handle, WM_COMMAND, WM_SIZE, 0
I will put this together in the end. I think the next step is to close this child window down properly.
 
I was wondering if anyone has had a play with this.

I have a couple of things I am not happy about.

First is
Code:
Set GE_interface = CreateObject("GoogleEarth.ApplicationGE")
will start the google earth program, the whole program comes up with focus. As soon as I get the handle i hide it, but that still is a while.
So is there a way to call a program hidden?

I cannot seem to control the size of my render window. It now just opens up in full screen. Can someone that understand these send and post messages please give me a hint how I need to get this working better?
 
hi.. can u attach with some db sample.
 
Basically here is the thread with an example http://www.access-programmers.co.uk/forums/showthread.php?t=168131

This does not use the COM object with the Google Earth Program and I stopped working on that as Google stopped supporting the COM object at least a year ago. Thus all the new features would not be accessable throught this COM object.

There seems to be only one way to do this and that is with the Google Earth Add-in for a webbrowser. Have a read of this other thread and the example.

You can ask any questions you then have.
 

Users who are viewing this thread

Back
Top Bottom