Creating Controls in Assembler
  • Preface
    • Author
    • Guidelines
  • Introduction
    • Controls & Modern UI Design
    • The HotMenu Quest
  • Our First Control
    • External End-User Functions
    • Internal Functions
  • Registering Our Control
  • Creating Our Control
  • Inside Our Control
    • On Creation: WM_CREATE
    • On Destroying: WM_NCDESTROY
    • Handling Other Messages For Our Control
  • Initializing Our Control
  • Painting Our Control
  • Using Our Control
  • Control Properties
    • The Memory Used To Store Properties
    • Property Structures & Constants
    • Using Macros To Get/Set Properties
    • Using The Win32 API To Get/Set Properties
    • Internal Wrapper Functions
  • Additional Resources
    • RadASM Auto-complete
    • The ModernUI Framework
Powered by GitBook
On this page

Was this helpful?

  1. Control Properties

The Memory Used To Store Properties

PreviousControl PropertiesNextProperty Structures & Constants

Last updated 5 years ago

Was this helpful?

Our __AllocMemProperties function which is used in the WM_CREATE message of the main processing function _SB_WndProc, will allocate the memory size required based on two structures we use named _SIMPLEBUTTON_PROPERTIES and SIMPLEBUTTON_PROPERTIES (See for details). Of course we could use other means to pass the size of memory required - I just felt that it was more convenient to use a structure for better organisation of the properties used.

It is entirely possible to expand on this and create a function for the end-user that can make use of the external SIMPLEBUTTON_PROPERTIES structure and allow the end-user to pass as a parameter to the function. a pointer to a variable defined as a SIMPLEBUTTON_PROPERTIES type. The function could then iterate through each field and set the appropriate values for the control to make use of. Additional checks would be required for the size of the passed parameter to ensure it is correct, to prevent buffer overflows for example. A lot of Microsoft's own structures make use of a cbSize field to validate the structure.

__AllocMemProperties will store the pointer to the memory allocated, in the extra window bytes allocated by cbWndExtra, by making use of calls to .

Note: INTERNAL_PROPERTIES is a constant that equals 0, whereas theEXTERNAL_PROPERTIES constant equals 4 - created for myself just for convenience as a wrapper to call the function with the specified offset into the extra memory reserved by cbWndExtra at our controls registration.

Internally the __AllocaMemProperties function calls either of the following:

Invoke SetWindowLong, hControl, 0, PtrAllocMem- To set the pointer to the memory that will store the internal properties.

Invoke SetWindowLong, hControl, 4, PtrAllocMem - To set the pointer to memory that will store the external properties.

PtrAllocMem is the pointer to our memory that was allocated using from within __AllocMemProperties

Property Structures & Constants
SetWindowLong
SetWindowLong
GlobalAlloc