Thread: proper way to store info for a window

  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, 03: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, 03:12 PM
  4. Resource ICONs
    By gbaker in forum Windows Programming
    Replies: 4
    Last Post: 12-15-2003, 07:18 AM
  5. Replies: 5
    Last Post: 03-05-2003, 03:28 PM