Advertisement

Sending custom messages

Started by November 06, 2000 10:07 PM
2 comments, last by Orpheum 24 years, 2 months ago
For my map editor, I have created a static window on the right side of the screen to hold columns of 5 child windows each. Each of these smaller child windows will display 1 tile from the tileset. What Im stuck on is how do I notify these bastards of what tile they are supposed to draw? Is there a custom windows message I can send, or a value I can send to the WndProc of the child windows?? I gave all the child windows based on that class some extra storage to hold the index into the tileset like so "wndclass.cbWndExtra = sizeof(int);", but Im having trouble wrapping my brain around how it is going to get that info! Im still pretty new to Win32 so its fairly possible Im overlooking something simple. I''ve been digging around in MSDN, but its so unwieldy when you dont really know what youre looking for.
There is no spoon.
There is a constant value define as WM_USER. In order to send your child controls your own message, and do whatever you want on that message, you need to define your own by doing something like this:

#define WM_UPDATESCREEN WM_USER+100

// Then you in your program you can do something like:
...

SendMessage( hChildWindow, WM_UPDATESCREEN, 0, 0 );

// instead of 0''s as parameters to SendMessage, you can pass your own data, and use that in the child windows'' handlers to do a number of things.

// Then your message handler might look like this:

LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch( uMsg )
{
case WM_CREATE:
{
...
break;
}
case WM_DESTROY:
{
PostQuitMessage( 0 );
return 0;
}
case WM_UPDATESCREEN:
{
RepaintThoseChildControls();
break;
}
}
return DefWindowProc( hWnd, uMsg, wParam, lParam );
}

Hope this helps you get the idea.

If you have questions, ask!

-------------------------------
"Shunji is a nutcase" - Voice

..-=gLaDiAtOr=-..
Advertisement
I found something called SetWindowLong(hwnd, GWL_USERDATA, data)... currently the whole deal doesnt work, but theres a fair amount of new code to get the less than ideal situation to work so I think debugging is in order. =) Im trying to get these 32x32 child windows to display a tile from the tileset, but theyre blank for some reason. Anyone got any caveats for Get/SetWindowLong??
There is no spoon.
I use GWL_USERDATA to store a pointer to whatever info the window needs - in C++ it''s a great place to stick the this pointer for a given window. The only caveat is that you can only use it for windows that you create. If you''re using a third party library or custom control or something they may already be using it for thier own purposes.

-Mike

This topic is closed to new replies.

Advertisement