@@ -21,7 +21,7 @@ private ShowDesktop()
2121
2222 CreateParams cp = new CreateParams { ExStyle = GadgetWindow . WS_EX_TOOLWINDOW , Caption = _referenceWindowCaption } ;
2323 _referenceWindow . CreateHandle ( cp ) ;
24- NativeMethods . SetWindowPos ( _referenceWindow . Handle ,
24+ WinApiHelper . SetWindowPos ( _referenceWindow . Handle ,
2525 GadgetWindow . HWND_BOTTOM ,
2626 0 ,
2727 0 ,
@@ -82,23 +82,23 @@ private void StopTimer()
8282 // the desktop worker window (if available) can hide the reference window
8383 private IntPtr GetDesktopWorkerWindow ( )
8484 {
85- IntPtr shellWindow = NativeMethods . GetShellWindow ( ) ;
85+ IntPtr shellWindow = WinApiHelper . GetShellWindow ( ) ;
8686 if ( shellWindow == IntPtr . Zero )
8787 return IntPtr . Zero ;
8888
8989
90- NativeMethods . GetWindowThreadProcessId ( shellWindow , out int shellId ) ;
90+ WinApiHelper . GetWindowThreadProcessId ( shellWindow , out int shellId ) ;
9191
9292 IntPtr workerWindow = IntPtr . Zero ;
93- while ( ( workerWindow = NativeMethods . FindWindowEx ( IntPtr . Zero , workerWindow , "WorkerW" , null ) ) != IntPtr . Zero )
93+ while ( ( workerWindow = WinApiHelper . FindWindowEx ( IntPtr . Zero , workerWindow , "WorkerW" , null ) ) != IntPtr . Zero )
9494 {
95- NativeMethods . GetWindowThreadProcessId ( workerWindow , out int workerId ) ;
95+ WinApiHelper . GetWindowThreadProcessId ( workerWindow , out int workerId ) ;
9696 if ( workerId == shellId )
9797 {
98- IntPtr window = NativeMethods . FindWindowEx ( workerWindow , IntPtr . Zero , "SHELLDLL_DefView" , null ) ;
98+ IntPtr window = WinApiHelper . FindWindowEx ( workerWindow , IntPtr . Zero , "SHELLDLL_DefView" , null ) ;
9999 if ( window != IntPtr . Zero )
100100 {
101- IntPtr desktopWindow = NativeMethods . FindWindowEx ( window , IntPtr . Zero , "SysListView32" , null ) ;
101+ IntPtr desktopWindow = WinApiHelper . FindWindowEx ( window , IntPtr . Zero , "SysListView32" , null ) ;
102102 if ( desktopWindow != IntPtr . Zero )
103103 return workerWindow ;
104104 }
@@ -116,7 +116,7 @@ private void OnTimer(object state)
116116 if ( workerWindow != IntPtr . Zero )
117117 {
118118 // search if the reference window is behind the worker window
119- IntPtr reference = NativeMethods . FindWindowEx ( IntPtr . Zero , workerWindow , null , _referenceWindowCaption ) ;
119+ IntPtr reference = WinApiHelper . FindWindowEx ( IntPtr . Zero , workerWindow , null , _referenceWindowCaption ) ;
120120 showDesktopDetected = reference != IntPtr . Zero ;
121121 }
122122 else
@@ -132,30 +132,3 @@ private void OnTimer(object state)
132132 }
133133 }
134134}
135-
136- internal static class NativeMethods
137- {
138- internal const int WM_USER = 0x0400 ;
139- private const string USER = "user32.dll" ;
140-
141- [ DllImport ( USER , CallingConvention = CallingConvention . Winapi ) ]
142- public static extern bool SetWindowPos ( IntPtr hWnd , IntPtr hWndInsertAfter , int X , int Y , int cx , int cy , uint uFlags ) ;
143-
144- [ DllImport ( "user32.dll" , EntryPoint = "SendMessageA" , SetLastError = true ) ]
145- internal static extern IntPtr SendMessage ( IntPtr hWnd , UInt32 msg , int wParam , IntPtr lParam ) ;
146-
147- [ DllImport ( "user32.dll" ) ]
148- internal static extern bool SetForegroundWindow ( IntPtr hWnd ) ;
149-
150- [ DllImport ( USER , CallingConvention = CallingConvention . Winapi ) ]
151- public static extern IntPtr FindWindowEx ( IntPtr hwndParent , IntPtr hwndChildAfter , string lpszClass , string lpszWindow ) ;
152-
153- [ DllImport ( "user32.dll" ) ]
154- internal static extern IntPtr FindWindow ( string className , string windowName ) ;
155-
156- [ DllImport ( USER , CallingConvention = CallingConvention . Winapi ) ]
157- public static extern IntPtr GetShellWindow ( ) ;
158-
159- [ DllImport ( USER , CallingConvention = CallingConvention . Winapi ) ]
160- public static extern int GetWindowThreadProcessId ( IntPtr hWnd , out int processId ) ;
161- }
0 commit comments