Click here to Skip to main content
15,893,266 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hellow
i added google Earth to my project,what i need is to make google earth window iconic here in the following code
C#
private void Form1_Load(object sender, EventArgs e)
{
    if (this.DesignMode == false)
    {
        cam.FocusPointAltitudeMode = AltitudeModeGE.RelativeToGroundAltitudeGE;
        googleEarth = new ApplicationGEClass();
        cam.Tilt = 35;
        cam.Azimuth = 0;
        numericUpDown1.Value = 250;
        cam.Range = (double)numericUpDown1.Value;
    }

}

private void InsertGoogleButton_Click(object sender, EventArgs e)
{
    int ww, ll, x;
    ww = this.Width;
    ww = (int)(88 * ww / 100);
    ll = this.Height;
    ll = (int)(88 * ll / 100);

    InsertGoogleButton.Enabled = false;
    UpdateGoogleButton.Enabled = true;

    cam.FocusPointLatitude  = Form1.Lat_1  + Form1.Lat_2  / 60  + Form1.Lat_3 / 3600;
    cam.FocusPointLongitude = Form1.Long_1 + Form1.Long_2 / 60  + Form1.Long_3/ 3600;
    cam.FocusPointAltitude = 150;
    //---------------------------------------
    cam.Tilt = 35;
    textBox1.Text = cam.Tilt.ToString();

    cam.Azimuth = 0;//stright north
    textBox2.Text = cam.Azimuth.ToString();

    cam.Range = 250;
    numericUpDown1.Value = (decimal)cam.Range;
    //----------------------------
    cam.FocusPointAltitudeMode = AltitudeModeGE.RelativeToGroundAltitudeGE;
    googleEarth = new ApplicationGEClass();

    //Hwnd wnd=googleEarth.GetMainHwnd;// <---------- may be this one
    //wnd.setIconic;//   <----------  syntax may may be like this
    //--------------------------------------

    GEHrender = (IntPtr)googleEarth.GetRenderHwnd();
    GEParentHrender = ClassGoogle.GetParent(GEHrender);

    ClassGoogle.MoveWindow(GEHrender, 0, 0, ww, ll, true);
    ClassGoogle.SetParent(GEHrender, this.Handle);
    googleEarth.SetCamera(cam, 0.25f);
}
Posted
Updated 19-Aug-14 6:22am
v2

1 solution

You can't minimize the googleEarth instance because it's a Control in your Form, and not an MDI child.  Did you mean you want to minimize your app's window?  If so, just do this.WindowState = FormWindowState.Minimized;.

/ravi
 
Share this answer
 
Comments
Engineer khalid 19-Aug-14 16:18pm    
in Google Class i added this code
[DllImport("user32", CharSet = CharSet.Auto)]
public extern static IntPtr ShowWindow(
IntPtr hWndG, int ShowHow);

//before Form1_Load i added
//private IntPtr Gwnd = (IntPtr)0;
//then in Form1_Load i added

Gwnd = (IntPtr)googleEarth.GetMainHwnd();//GetRenderHwnd();
ClassGoogle.ShowWindow(Gwnd, 6);//SW_MINIMUM);//SW_FORCEMINIMIZE

their is no error now every thing is fine but
how could i substude the number 6 with SW_MINIMIZE
it seems SW_MINIMIZE should be in google class
public static class ClassGoogle
{
[DllImport("user32", CharSet = CharSet.Auto)]
public extern static IntPtr GetParent(
IntPtr hWnd);

[DllImport("user32", CharSet = CharSet.Auto)]
public extern static bool MoveWindow(
IntPtr hWnd, int X, int Y,
int nWidth, int nHeight, bool bRepaint);

[DllImport("user32", CharSet = CharSet.Auto)]
public extern static IntPtr SetParent(
IntPtr hWndChild, IntPtr hWndNewParent);

[DllImport("user32", CharSet = CharSet.Auto)]
public extern static IntPtr ShowWindow(
IntPtr hWndG, int ShowHow);
}
// i am still need answer
Ravi Bhavnani 19-Aug-14 16:28pm    
You could just define them as constants. See http://stackoverflow.com/questions/2365014/how-to-group-windows-api-constants.

/ravi
Engineer khalid 19-Aug-14 16:31pm    
my project as this ;
in Form1 i used a buttonClick by which i called another Form=>FormGoogle ,
by this code
FormGoogle frmGogle = new FormGoogle();
frmGogle.ShowDialog();
i reached the above Form1_Load,unfortunatlly the google window shows its self in a way that does not fit into my FormGoogle ,thats why i had to minimize it,then show it again in the above
InsertGoogleButton_Click(.....
Engineer khalid 19-Aug-14 16:40pm    
Hi Ravi Bhavani thank you very much
i assume you have solved the whole question you deserve the 5 points
Ravi Bhavnani 19-Aug-14 16:42pm    
Thanks, Khalid. If you accept the solution, please mark it accepted, making it easier for others to find.

/ravi

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900