Sharing WndProc
This should be simple, but... if I create four child windows that all have the same WndProc, what''s the simplest way to determine which Child Window I''m processing messages for? I figured out a way to do it, but I think it''s clunky.
Is there a standard way?
Thanks
"It's obvious isn't it Miller? Curiosity killed these cats!"
September 17, 2000 11:20 AM
When you register your window class you set the WndProc that a window will use. You just register which windows you want. The reason for this is that each window has a reason it''s been created, so if you create a window for an overhead view then you''d usually want each of those windows to have an overhead view and act exactly the same. If you''d like a window to do something else then you register another window class type.
Hope that helps...
n!
Hope that helps...
n!
From the top of my head, I would say there is a HWND pointer passed to the WndProc function when it''s called, telling Wndproc who''s calling it... Otherwise check out MSDN.microsoft.com ... if it ain''t explained in there, it probably doesn''t exist
-----------------------------Sancte Isidore ora pro nobis !
I go with ahw, but I don't exactly understand what you're asking - what do you want to use it for?
You could do a SetWindowLong(hWnd, GWL_USERDATA, (LONG)pData); to add a pointer to each window. You can attach an object to each window this way (but you'll have to register this window-class with WNDCLASS wc.cbWndExtra = sizeof(void *); (or more for more data);
(ps: Just wish we had a nice New Win32 Forum for problems like these )
Edited by - baskuenen on September 17, 2000 9:00:57 PM
You could do a SetWindowLong(hWnd, GWL_USERDATA, (LONG)pData); to add a pointer to each window. You can attach an object to each window this way (but you'll have to register this window-class with WNDCLASS wc.cbWndExtra = sizeof(void *); (or more for more data);
(ps: Just wish we had a nice New Win32 Forum for problems like these )
Edited by - baskuenen on September 17, 2000 9:00:57 PM
First, thanks everybody.
What I was trying to do was create a standard 4 window modelling type area (top, side, front, render, etc.) My render view was going to be a separate proc, but I was thinking to use the same proc for the other views and just check for the view type within the processing code. Maybe I should follow anonymous'' advice and use a separate proc (or at least class) for each view.
But, barring that, ahw & Baskuenen, yes, the HWND is the simple answer. I don''t know what it is, if you don''t see the obvious right away, you don''t ever seem to see it. Thanks.
I had also, this afternoon, thought about putting the WndProc for the views inside the view class. I''m not good enough at Windows programming to know whether that''s a good idea or not. What do you think?
And, Baskuenen, the Win32 forum is a great idea. You''ve got my vote.
"That ain''t the soup du jour. I had soup du jour once. It was chicken"
What I was trying to do was create a standard 4 window modelling type area (top, side, front, render, etc.) My render view was going to be a separate proc, but I was thinking to use the same proc for the other views and just check for the view type within the processing code. Maybe I should follow anonymous'' advice and use a separate proc (or at least class) for each view.
But, barring that, ahw & Baskuenen, yes, the HWND is the simple answer. I don''t know what it is, if you don''t see the obvious right away, you don''t ever seem to see it. Thanks.
I had also, this afternoon, thought about putting the WndProc for the views inside the view class. I''m not good enough at Windows programming to know whether that''s a good idea or not. What do you think?
And, Baskuenen, the Win32 forum is a great idea. You''ve got my vote.
"That ain''t the soup du jour. I had soup du jour once. It was chicken"
"It's obvious isn't it Miller? Curiosity killed these cats!"
quote: Original post by justj
...
And, Baskuenen, the Win32 forum is a great idea. You''ve got my vote.
...
Yes, please - post your vote in the above forum. If we get enough votes and let the GDStaff know a lot of people would like a New Win32 Forum - maybe they will add it straight away...
Consider it done.
"It's obvious isn't it Miller? Curiosity killed these cats!"
September 18, 2000 08:11 AM
You asked how to create a window that uses a different wndproc, without knowing what you wanted to do I just answered the question
Yup, if you want multiple views that work the same then use a single window class and pass in extra data via the cbWndExtra tag.
n!
Yup, if you want multiple views that work the same then use a single window class and pass in extra data via the cbWndExtra tag.
n!
September 18, 2000 08:12 AM
Actually, rereading your original posting I probably read it wrong in the first place, apologies...
n!
n!
No apologies necessary. Actually, the more I get into laying out the code, I may end up taking your original advice. At first, I though a lot of the processing for each view would be pretty similar, but I think I''m just going to end up with a whole bunch of "if top_view" type stuff.
You''re not a member of the Anonymous 4 by any chance? Love your music
"That ain't soup du jour. I had soup du jour once. It was chicken"
You''re not a member of the Anonymous 4 by any chance? Love your music
"That ain't soup du jour. I had soup du jour once. It was chicken"
"It's obvious isn't it Miller? Curiosity killed these cats!"
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement