proper way to store info for a window

This is a discussion on proper way to store info for a window within the Windows Programming forums, part of the Platform Specific Boards category; Okay, here's another newbie question, which I get conflicting answers to when I ask people I know. What is the ...

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    51

    proper way to store info for a window

    Okay, here's another newbie question, which I get conflicting answers to when I ask people I know.

    What is the proper way to get information to your window to and how are you going to store it?

    Most times one would want to have your window routine know things like a pointer to what it's displaying, but since you can't just pass it each time your window routine is called, how are you supposed to do this correctly? I know one could just solve everything by using a global variable, but is this the correct way? I also found a way using static varaibles, but I am not sure of the scope of how well insulated that is from other windows that would call the routine.

    Thanks

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    You could set cbWndExtra in your WNDCLASSEX strucuture to the amount of extra data you want to store and then use GetWindowLong/SetWindowLong to get/set the data.
    Static variables in your window procedure are fine as long as you only have created one window that uses that procedure.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. creating a child window
    By rakan in forum Windows Programming
    Replies: 2
    Last Post: 01-23-2007, 02:22 PM
  2. Linking OpenGL in Dev-C++
    By linkofazeroth in forum Game Programming
    Replies: 4
    Last Post: 09-13-2005, 10:17 AM
  3. Help doing an e-mail program in c...
    By Tyler_Durden in forum C Programming
    Replies: 88
    Last Post: 01-02-2005, 02:12 PM
  4. Resource ICONs
    By gbaker in forum Windows Programming
    Replies: 4
    Last Post: 12-15-2003, 06:18 AM
  5. Replies: 5
    Last Post: 03-05-2003, 02:28 PM

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