Dear Johan,
The code I use to test are included below. You can see the coordinate display on the screen before and after a press on A button.
Best regards,
Tri
////////////////////////////////////////
using System;
using System.Data;
using System.Drawing;
using GapiDrawNet;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.IO;
using System.Threading;
using System.Collections;
using System.Diagnostics;
namespace GapiFormTest
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : GapiForm
{
GapiSurface backgroundSurface;
GapiBitmapFont _simpleFont = new GapiBitmapFont();
public Form1(GapiApplication application):base(application)
{
backgroundSurface = new GapiSurface();
}
private string _coordinate = "";
override public void StylusDown(Point p, System.Windows.Forms.MouseEventArgs e)
{
_coordinate = p.X.ToString() + "," + p.Y.ToString();
}
GapiDisplay _gapiDisplay;
override public void KeyDown(System.Windows.Forms.KeyEventArgs e)
{
if ((int)e.KeyCode == this.GDApplication.KeyList.vkA )
{
_gapiDisplay.SuspendDisplay();
OnlineHelp();
_gapiDisplay.ResumeDisplay();
}
else if ((int)e.KeyCode == this.GDApplication.KeyList.vkB)
{
}
}
public override void CreateSurfaces(GapiDisplay gapiDisplay)
{
base.CreateSurfaces(gapiDisplay);
backgroundSurface.CreateSurface("background.bmp");
_simpleFont.CreateFontSimple("simpleFont.png");
_gapiDisplay = gapiDisplay;
}
public override void ProcessNextFrame(bool frameOverflow)
{
BackBuffer.BltFast(0, 0, backgroundSurface, 0);
DrawFrameInfo(BackBuffer,0,_coordinate,GapiUtility.RGB(255,0,0));
base.ProcessNextFrame(frameOverflow);
}
private void DrawFrameInfo(GapiSurface surface, int dwY, string pText, int color)
{
int strWidth = surface.GetTextWidth(pText, _simpleFont);
int strX = surface.Width - strWidth;
GDRect rect = new GDRect(0, dwY-1, strX + strWidth + 3, dwY +

;
GDFILLRECTFX fillrectfx = new GDFILLRECTFX();
fillrectfx.dwOpacity = 128;
surface.FillRect(ref rect, color, 128);
surface.DrawRect(ref rect,0xff00ff);
surface.DrawText(strX, dwY, pText, _simpleFont, DrawTextOptions.GDDRAWTEXT_LEFT);
}
[DllImport("CoreDll")]
private extern static
int CreateProcess( String imageName,
String cmdLine,
IntPtr lpProcessAttributes,
IntPtr lpThreadAttributes,
Int32 boolInheritHandles,
Int32 dwCreationFlags,
IntPtr lpEnvironment,
IntPtr lpszCurrentDir,
byte [] si,
ProcessInfo pi );
public class ProcessInfo
{
public IntPtr hProcess;
public IntPtr hThread;
public Int32 ProcessId;
public Int32 ThreadId;
}
[DllImport("CoreDll")]
public static extern bool SetForegroundWindow( IntPtr hWnd);
[DllImport("CoreDll")]
public static extern IntPtr GetForegroundWindow();
[DllImport("CoreDll")]
public static extern IntPtr FindWindow( char[] className, char[] WindowsName);
static ProcessInfo _processInfo;
public static bool CreateProcess( String ExeName, String CmdLine, ProcessInfo pi )
{
if ( _processInfo == null )
_processInfo = new ProcessInfo();
byte [] si = new byte[128];
int er = CreateProcess(ExeName, CmdLine, IntPtr.Zero, IntPtr.Zero,
0, 0, IntPtr.Zero, IntPtr.Zero, si, _processInfo);
return true;
}
public bool IsWindowVisible(string WindowName)
{
IntPtr hWnd;
hWnd = FindWindow(null, WindowName.ToCharArray());
IntPtr h2 = GetForegroundWindow();
if (h2 == hWnd)
return true;
return false;
}
private void OnlineHelp()
{
CreateProcess("iexplore.exe", "", _processInfo);
Thread.Sleep(1000);
while (IsWindowVisible("Internet Explorer"))
Thread.Sleep(200);
string strinet = "Internet Explorer";
IntPtr hWndInet = FindWindow(null,strinet.ToCharArray());
Microsoft.WindowsCE.Forms.Message msg = new Microsoft.WindowsCE.Forms.Message();
msg.HWnd = hWndInet;
msg.Msg = 0x0010; //WM_CLOSE;
Microsoft.WindowsCE.Forms.MessageWindow.SendMessage(ref msg);
}
}
}