HOWTO: Use DWL_USER to Access Extra Bytes in a Dialog Box

ID: Q88358

The information in this article applies to:

SUMMARY

Windows extra bytes are used to store private information specific to an instance of a window. For dialog boxes, these extra bytes are already allocated by the dialog manager. The offset to the extra byte location is called DWL_USER.

DWL_USER is the 8th byte offset of the dialog extra bytes. The programmer has 4 bytes (a long) available from this offset for personal use.

CAUTION: DO NOT use more than 4 bytes of these extra bytes, as the rest of them are used by the dialog manager.

Example

   DWORD dwNumber = 10;
            .
            .
            .
            .
   case WM_INITDIALOG:
           SetWindowLong(hWnd,DWL_USER,dwNumber); // Store value 10 at
                                                  // byte offset 8
           dwNumber = GetWindowLong(hWnd,DWL_USER); // Retrieve the value

NOTE: GetWindowWord and SetWindowWord could be used instead.

Additional query words:

Keywords          : kbDlg kbNTOS kbGrpUser kbWinOS kbWndw kbWndwProp 
Issue type        : kbhowto

Last Reviewed: December 18, 1998