Announcement

Collapse
No announcement yet.

Is this safe to use?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Steve Hutchesson
    replied
    Mark,

    Something I should have remembered is an old trick in custom controls
    that do not use a title bar if you need additional memory on an instance
    basis, the memory allocated to a window for text is usually not used so
    you can use that as well if you are running out of room with the extra
    memory allocated in the WNDCLASSEX structure.

    It is a bit more messing around to access it as it was not directly
    designed to be used in this manner but it gives you an extra byte sequence
    to use that can be loaded any way you like.

    Regards,

    [email protected]

    ------------------

    Leave a comment:


  • Edwin Knoppert
    replied
    Hopefully DDT will NOT use this UserData in the next release.
    It should be used by the programmer, not the engine.

    Sorry.

    ------------------
    [email protected]

    Leave a comment:


  • Steve Hutchesson
    replied
    Mark,

    If you create the window using the CreateWindowEx() function, then
    you should be able to use this value if you want to.

    Regards,

    [email protected]

    ------------------

    Leave a comment:


  • Guest's Avatar
    Guest replied
    So let me get this straight, as long as I DONT use DDT then it is
    completely safe to use this userdata area. I am writing a custom
    control that uses a structure/type to store instance related data
    about the control. I dont use any DDT so this should be ok then?



    ------------------
    Cheers

    Leave a comment:


  • Steve Hutchesson
    replied
    Mark,

    ======================================

    MSDN
    ~~~~
    GWL_USERDATA
    Retrieves the 32-bit value associated with the window. Each window has a
    corresponding 32-bit value intended for use by the application that
    created the window.

    ======================================

    This says you can use it for whatever you like but the normal
    recommendation from MSDN is as follows.

    ======================================

    Remarks
    Reserve extra window memory by specifying a nonzero value in the
    cbWndExtra member of the WNDCLASSEX structure used with the
    RegisterClassEx function.

    ======================================

    There is no problems using pointers in the 40 bytes of memory that you can
    allocate in the extra window memory, probably the pick of the crop in memory
    allocation functions is the older GlobalAlloc() as it handles small amounts
    of memory well.

    The result of either VarPtr() or StrPtr() is a 32 bit variable so it will fit
    into any of the 4 byte long allocations in the extra memory fine.

    Regards,

    [email protected]

    ------------------

    Leave a comment:


  • Tom Hanlin
    replied
    Sure, with the usual caveats. There is no point in storing a pointer
    to a data item that may move or disappear, for example.

    ...eh, provided you're not using DDT, I guess. Good catch!

    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Leave a comment:


  • Semen Matusovski
    replied
    mark --
    ddt uses %gwl_userdata.
    see, for example,


    [this message has been edited by semen matusovski (edited october 31, 2000).]

    Leave a comment:


  • Guest's Avatar
    Guest started a topic Is this safe to use?

    Is this safe to use?

    Hello,


    Is it safe to use these to store a pointer?


    Pointer = GetWindowLong(hWnd, %GWL_USERDATA)
    SetWindowLong(hWnd, %GWL_USERDATA, Pointer)

    Just wondering...


    ------------------
    Cheers
Working...
X