Search code examples
.netwindows-embedded-compact

Windows .NET compact framework 3.5 lost focus event not working properly


We are currently migrating a PDA application from .NET compact framework 1.1 to .NET compact framework 3.5.
PDA having operating system Windows 6.0 and 6.5 installed.

On got_focus event of custom text box we have wrote below code

enter code here
private void tbCustom_GotFocus(object sender, EventArgs e)
{ 
    m_Keypad.SetBuffer(tbMileage.Text);
    m_Keypad.HideOSKeyPad();
    m_Keypad.Show();
    this.m_ToolBarButtonNumericKeypad.ImageIndex = 11;
    tbCustom.Focus();
}

its working fine in .NET CF 1.1 but while we convert this code into 3.5 without changing any code its just got into recursive and applcaiton is got crash. Please provide help about this. Thanks in advance.


Solution

  • There are couple of Pinvoke metthods used for opening the custom keypad window without a focus on it. This API works in CF1.0 however it doesn't work for .NET CF3.5 Following is the correct one for .NET CF3.5

    [DllImport("coredll.dll", SetLastError = true)]
    private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
    [DllImport("coredll.dll", SetLastError = true)]
    private static extern int GetWindowLong(IntPtr hWnd, int nIndex);