OSDN Git Service

AppliStation-GUI,ソースコードへのコメント付記
[applistation/AppliStation.git] / AppliStation / AppliStation.Util / NativeMethods.cs
1 // Vistaの効果を有効にするフラグ(不要の場合はコメントアウト)\r
2 #define USE_VISTA_EFFECTS\r
3 \r
4 using System;\r
5 using System.Runtime.InteropServices;\r
6 using System.Windows.Forms;\r
7 using System.Drawing;\r
8 \r
9 namespace AppliStation.Util\r
10 {\r
11         /// <summary>\r
12         /// Win32ネイティブメソッドを叩いてGUI操作するための関数群のクラス\r
13         /// </summary>\r
14         public sealed class NativeMethods\r
15         {\r
16                 /// <summary>\r
17                 /// 呼び出し禁止\r
18                 /// </summary>\r
19                 private NativeMethods()\r
20                 {\r
21                 }\r
22 \r
23                 /// <summary>\r
24                 /// WindowsVista向け、プログレスバーステータス(色)を設定する\r
25                 /// </summary>\r
26                 /// <param name="progBar">対象のプログレスバー</param>\r
27                 /// <param name="state">状態。(1:Normal,2:Error,3:Paused)</param>\r
28                 public static void ProgressBar_SetState(ProgressBar progBar, uint state)\r
29                 {\r
30 #if USE_VISTA_EFFECTS\r
31                         try {\r
32                                 // status := (PBST_NORMAL | PBST_ERROR | PBST_PAUSED)\r
33                                 // SendMessage(progressBar.Handle, PBM_SETSTATE, state, 0);\r
34                                 SendMessage(progBar.Handle, 0x410, new IntPtr(state), IntPtr.Zero);\r
35                         } catch (Exception) {\r
36                         }\r
37 #endif\r
38                 }\r
39                 \r
40                 #region タスクバーおよびタイトルバーのフラッシュ\r
41                 \r
42                 /// <summary>\r
43                 /// タスクバーおよびタイトルバーボタンのフラッシュの設定フラグ\r
44                 /// </summary>\r
45                 public enum FlashFlag : uint {\r
46                         /// <summary>\r
47                         /// 点滅の停止\r
48                         /// </summary>\r
49                         Stop = 0,\r
50                         /// <summary>\r
51                         /// タイトルバーを点滅\r
52                         /// </summary>\r
53                         Caption = 1,\r
54                         /// <summary>\r
55                         /// タスクバーボタンを点滅\r
56                         /// </summary>\r
57                         Tray = 2,\r
58                         /// <summary>\r
59                         /// タイトルバーとタスクバーボタンを点滅\r
60                         /// </summary>\r
61                         All = 3,\r
62                         /// <summary>\r
63                         /// Stopが設定されるまで点滅する\r
64                         /// </summary>\r
65                         Timer = 4,\r
66                         /// <summary>\r
67                         /// フォアグラウンドの状態になるまで点滅\r
68                         /// </summary>\r
69                         TimerNoFG = 12,\r
70                 }\r
71                 \r
72                 [StructLayout(LayoutKind.Sequential)]\r
73                 struct FLASHWINFO\r
74                 {\r
75                     public int cbSize;\r
76                     public IntPtr hWnd;\r
77                     public FlashFlag dwFlags;\r
78                     public uint uCount;\r
79                     public uint dwTimeout;\r
80                 }\r
81                 \r
82                 /// <summary>\r
83                 /// タスクバーおよびタイトルバーボタンを点滅させる\r
84                 /// </summary>\r
85                 /// <param name="form">対象フォーム</param>\r
86                 /// <param name="flag">点滅パラメータフラグ</param>\r
87                 /// <param name="count">点滅回数</param>\r
88                 /// <param name="timeout">点滅の間隔(ミリ秒)</param>\r
89                 /// <returns></returns>\r
90                 public static bool Form_FlashWindow(Form form, FlashFlag flag, uint count, uint timeout)\r
91                 {\r
92                         try {\r
93                                 FLASHWINFO info = new FLASHWINFO();\r
94                                 info.cbSize = Marshal.SizeOf(typeof(FLASHWINFO));\r
95                                 info.hWnd = form.Handle;\r
96                                 info.dwFlags = flag;\r
97                                 info.uCount = count;\r
98                                 info.dwTimeout = timeout;\r
99                                 \r
100                                 return FlashWindowEx(ref info) == 0;\r
101                         } catch (Exception) {\r
102                                 return false;\r
103                         }\r
104                 }\r
105                 \r
106                 [DllImport("user32.dll")]\r
107                 static extern Int32 FlashWindowEx(ref FLASHWINFO pwfi);\r
108                 \r
109                 #endregion\r
110                 \r
111                 #region ListView関連\r
112                 \r
113                 /// <summary>\r
114                 /// リストビューにダブルバッファでの描画をするか否かを設定する\r
115                 /// </summary>\r
116                 /// <remarks>マウスでの選択に半透明ツールを採用するか否かもこの設定に依存</remarks>\r
117                 /// <param name="listView">対象のリストビュー</param>\r
118                 /// <param name="bEnable">ダブルバッファでの描画をするとき<code>true</code></param>\r
119                 public static void ListView_SetDoubleBuffer(ListView listView, bool bEnable)\r
120                 {\r
121                         try {\r
122                                 // SendMessage(listView.Handle, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_DOUBLEBUFFER, bEnable? LVS_EX_DOUBLEBUFFER:0);\r
123                                 SendMessage(listView.Handle, 0x1036, new IntPtr(0x00010000), new IntPtr((bEnable)? 0x00010000u:0x0u));\r
124                         } catch (Exception) {\r
125                         }\r
126                 }\r
127                 \r
128                 /// <summary>\r
129                 /// 選択されたアイテムの部分の背景にグラデーションがかかった感じになる、\r
130                 /// Vista以降でのエクスプローラの見た目をListViewに反映させる。\r
131                 /// </summary>\r
132                 /// <remarks>Vista未満のバージョンでは何もしない。</remarks>\r
133                 /// <param name="listView">対象のListView</param>\r
134                 public static void ListView_EnableVistaExplorerTheme(ListView listView)\r
135                 {\r
136 #if USE_VISTA_EFFECTS\r
137                         // Vista未満はなにもしない\r
138                         OperatingSystem os = Environment.OSVersion;\r
139                         if (os.Platform != PlatformID.Win32NT || os.Version.Major < 6) return;\r
140                         \r
141                         try {\r
142                                 SetWindowTheme(listView.Handle, "explorer", null);\r
143                         } catch (Exception) {\r
144                         }\r
145 #endif\r
146                 }\r
147                 \r
148                 /// <summary>\r
149                 /// ヘッダに"すべて選択"に似たチェックボックスを作るか否かを指定する\r
150                 /// </summary>\r
151                 /// <remarks>このオプションを設定するとVistaエクスプローラでの「チェックボックスを使用して項目を選択する」と同様の動作になる</remarks>\r
152                 /// <param name="listView">対象のListBox</param>\r
153                 /// <param name="bAutoCheckSelect">チェックボックスを使用して項目を選択するとき<code>true</code></param>\r
154                 public static void ListView_SetAutoCheckSelect(ListView listView, bool bAutoCheckSelect)\r
155                 {\r
156 #if USE_VISTA_EFFECTS\r
157                         try {\r
158                                 // SendMessage(listView.Handle, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_AUTOCHECKSELECT, bAutoCheckSelect?LVS_EX_AUTOCHECKSELECT:0);\r
159                                 SendMessage(listView.Handle, 0x1036, new IntPtr(0x08000000), new IntPtr((bAutoCheckSelect)?0x08000000u:0x0u));\r
160                         } catch (Exception) {\r
161                         }\r
162 #endif\r
163                 }\r
164                 \r
165                 #region ColumnHeaderのソートの三角印用\r
166                 \r
167                 [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]\r
168                 private struct HD_ITEM\r
169                 {\r
170                         public uint    mask;\r
171                         public int     cxy;\r
172                         [MarshalAs(UnmanagedType.LPTStr)]public string   pszText;\r
173                         public IntPtr   hbm;\r
174                         public int     cchTextMax;\r
175                         public int     fmt;\r
176                         [MarshalAs(UnmanagedType.LPTStr)]public string  lParam;\r
177                         public int     iImage;        // index of bitmap in ImageList\r
178                         public int     iOrder;\r
179                 }\r
180                 \r
181                 /// <summary>\r
182                 /// WinXP以降、ソートの矢印を表示\r
183                 /// </summary>\r
184                 /// <param name="listView">対象のListView</param>\r
185                 /// <param name="column">表示する矢印のヘッダ</param>\r
186                 /// <param name="order">ソートの昇順・降順</param>\r
187                 public static void ColumnHeader_SetSortState(ListView listView, int column, SortOrder order)\r
188                 {\r
189                         try {\r
190                                 // SendMessage(hWnd, LVM_GETHEADER, NULL, NULL);\r
191                                 IntPtr hWnd = SendMessage(listView.Handle, 0x101F, IntPtr.Zero, IntPtr.Zero);\r
192                                 \r
193                                 HD_ITEM hdi = new HD_ITEM();\r
194                                 hdi.mask = 0x0004; // HDI_FORMAT;\r
195                                 for (int i = 0; i < listView.Columns.Count; i++) {\r
196                                         // SendMessage(hWnd, HDM_GETITEMW, i, &hdi);\r
197                                         SendMessage(hWnd, 0x120b, new IntPtr(i), ref hdi);\r
198                                         \r
199                                         const int HDF_SORTUP = 0x400;\r
200                                         const int HDF_SORTDOWN = 0x200;\r
201                                         \r
202                                         if (i != column || order == SortOrder.None) {\r
203                                                 hdi.fmt = hdi.fmt & ~(HDF_SORTUP | HDF_SORTDOWN);\r
204                                         } else if (order == SortOrder.Ascending) { // 昇順\r
205                                                 hdi.fmt = hdi.fmt & ~HDF_SORTDOWN | HDF_SORTUP;\r
206                                         } else if (order == SortOrder.Descending) { // 降順\r
207                                                 hdi.fmt = hdi.fmt & ~HDF_SORTUP | HDF_SORTDOWN;\r
208                                         }\r
209                                         \r
210                                         // SendMessage(hWnd, HDM_SETITEMW, i, &hdi);\r
211                                         SendMessage(hWnd, 0x120c, new IntPtr(i), ref hdi);\r
212                                 }\r
213                         } catch (Exception) {\r
214                         }\r
215                 }\r
216                 \r
217                 /// <summary>\r
218                 /// ヘッダ部のサイズを返す\r
219                 /// </summary>\r
220                 /// <param name="listView">ListView</param>\r
221                 /// <returns>ヘッダ部のクライアントサイズ</returns>\r
222                 public static Size ColumnHeader_GetSize(ListView listView)\r
223                 {\r
224                         LRECT lrect;\r
225                         \r
226                         try {\r
227                                 // SendMessage(hWnd, LVM_GETHEADER, NULL, NULL);\r
228                                 IntPtr hWnd = SendMessage(listView.Handle, 0x101F, IntPtr.Zero, IntPtr.Zero);\r
229                                 GetClientRect(hWnd, out lrect);\r
230                         } catch {\r
231                                 lrect.Left = lrect.Right = lrect.Top = lrect.Bottom = 0;\r
232                         }\r
233                         \r
234                         Size size = new Size(lrect.Right - lrect.Left,\r
235                                         lrect.Bottom - lrect.Top);\r
236                         return size;\r
237                 }\r
238                 \r
239                 #endregion\r
240                 \r
241                 #endregion\r
242                 \r
243                 #region EnableWindow(コメントアウト)\r
244 //              /// <summary>\r
245 //              /// 指定されたコントロール(ウィンドウ)への、\r
246 //              /// キーボード入力およびマウス入力を有効化または無効化\r
247 //              /// </summary>\r
248 //              /// <param name="control">対象のコントロールのハンドラ</param>\r
249 //              /// <param name="bEnable">有効にするか無効にするかを指定</param>\r
250 //              /// <returns>直前にウィンドウが無効状態だった場合はtrueを返す</returns>\r
251 //              public static bool Control_EnableWindow(Control ctrl, bool bEnable)\r
252 //              {\r
253 //                      try {\r
254 //                              return EnableWindow(ctrl.Handle, bEnable);\r
255 //                      } catch {\r
256 //                              ctrl.Enabled = bEnable;\r
257 //                              return true;\r
258 //                      }\r
259 //              }\r
260 //              \r
261 //              /// <summary>\r
262 //              /// 指定されたコントロール(ウィンドウ)への、\r
263 //              /// キーボード入力およびマウス入力を有効化または無効化\r
264 //              /// </summary>\r
265 //              /// <param name="control">対象のコントロールのハンドラ</param>\r
266 //              /// <param name="bEnable">有効にするか無効にするかを指定</param>\r
267 //              /// <returns>直前にウィンドウが無効状態だった場合はtrueを返す</returns>\r
268 //              [DllImport("user32.dll")]\r
269 //              public static extern bool EnableWindow(IntPtr hWnd, bool bEnable);\r
270                 #endregion\r
271                 \r
272                 #region RichTextBox関連\r
273                 \r
274                 [StructLayout(LayoutKind.Sequential)]\r
275                 private struct CHARFORMAT2\r
276                 {\r
277                         public int cbSize;\r
278                         public uint dwMask;\r
279                         public uint dwEffects;\r
280                         public int yHeight;\r
281                         public int yOffset;\r
282                         public int crTextColor;\r
283                         public byte bCharSet;\r
284                         public byte bPitchAndFamily;\r
285                         [MarshalAs(UnmanagedType.ByValArray, SizeConst=32)]\r
286                         public char[] szFaceName;\r
287                         public short wWeight;\r
288                         public short sSpacing;\r
289                         public int crBackColor;\r
290                         public int LCID;\r
291                         public uint dwReserved;\r
292                         public short sStyle;\r
293                         public short wKerning;\r
294                         public byte bUnderlineType;\r
295                         public byte bAnimation;\r
296                         public byte bRevAuthor;\r
297                         public byte bReserved1;\r
298                 }\r
299                 \r
300                 /// <summary>\r
301                 /// リッチテキストの選択部分に文字フォーマット効果を与える\r
302                 /// </summary>\r
303                 /// <param name="richTextBox">対象のリッチテキストボックス</param>\r
304                 /// <param name="dwMask">有効な文字フォーマット効果</param>\r
305                 /// <param name="dwEffect">文字フォーマット効果のフラグ</param>\r
306                 public static void RichTextBox_SetSelectionFormat(RichTextBox richTextBox, uint dwMask, uint dwEffect)\r
307                 {\r
308                         CHARFORMAT2 cfmt = new CHARFORMAT2();\r
309                         cfmt.cbSize = Marshal.SizeOf(typeof(CHARFORMAT2));\r
310                         cfmt.dwMask = dwMask;\r
311                         cfmt.dwEffects = dwEffect;\r
312                         \r
313                         //SendMessage(richTextBox.Handle, EM_SETCHARFORMAT, SCF_SELECTION, ref cfmt);\r
314                         SendMessage(richTextBox.Handle, 0x0444, new IntPtr(0x0001), ref cfmt);\r
315                 }\r
316                 /// <summary>\r
317                 /// リッチテキストにテキストリンクを追加する\r
318                 /// </summary>\r
319                 /// <param name="richTextBox">対象のリッチテキストボックス</param>\r
320                 /// <param name="text">追加するテキスト</param>\r
321                 public static void RichTextBox_AddTextLink(RichTextBox richTextBox, string text)\r
322                 {\r
323                         int pos = richTextBox.TextLength;\r
324                         richTextBox.Select(pos,0);\r
325                         richTextBox.SelectedText = text;\r
326                         richTextBox.Select(pos, text.Length);\r
327                         \r
328                         // RichTextBox_SetSelectionFormat(richTextBox, CFM_LINK, CFE_LINK);\r
329                         RichTextBox_SetSelectionFormat(richTextBox, 0x00000020, 0x0020);\r
330                         \r
331                         richTextBox.Select(richTextBox.TextLength, 0);\r
332                 }\r
333                 \r
334                 #endregion\r
335                 \r
336                 #region アイコン関連\r
337                 \r
338                 [DllImport("shell32.dll")]\r
339                 private static extern IntPtr ExtractIcon(IntPtr hInst, string lpszExeFileName, int nIconIndex);\r
340                 \r
341                 [DllImport("user32.dll", SetLastError=true)]\r
342                 [return: MarshalAs(UnmanagedType.Bool)]\r
343                 private static extern bool DestroyIcon(IntPtr hIcon);\r
344                 \r
345                 [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]\r
346                 private struct SHSTOCKICONINFO\r
347                 {\r
348                         public Int32 cbSize;\r
349                         public IntPtr hIcon;\r
350                         public Int32 iSysImageIndex;\r
351                         public Int32 iIcon;\r
352                         [MarshalAs(UnmanagedType.ByValTStr, SizeConst=260)] public string path;\r
353                 }\r
354                 \r
355                 [DllImport("shell32.dll", CharSet=CharSet.Unicode, ExactSpelling=true, SetLastError=true)]\r
356                 private static extern void SHGetStockIconInfo(uint siid, uint uFlags, ref SHSTOCKICONINFO sii);\r
357                 \r
358                 /// <summary>\r
359                 /// アイコンファイル(実行ファイル・DLL)を開いてアイコンを作る\r
360                 /// </summary>\r
361                 /// <remarks>内部でコピーされるのでWin32APIのDestroyIconを使わないでいいが、やや遅い動作</remarks>\r
362                 /// <param name="form">ハンドラ</param>\r
363                 /// <param name="lpszExeFileName">対象ファイル</param>\r
364                 /// <param name="nIconIndex">アイコンインデックス</param>\r
365                 /// <returns>生成されたアイコン</returns>\r
366                 public static Icon ExtractIcon(Form form, string lpszExeFileName, uint nIconIndex)\r
367                 {\r
368                         Icon ico = null;\r
369                         \r
370                         if (! System.IO.File.Exists(lpszExeFileName)) {\r
371                                 ico = Icon.ExtractAssociatedIcon(lpszExeFileName); // ExtractAssociatedIconに例外を吐いてもらう\r
372                         } else {\r
373                                 IntPtr hInst = (form != null)? form.Handle : IntPtr.Zero;\r
374                                 IntPtr hIcon = IntPtr.Zero;\r
375                                 \r
376                                 try {\r
377                                         hIcon = ExtractIcon(hInst, lpszExeFileName, (int) nIconIndex);\r
378                                         if ((hIcon != IntPtr.Zero) && (hIcon.ToInt32() != 2)) {\r
379                                                 ico = (Icon) Icon.FromHandle(hIcon).Clone();\r
380                                                 DestroyIcon(hIcon);\r
381                                         }\r
382                                 } catch (System.Runtime.InteropServices.COMException) {\r
383                                         // ExtraIconのP/Invoke失敗時用\r
384                                 }\r
385                         }\r
386                         return ico;\r
387                 }\r
388                 \r
389                 /// <summary>\r
390                 /// ユーザ昇格が必要か設定し、設定必要なときシールドアイコンを表示する。\r
391                 /// </summary>\r
392                 /// <param name="button">対象のボタン</param>\r
393                 /// <param name="required">ユーザ昇格が必要か否か、すなわちシールドアイコンを表示するか</param>           \r
394                 public static void Button_SetElevationRequiredState(Button button, bool required)\r
395                 {\r
396 #if USE_VISTA_EFFECTS\r
397                         if (Environment.OSVersion.Version.Major >= 6) {\r
398                                 button.FlatStyle = FlatStyle.System;\r
399                                 // SendMessage(hWnd, BCM_SETSHIELD, 0, required);\r
400                                 SendMessage(button.Handle, 0x160C, IntPtr.Zero, new IntPtr((required)? 1u : 0u));\r
401                         } else { // Legacy OS\r
402 #endif\r
403                                 // FlatStyle.System に設定されている場合、Image プロパティに割り当てられているイメージは表示されない対策\r
404                                 if (button.FlatStyle == FlatStyle.System) {\r
405                                         button.FlatStyle = FlatStyle.Standard;\r
406                                 }\r
407                                 \r
408                                 button.TextImageRelation = TextImageRelation.ImageBeforeText;\r
409                                 if (required) {\r
410                                         button.ImageAlign = ContentAlignment.MiddleLeft;\r
411                                         using (Icon ico = new Icon(SystemIcons.Shield, 16, 16)) {\r
412                                                 button.Image = ico.ToBitmap();\r
413                                         }\r
414                                 } else {\r
415                                         button.Image = null;\r
416                                 }\r
417                                 button.AutoSize = true;\r
418 #if USE_VISTA_EFFECTS\r
419                         }\r
420 #endif\r
421                 }\r
422                 \r
423                 /// <summary>\r
424                 /// シェルのソトックアイコンのハンドラを取得する。\r
425                 /// </summary>\r
426                 /// <param name="siid">ストックID</param>\r
427                 /// <param name="isSmall">アイコンサイズは小さいのであればtrueを指定</param>\r
428                 /// <returns>アイコンのハンドラ。存在しない場合、null</returns>\r
429                 private static IntPtr SHGetStockIconHandle(uint siid, bool isSmall)\r
430                 {\r
431 #if USE_VISTA_EFFECTS\r
432                         try {\r
433                                 SHSTOCKICONINFO sii = new SHSTOCKICONINFO();\r
434                                 sii.cbSize = Marshal.SizeOf(typeof(SHSTOCKICONINFO));\r
435                                 sii.hIcon = IntPtr.Zero;\r
436                                 \r
437                                 //SHGetStockIconInfo(siid, SHGFI_ICON | ((isSmall)? SHGFI_SMALLICON : SHGFI_LARGEICON), ref sii);\r
438                                 SHGetStockIconInfo(siid, 0x100u | ((isSmall)? 0x1u : 0x0u), ref sii);\r
439                                 \r
440                                 return sii.hIcon;\r
441                         } catch (Exception) {\r
442                                 return IntPtr.Zero;\r
443                         }\r
444 #else\r
445                         return IntPtr.Zero;\r
446 #endif\r
447                 }\r
448                 \r
449                 /// <summary>\r
450                 /// ユーザ昇格が必要か設定し、設定必要なときシールドアイコンを表示する。\r
451                 /// </summary>\r
452                 /// <param name="label">対象のリンクラベル</param>\r
453                 /// <param name="required">ユーザ昇格が必要か否か、すなわちシールドアイコンを表示するか</param>           \r
454                 public static void LinkLabel_SetElevationRequiredState(LinkLabel label, bool required)\r
455                 {\r
456                         if (required) {\r
457                                 IntPtr iconHandle = IntPtr.Zero;\r
458                                 \r
459                                 //SHGetStockIconHandle(SIID_SHIELD, true);\r
460                                 iconHandle = SHGetStockIconHandle(77, true);\r
461                                 if (iconHandle != IntPtr.Zero) {\r
462                                         label.Image = Bitmap.FromHicon(iconHandle);\r
463                                 } else {\r
464                                         using (Icon ico = new Icon(SystemIcons.Shield, 16, 16)) {\r
465                                                 label.Image = ico.ToBitmap();\r
466                                         }\r
467                                 }\r
468                                 \r
469                                 label.ImageAlign = ContentAlignment.MiddleLeft;\r
470                                 label.Padding = new Padding(label.Image.Width, label.Padding.Top, label.Padding.Right, label.Padding.Bottom);\r
471                         } else {\r
472                                 label.Image = null;\r
473                                 label.Padding = new Padding(0);\r
474                         }\r
475                 }\r
476                 \r
477                 #endregion\r
478                 \r
479                 [DllImport("user32.dll", CharSet = CharSet.Auto)]\r
480                 internal static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);\r
481                 \r
482                 [DllImport("user32.dll", CharSet=CharSet.Auto)]\r
483                 private static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, ref HD_ITEM lParam);\r
484                 \r
485                 [DllImport("user32.dll", CharSet=CharSet.Auto)]\r
486                 private static extern IntPtr SendMessage(IntPtr hWnd, Int32 Msg, IntPtr wParam, ref CHARFORMAT2 lParam);\r
487 \r
488                 [DllImport("uxtheme.dll", ExactSpelling=true, CharSet=CharSet.Unicode)]\r
489                 internal static extern int SetWindowTheme(IntPtr hWnd, String pszSubAppName, String pszSubIdList);\r
490                 \r
491                 [Serializable]\r
492                 [StructLayout(LayoutKind.Sequential)]\r
493                 private struct LRECT {\r
494                         public int Left;\r
495                         public int Top;\r
496                         public int Right;\r
497                         public int Bottom;\r
498                 }\r
499                 \r
500                 [DllImport("user32.dll")]\r
501                 private static extern bool GetClientRect(IntPtr hWnd, out LRECT lpRect);\r
502         }\r
503 }\r