Well just in case you don't know where to start or you can't translate VB code do C++ (clr syntax) here we go. Hope this will help you.
Intro:
using namespace System::Runtime::InteropServices;
using namespace System::Security::Permissions;
using namespace Microsoft::Win32;
const System::UInt32 WM_USER = 1024;
const System::UInt32 WM_CSKEYBOARD = WM_USER + 192;
const System::UInt32 WM_CSKEYBOARDMOVE = WM_USER + 193;
[DllImport("user32.dll")]
extern IntPtr FindWindow(String^ lpClassName, String^ lpWindowName);
[DllImport("user32.dll")]
extern IntPtr PostMessage(System::IntPtr hWnd, System::UInt32 Msg, int wParam, int lParam);
[assembly:RegistryPermissionAttribute(SecurityAction::RequestMinimum, All = "HKEY_CURRENT_USER")];
....blah blah blah you normal code...
void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
// Open/show the Comfort Onscreen Keyboard
IntPtr hWnd;
hWnd = FindWindow("TFirstForm", "CKeyboardFirstForm");
PostMessage(hWnd, WM_CSKEYBOARD, 1, 0);
}
void button2_Click(System::Object^ sender, System::EventArgs^ e)
{
// close the Comfort Onscreen Keyboard
IntPtr hWnd;
hWnd = FindWindow("TFirstForm", "CKeyboardFirstForm");
PostMessage(hWnd, WM_CSKEYBOARD, 2, 0);
}
void button3_Click(System::Object^ sender, System::EventArgs^ e)
{
//Move the Comfort Onscreen Keyboard; Move it first then show it
IntPtr hWnd;
hWnd = FindWindow("TFirstForm", "CKeyboardFirstForm");
PostMessage(hWnd, WM_CSKEYBOARDMOVE, 200, 200);
PostMessage(hWnd, WM_CSKEYBOARD, 1, 0);
}
void button4_Click(System::Object^ sender, System::EventArgs^ e)
{
//Toggle the Comfort Onscreen Keyboard
IntPtr hWnd;
hWnd = FindWindow("TFirstForm", "CKeyboardFirstForm");
PostMessage(hWnd, WM_CSKEYBOARD, 4, 0);
}
void button5_Click(System::Object^ sender, System::EventArgs^ e)
{
//Fade the Comfort Onscreen Keyboard
IntPtr hWnd;
hWnd = FindWindow("TFirstForm", "CKeyboardFirstForm");
PostMessage(hWnd, WM_CSKEYBOARD, 3, 0);
}
void button6_Click(System::Object^ sender, System::EventArgs^ e)
{
//Change the keyboard type and show it
System::Object ^kname="NumPad";
//Change the Registry entry for the required keyboard
RegistryKey ^key= Registry::CurrentUser->OpenSubKey ( "Software\\ComfortSoftware\\CKeyboard",true);
key->SetValue("KeyboardName",kname);
//Open the keyboard
IntPtr hWnd;
hWnd = FindWindow("TFirstForm", "CKeyboardFirstForm");
PostMessage(hWnd, WM_CSKEYBOARD, 1, 0);
}