Window Class Memory

This is a discussion on Window Class Memory within the Windows Programming forums, part of the Platform Specific Boards category; Hi all, I've got some questions about window class memory - the memory you allocate by setting the cbClsExtra member ...

  1. #1
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,892

    Window Class Memory

    Hi all,

    I've got some questions about window class memory - the memory you allocate by setting the cbClsExtra member of a WNDCLASS(EX) to a value greater than 0.

    The problem I have is this: I want to store some strings I loaded from somewhere, which will remain the same for all instances of the window class. So it would be a good idea to load these strings once and store pointers to them in the class extra memory.

    Which begs the question of initialization/deinitialization. Initialization is the easy part: In WM_CREATE, I can simply check if the pointers are NULL, and if they are, load the strings.

    I can't deinitialize them in WM_DESTROY. I don't know if there are other windows of the same class, who I would steal the memory from. (And heaven help me if those windows run in a different thread.)

    Neither can I deinitialize it at any later point, because there is no way to access the memory without an actual window instance.

    It would be possible to reserve even more memory and implement reference counting, but is it worth it? Are there better alternatives?
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    You could just leave the memory to be released on process termination.

    >> It would be possible to reserve even more memory and implement reference counting, but is it worth it? <<

    It's only four bytes...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  2. opengl help
    By heat511 in forum Game Programming
    Replies: 4
    Last Post: 04-05-2004, 01:08 AM
  3. Experienced coders read. ( Common/efficient writing )
    By knave in forum C++ Programming
    Replies: 8
    Last Post: 04-23-2003, 09:07 PM
  4. How to change window style at runtime?
    By Mr. Bitmap in forum Windows Programming
    Replies: 5
    Last Post: 06-09-2002, 04:49 PM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 09:01 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21