PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Gapidraw .NET : How to get the Handle?

Hi,

I am new to Gapidraw and I just started to use GapiDraw .NET. Is there a way to retrieve the HWND in my GapiApplication?

Thanks,

Alex
Not easily. You don't usually need the handle for gapidraw.net as the OpenDisplay functions can take the window title rather than the handle.

IIRC getting the handle is a pain in dot net. You have to do something like FindWindow (which probably requires p/invoke) to do it.

Unless you need the handle somewhere else, don't worry about it and use the title instead. That is how the GapiApplication class does it.

Sean
Ok Sean, Thanks for the help.

I need another tip : I try to insert inside a .NET CF System.Windows.Forms.Form a GapiDisplay Object (as you did in the TestApp). The problem is that when I do the Flip(), it is displayed behind the Form. Do you know how to place it in the foreground.
Thanks,

Alexandre
Here is the code :

GapiDisplay display ;
private void button2_Click(object sender, System.EventArgs e)
{
display = new GapiDisplay();
display.OpenDisplay((IntPtr)this.hWnd);
label2.Text = display.GetDisplayMode().ToString();

GapiSurface m_ipaq = new GapiSurface();

m_ipaq.CreateSurface("ipaq.png");
m_ipaq.SetColorKeyFromBottomLeftCorner();

int nRotAngle = 0;
double nRotScale = -360;

int dwScreenWidth = display.BackBuffer.GetWidth();
int dwScreenHeight = display.BackBuffer.GetHeight();

// Clean up background after last pass
//display.BackBuffer.FillRect(GapiUtility.RGB(128, 128, 128));


// drap ipaq
int nScale = 80 + (int) (Math.Cos(Math.Sin(nRotScale*3.14159/180.0)) * 80.0);
nRotScale += 5;
nRotAngle += 100;
if (nRotScale >= 360) nRotScale = -360;
if (nRotAngle >= 36000) nRotAngle = 0;

GDBLTFX bltfx = new GDBLTFX();
bltfx.dwRotationAngle = nRotAngle;
bltfx.dwRotationScale = nScale;

display.BackBuffer.Blt(m_ipaq, BltOptions.GDBLT_KEYSRC | BltOptions.GDBLT_ROTATIONANGLE | BltOptions.GDBLT_ROTATIONSCALE,
ref bltfx);

display.Flip();
}