In the c # winform application, the form contains ShowInTaskbar and FormWindowState. the Minimized attribute. NET Framework class library can easily implement the smart device of c # without displaying the form in the taskbar or minimizing the form operation. NET Compact Framework does not support these two functions. To implement these two functions, you must call the underlying win32 API functions. A large number of underlying Win32 operation functions exist in cordll. dll dynamic link library. Implementation Method:
First, call the Win32 statement: using System. Runtime. InteropServices;
1. The form is not displayed on the taskbar.
Const int EXSTYLE =-20;
Const int WS_EX_NOANIMATION = 0x04000000;
[DllImport ("coredll. dll", SetLastError = true)]
Public static extern void SetWindowLong (IntPtr hWnd, int GetWindowLongParam, uint nValue );
[Dllimport ("coredll. dll", setlasterror = true)]
Public static extern uint getwindowlong (intptr hwnd, int nitem );
[Dllimport ("coredll. dll")]
Private Static extern intptr getcapture ();
Void notshowintaskbar ()
{
Capture = true;
Intptr hwnd = getcapture ();
Capture = false;
Uint style = GetWindowLong (hwnd, EXSTYLE );
Style | = WS_EX_NOANIMATION;
SetWindowLong (hwnd, EXSTYLE, style );
}
2. Minimize forms
[DllImport ("coredll. dll")]
Static extern int ShowWindow (IntPtr hWnd, int nCmdShow );
Const int SW_MINIMIZED = 6;
Void minimize ()
{
Showwindow (this. Handle, sw_minimized );
}