@@ -256,9 +256,87 @@ public delegate void WinEventProc(
256
256
[ DllImport ( nameof ( User32 ) , SetLastError = true ) ]
257
257
public static extern int MessageBoxIndirect ( ref MSGBOXPARAMS lpMsgBoxParams ) ;
258
258
259
- [ DllImport ( nameof ( User32 ) , CharSet = CharSet . Unicode ) ]
259
+ [ DllImport ( nameof ( User32 ) , SetLastError = true ) ]
260
260
public static extern int SetWindowLong ( IntPtr hWnd , WindowLongIndexFlags nIndex , SetWindowLongFlags dwNewLong ) ;
261
261
262
+ /// <summary>
263
+ /// Changes an attribute of the specified window. The function also sets a value at the specified
264
+ /// offset in the extra window memory.
265
+ /// </summary>
266
+ /// <param name="hWnd">A handle to the window and, indirectly, the class to which the window belongs.
267
+ /// The SetWindowLongPtr function fails if the process that owns the window specified by the
268
+ /// <paramref name="hWnd"/> parameter is at a higher process privilege in the UIPI hierarchy than the
269
+ /// process the calling thread resides in.</param>
270
+ /// <param name="nIndex">The zero-based offset to the value to be set. Valid values are in the range zero
271
+ /// through the number of bytes of extra window memory, minus the size of a LONG_PTR. To set any other value,
272
+ /// specify one of the following values.
273
+ /// +---------------------+---------------------------------------------------------------------------------------------------+
274
+ /// | Value | Meaning |
275
+ /// +---------------------+---------------------------------------------------------------------------------------------------+
276
+ /// | GWL_EXSTYLE(-20) | Sets a new extended window style. |
277
+ /// | GWLP_HINSTANCE(-6) | Sets a new application instance handle. |
278
+ /// | GWLP_ID(-12) | Sets a new identifier of the child window.The window cannot be a top-level window. |
279
+ /// | GWL_STYLE (-16) | Sets a new window style. |
280
+ /// | GWLP_USERDATA (-21) | Sets the user data associated with the window.This data is intended for use by the application |
281
+ /// | | that created the window. Its value is initially zero. |
282
+ /// | GWLP_WNDPROC (-4) | Sets a new address for the window procedure. |
283
+ /// +---------------------+---------------------------------------------------------------------------------------------------+
284
+ ///
285
+ /// The following values are also available when the hWnd parameter identifies a dialog box.
286
+ ///
287
+ /// +-------------------------------------------------+---------------------------------------------------------------------------+
288
+ /// | Value | Meaning |
289
+ /// +-------------------------------------------------+---------------------------------------------------------------------------+
290
+ /// | DWLP_DLGPROC (DWLP_MSGRESULT + sizeof(LRESULT)) | Sets the new pointer to the dialog box procedure. |
291
+ /// | DWLP_MSGRESULT (0) | Sets the return value of a message processed in the dialog box procedure. |
292
+ /// | DWLP_USER (DWLP_DLGPROC + sizeof(DLGPROC)) | Sets new extra info |
293
+ /// +-------------------------------------------------+---------------------------------------------------------------------------+
294
+ /// </param>
295
+ /// <param name="dwNewLong">The replacement value.</param>
296
+ /// <returns>
297
+ /// <para>If the function succeeds, the return value is the previous value of the specified offset.</para>
298
+ /// <para>If the function fails, the return value is zero. To get extended error information, call GetLastError.</para>
299
+ /// <para>If the previous value is zero and the function succeeds, the return value is zero, but the function does
300
+ /// not clear the last error information. To determine success or failure, clear the last error information by
301
+ /// calling SetLastError with 0, then call SetWindowLongPtr. Function failure will be indicated by a return value of
302
+ /// zero and a GetLastError result that is nonzero.</para>
303
+ /// </returns>
304
+ /// <remarks>
305
+ /// <list type="bullet">
306
+ /// <item>The return type, and the type of <paramref name="dwNewLong"/> are both LONG_PTR.
307
+ /// LONG_PTR is defined as <code>__int64</code> on 64-bit platforms, and it is defined as <code>long</code>
308
+ /// on 32-bit platforms. This definition fits nicely with now <see cref="IntPtr"/> works on 32-bit vs. 64-bit
309
+ /// platforms.</item>
310
+ /// <item>Windows XP/2000: The SetWindowLongPtr function fails if the window specified by the
311
+ /// <paramref name="hWnd"/> parameter does not belong to the same process as the calling thread.</item>
312
+ /// <item>
313
+ /// <para>Certain window data is cached, so changes you make using SetWindowLongPtr will not take effect until you call
314
+ /// the SetWindowPos function.</para>
315
+ /// <para>If you use SetWindowLongPtr with the <see cref="WindowLongIndexFlags.GWLP_WNDPROC"/> index to replace the window procedure,
316
+ /// the window procedure must conform to the guidelines specified in the description of the WindowProc callback function.</para>
317
+ /// <para>If you use SetWindowLongPtr with the <see cref="WindowLongIndexFlags.DWLP_MSGRESULT"/> index to set the return value for a
318
+ /// message processed by a dialog box procedure, the dialog box procedure should return TRUE directly afterward. Otherwise, if you call
319
+ /// any function that results in your dialog box procedure receiving a window message, the nested window message could overwrite the return value
320
+ /// you set by using <see cref="WindowLongIndexFlags.DWLP_MSGRESULT"/>.</para>
321
+ /// <para>Calling SetWindowLongPtr with the <see cref="WindowLongIndexFlags.GWLP_WNDPROC"/> index creates a subclass of the window
322
+ /// class used to create the window. An application can subclass a system class, but should not subclass a window class created by another process.
323
+ /// The SetWindowLongPtr function creates the window subclass by changing the window procedure associated with a particular
324
+ /// window class, causing the system to call the new window procedure instead of the previous one. An application must pass
325
+ /// any messages not processed by the new window procedure to the previous window procedure by calling CallWindowProc.
326
+ /// This allows the application to create a chain of window procedures.</para>
327
+ /// <para>Reserve extra window memory by specifying a nonzero value in the <see cref="WNDCLASSEX.cbWndExtra"/> member of the
328
+ /// <see cref="WNDCLASSEX"/> structure used with the RegisterClassEx function.</para>
329
+ /// <para>Do not call SetWindowLongPtr with the <see cref="WindowLongIndexFlags.GWLP_HWNDPARENT"/> index to change the parent of a
330
+ /// child window. Instead, use the SetParent function.</para>
331
+ /// <para>If the window has a class style of <see cref="ClassStyles.CS_CLASSDC"/> or <see cref="ClassStyles.CS_PARENTDC"/>, do not set
332
+ /// the extended window styles <see cref="WindowStylesEx.WS_EX_COMPOSITED"/> or <see cref="WindowStylesEx.WS_EX_LAYERED"/>.</para>
333
+ /// <para>Calling SetWindowLongPtr to set the style on a progressbar will reset its position.</para>
334
+ /// </item>
335
+ /// </list>
336
+ /// </remarks>
337
+ [ DllImport ( nameof ( User32 ) , SetLastError = true ) ]
338
+ public static extern unsafe void * SetWindowLongPtr ( IntPtr hWnd , WindowLongIndexFlags nIndex , void * dwNewLong ) ;
339
+
262
340
[ DllImport ( nameof ( User32 ) , SetLastError = true , CharSet = CharSet . Unicode ) ]
263
341
public static extern int GetWindowLong ( IntPtr hWnd , WindowLongIndexFlags nIndex ) ;
264
342
0 commit comments