Recently in doing the WinCE system scanner application, encountered some problems, including the disappearance of the cue box in the handheld terminal display too small,
The user asks for a prompt to automatically shut down after a few seconds, and the Windows platform can be automatically destroyed by invoking the system API in the form of a timer.
However, there is a difference in wince, because the wince system is a lite version of the Windows system, so the API is also a thin,
The Windows Platform destruction message box was completed with FindWindow and PostMessage in User32.dll, and the wince platform did not
User32.dll, but the corresponding API is in Coredll.dll.
Windows platform Sample code:
1[DllImport ("user32.dll", EntryPoint ="FindWindow", CharSet =CharSet.Auto)]2 Internal Static externIntPtr FindWindow (stringClassName,stringwindowname);3 4[DllImport ("user32.dll", EntryPoint ="PostMessage", CharSet =CharSet.Auto)]5 Internal Static extern intPostMessage (IntPtr hWnd,intmsg,intptr wparam,intptr lParam);6 7 Internal Const intWm_close =0x10;8Timer timer =NewTimer ();9 Ten Private voidBtnautoclosemesaage_click (Objectsender, EventArgs e) One { A Runkilltimer (); -MessageBox.Show ("the operation is complete and can be closed! ","Message"); - } the - /// <summary> - ///Running a timer - /// </summary> + Internal voidRunkilltimer () - { +Timer. Interval = -; ATimer. tick+=Timer_tick; at timer. Start (); - } - - /// <summary> - ///timer triggers close message box - /// </summary> in /// <param name= "Sender" ></param> - /// <param name= "E" ></param> to Private voidTimer_tick (Objectsender, EventArgs e) + { - Killmessagebox (); the timer. Stop (); * } $ Panax Notoginseng /// <summary> - ///call the API to find the form and close the /// </summary> + Internal voidKillmessagebox () A { theIntPtr msgptr = FindWindow (NULL,"Message"); + if(Msgptr! =IntPtr.Zero) - { $ PostMessage (msgptr, Wm_close, IntPtr.Zero, IntPtr.Zero); $ } -}
View Code
WinCE Platform Sample code:
1[DllImport ("Coredll.dll", EntryPoint ="FindWindow", CharSet =CharSet.Auto)]2 Internal Static externIntPtr FindWindow (stringClassName,stringwindowname);3 4[DllImport ("Coredll.dll", EntryPoint ="PostMessage", CharSet =CharSet.Auto)]5 Internal Static extern intPostMessage (IntPtr hWnd,intmsg,intptr wparam,intptr lParam);6 7 Internal Const intWm_close =0x10;8Timer timer =NewTimer ();9 Ten Private voidBtnautoclosemesaage_click (Objectsender, EventArgs e) One { A Runkilltimer (); -MessageBox.Show ("the operation is complete and can be closed! ","Message"); - } the - /// <summary> - ///Running a timer - /// </summary> + Internal voidRunkilltimer () - { +Timer. Interval = -; ATimer. tick+=NewEventHandler (Timer_tick); atTimer. Enabled =true; - } - - /// <summary> - ///timer triggers close message box - /// </summary> in /// <param name= "Sender" ></param> - /// <param name= "E" ></param> to Private voidTimer_tick (Objectsender, EventArgs e) + { - Killmessagebox (); theTimer. Enabled =false; * } $ Panax Notoginseng /// <summary> - ///call the API to find the form and close the /// </summary> + Internal voidKillmessagebox () A { theIntPtr msgptr = FindWindow (NULL,"Message"); + if(Msgptr! =IntPtr.Zero) - { $ PostMessage (msgptr, Wm_close, IntPtr.Zero, IntPtr.Zero); $ } -}
View Code
PS: We have other good ideas or suggestions can also be a lot of communication.
WINCE/WINDOWS Application message hint Box Auto vanishing function