如何获得web窗体的handle属性值??高分求

tre_sdlpq 2009-08-27 04:58:18
IntPtr m_hIMC = WR_Imm32.ImmGetContext(Handle);
这个在winfrom中执行时没有问题的;不过,放到web中,就会报错
C:\Inetpub\wwwroot\trys\WebForm1.aspx.cs(123): 名 'Handle' 在'trys.WebForm1' 不存在。

那么 怎样在web窗体获得'Handle' 呢?

具体代码如下:
private string GetReverseConversion(string AText)
{
if (AText == "")
return "";
IntPtr m_hKL = WR_Imm32.GetKeyboardLayout(0);
IntPtr m_hIMC = WR_Imm32.ImmGetContext(Handle);
WR_Imm32.CANDIDATELIST m_list = new WR_Imm32.CANDIDATELIST();
int dwSize = WR_Imm32.ImmGetConversionList(m_hKL, m_hIMC, AText, IntPtr.Zero, 0, (int)WR_Imm32.GCL.REVERSE_LENGTH);
IntPtr BufList = Marshal.AllocHGlobal(dwSize);
WR_Imm32.ImmGetConversionList(m_hKL, m_hIMC, AText, BufList, dwSize, (int)WR_Imm32.GCL.REVERSECONVERSION);
Marshal.PtrToStructure(BufList, m_list);
byte[] buf = new byte[dwSize];
Marshal.Copy(BufList, buf, 0, dwSize);
Marshal.FreeHGlobal(BufList);
int os = m_list.dwOffset;
string str = System.Text.Encoding.Unicode.GetString(buf, os, buf.Length - os - 3);
string[] ret = str.Split(new char[1]{'\0'});
return ret[0];
}




类“


public WR_Imm32()
{
//nayiinStr=inStr;
//
// TODO: コンストラクタ ロジックをここに追加してください。
//
}
public enum GCL
{
CONVERSION = 1,
REVERSECONVERSION = 2,
REVERSE_LENGTH = 3
}

[DllImport("Imm32.dll", CharSet=CharSet.Auto, EntryPoint="ImmGetContext")]
public static extern IntPtr ImmGetContext(IntPtr hWnd);

[DllImport("User32.dll", CharSet=CharSet.Auto, EntryPoint="GetKeyboardLayout")]
public static extern IntPtr GetKeyboardLayout(int idThread);

[DllImport("Imm32.dll", CharSet=CharSet.Auto, EntryPoint="ImmGetConversionList")]
public static extern int ImmGetConversionList(IntPtr hKL, IntPtr hIMC, string lpSrc, IntPtr lpDst, int dwBufLen, int uFlag);

[DllImport("Imm32.dll", CharSet=CharSet.Auto, EntryPoint="ImmReleaseContext")]
public static extern bool MessageBox(IntPtr hWnd, IntPtr hIMC);

[DllImport("imm32.dll", EntryPoint = "ImmInstallIME")]
public static extern int ImmInstallIMEA(string lpszIMEFileName, string lpszLayoutText);

[StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]
public class CANDIDATELIST
{
public int dwSize;
public int dwStyle;
public int dwCount;
public int dwSelection;
public int dwPageStart;
public int dwPageSize;
public int dwOffset;

}
...全文
87 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
tre_sdlpq 2009-08-27
  • 打赏
  • 举报
回复
不好意思,补充以下,是C#的 .net
qqweird0001 2009-08-27
  • 打赏
  • 举报
回复
是vb嘛,帮顶。

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧