In Windows Mobile, call the input method and change the position of the Input Panel.

Source: Internet
Author: User
Write full screen applications Program To make full use of the screen space, cancel the input method panel. But there is no input method panel. How do I set the display position of the Input Panel? One feasible method is to call P/invoke and call the input method in the program. The interface is as follows:

CodeAs follows:

Using System;
Using System. componentmodel;
Using System. drawing;
Using System. Windows. forms;
Using System. runtime. interopservices;

Namespace Smartdeviceproject1
{
[Structlayout (layoutkind. Sequential)]
Public   Struct Rect
{
Public   Int Left;
Public   Int Top;
Public   Int Right;
Public   Int Bottom;
}

Public   Struct Sipinfo
{
Public   Int Cbsize; // Set to 48
Public   Int Fdwflags; // Set to 0
Public Rectangle rcvisibledesktop; // Set to 0, 0, 0
Public Rectangle rcsiprect;
Public   Int Dwimdatasize; // Set to 0
Public Intptr pvimdata; // Set to intptr. Zero

Public Sipinfo ( Int Anyone)
{
Cbsize = Marshal. sizeof ( Typeof (Sipinfo ));
Fdwflags =   0 ; // Set to 0
Rcvisibledesktop =   New Rectangle ( 0 , 0 , 0 , 0 );
Rcsiprect =   New Rectangle ( 0 , 0 , 0 , 0 );
Dwimdatasize =   0 ;
Pvimdata = Intptr. zero;
}
}

Public   Partial   Class Form1: Form
{
[Dllimport ( " Coredll. dll " )]
Public   Extern   Static   Void Sipshowim ( Uint Dwflag );
[Dllimport ( " Coredll. dll " )]
Public   Extern   Static   Bool Sipsetdefaultrect ( Ref Rect rectf );
[Dllimport ( " Coredll. dll " )]
Public   Extern   Static   Bool Sipsetcurrentim ( Ref Intptr cslid );
[Dllimport ( " Coredll. dll " )]
Public   Extern   Static   Bool Sipgetcurrentim ( Ref Intptr cslid );
[Dllimport ( " Coredll " )]
Public   Extern   Static   Bool Sipgetinfo ( Ref Sipinfo );

Public   Static   Uint Sipf_off =   0x00 ;
Public   Static   Uint Sipf_on =   0x01 ;

Private Rect originalrect;
Private   Int Sipclsid;

Public Form1 ()
{
Initializecomponent ();
}

Private   Void Button#click ( Object Sender, eventargs E)
{
// Move the Input Panel up to 50 and enable the Input Method
Sipinfo =   New Sipinfo ( 0 );
Sipgetinfo ( Ref Sipinfo );

Originalrect =   New Rect ();
Originalrect. Left = Sipinfo. rcsiprect. X;
Originalrect. Top = Sipinfo. rcsiprect. Y;
Originalrect. Right = Sipinfo. rcsiprect. Right;
Originalrect. Bottom = Sipinfo. rcsiprect. height;

Rect newrect =   New Rect ();
Newrect. Left = Sipinfo. rcsiprect. X;
Newrect. Top = Sipinfo. rcsiprect. Y -   50 ;
Newrect. Right = Sipinfo. rcsiprect. Right;
Newrect. Bottom = Sipinfo. rcsiprect. Height -   50 ;

Sipsetdefaultrect ( Ref Newrect );
Sipclsid = Inputpanel1.inputmethods [ 1 ]. Clsid. gethashcode ();
Intptr pointclsid =   New Intptr (sipclsid );
If (Sipgetcurrentim ( Ref Pointclsid ))
{
Sipsetcurrentim (RefPointclsid );
}
Pointclsid = Intptr. zero;
Sipshowim (sipf_on );
}

Private   Void Form1_closing ( Object Sender, canceleventargs E)
{
// Restore the original Input Panel and disable the input method.
Sipsetdefaultrect ( Ref Originalrect );
Sipclsid = Inputpanel1.inputmethods [ 1 ]. Clsid. gethashcode ();
Intptr pointclsid =   New Intptr (sipclsid );
If (Sipgetcurrentim ( Ref Pointclsid ))
{
Sipsetcurrentim (RefPointclsid );
}
Pointclsid = Intptr. zero;
Sipshowim (sipf_off );
}
}
}

For more information, seeArticle: Managing the software Input Panel in your applications

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.