Multiple windows, one callback?

SephirothSephiroth Fayetteville, NC, USA
OK, I have my level editor up and running, minus scrolling the three 2D view windows. Now, the 2D views are just child windows of my main app window, and so far handling them within the main app callback has worked perfectly. Now each 2D view has two scrollbars to scroll from -32700 to 32700. I know how to setup the scrollbars with SCROLLINFO and such, but since I have three windows (ID_TOP, ID_FRONT, ID_SIDE), how can I figure out which window is sending the WM_H/VSCROLL message and scroll it? Is the HWND sent in the LPARAM or WPARAM somewhere? Once I know how to tell which window is sending the scroll request, I think I'll be set. Thanks for the help in advance.

-[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

Comments

  • : OK, I have my level editor up and running, minus scrolling the three 2D view windows. Now, the 2D views are just child windows of my main app window, and so far handling them within the main app callback has worked perfectly. Now each 2D view has two scrollbars to scroll from -32700 to 32700. I know how to setup the scrollbars with SCROLLINFO and such, but since I have three windows (ID_TOP, ID_FRONT, ID_SIDE), how can I figure out which window is sending the WM_H/VSCROLL message and scroll it? Is the HWND sent in the LPARAM or WPARAM somewhere? Once I know how to tell which window is sending the scroll request, I think I'll be set. Thanks for the help in advance.
    : -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]
    :

    The scrolling messages are sent to the 2D child views, you just have to re-translate them into the main callback.
  • SephirothSephiroth Fayetteville, NC, USA
    : The scrolling messages are sent to the 2D child views, you just have to re-translate them into the main callback.
    :
    OK, how would I do this? The child windows are "STATIC", and have no callback of their own. That's what's messing with me. I create the windows with WS_HSCROLL | WS_VSCROLL in the CreateWindowEx() call, so I figured the messages were going to the child windows, but since they have no callback, how do i grab them and figure out which window is sending it? Oh and like, thanks for the FAST reply Asm!

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

  • SephirothSephiroth Fayetteville, NC, USA
    OK, even though my child window scrollbars have a set range and appear to be enabled, you can NOT press or drag them! I tried EnableScrollBar() but they still won't work. This is another problem, aside from letting the parent callback do the work. I've already coded the lines that will adjust the viewing rectangle properly, now if it would just work!

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

  • : : The scrolling messages are sent to the 2D child views, you just have to re-translate them into the main callback.
    : :
    : OK, how would I do this? The child windows are "STATIC", and have no callback of their own. That's what's messing with me. I create the windows with WS_HSCROLL | WS_VSCROLL in the CreateWindowEx() call, so I figured the messages were going to the child windows, but since they have no callback, how do i grab them and figure out which window is sending it? Oh and like, thanks for the FAST reply Asm!
    :
    : -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]
    :
    :
    How, do you paint then inside your child windows? Do not tell me you just do 'GetDC()' and forcibly draw on it!? Well, jokes aside, for that complex system as you biult you definitely need the child window of your own class - register it and just create it 3 times as you did before. In fact, just replace "STATIC" in call to 'CreateWindow()' with your registered window. This way you get a callback and the rest, so you can control it fully. What if you need to be in focus in one of these panels and want to get a key pressed - can't do it without callback...

    Cheers!

  • SephirothSephiroth Fayetteville, NC, USA
    Yeah, I use GetDC. It does the job and you don't have to declare another variable like PaintStruct. There some advantage to using another form?

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

  • All subclass those static controls:

    [code]
    WNDPROC g_originalStaticProc = NULL; // keep it global or somewhere reachable from all the code.

    // after you created your 3 static windows lets say hWndStatic[3]

    // they all have the same proc, so get it from the first one.
    g_originalStaticProc = (WNDPROC)GetWindowLong(hWndStatic[0], GWL_WNDPROC);

    // original question, yes.. you can use one proc for all 3.
    for(int i = 0; i < 3; i++)
    SetWindowLong(hWndStatic[i], GWL_WNDPROC, (LONG)MyStaticWndProc);

    // and this is your new proc
    LRESULT WINAPI MyStaticWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    switch(message)
    {
    // case whatever message you want..

    case WM_PAINT:
    // move your GetDC() code to paint the static window here
    // replacing GetDC with BeginPaint of course..
    return 0; // we dont need or want to call the original paint procedure.

    case WM_HSCROLL: // however these got sent here, maybe a
    SendMessage from your main window.
    case WM_HSCROLL:
    return 0;

    default:
    break; // to call the original proc
    }

    CallWndProc(g_originalStaticProc, hWnd, message, wParam, lParam);
    }
    [/code]

    You can also subclass your scroll bars if you want. Same method as above (different g_originalXXXProc since its a different class) and you can maybe do this:
    [code]
    case WM_HSCROLL:
    case WM_VSCROLL:
    for(int i = 0; i < 3; i++)
    SendMessage(hWndStatic[i], message, wParam, lParam);
    [/code]

    : Yeah, I use GetDC. It does the job and you don't have to declare another variable like PaintStruct. There some advantage to using another form?
    :
    : -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]
    :
    :

  • : : The scrolling messages are sent to the 2D child views, you just have to re-translate them into the main callback.
    : :
    : OK, how would I do this? The child windows are "STATIC", and have no callback of their own. That's what's messing with me. I create the windows with WS_HSCROLL | WS_VSCROLL in the CreateWindowEx() call, so I figured the messages were going to the child windows, but since they have no callback, how do i grab them and figure out which window is sending it? Oh and like, thanks for the FAST reply Asm!
    :
    : -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]
    :
    :

    Enumerate all child windows of your main window, select the ones
    belonging to the 'STATIC' class and replace their window procedure with a custom one...

    I know this is not a very clean procedure, but it worked for me just fine B-)

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories