WINCE/WINDOWS Application message hint Box Auto vanishing function

Source: Internet
Author: User

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

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.