Forums


Comfort Software :: Forums :: Development
<< Previous thread | Next thread >>   

How to control the On-screen Keyboard Visual C++ clr syntax

Author Post
Barbetto80
Thu Sep 24 2009, 08:59am
Registered Member #116
Joined: Tue May 27 2008, 09:24am
Posts: 5

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);
}



[ Edited Thu Sep 24 2009, 05:15pm ]
Back to top
Moderators: Comfort

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System