Thread: Handling controls (buttons, edit boxes) width WndProc on a custom class.

  1. #1
    Registered User
    Join Date
    Apr 2012
    Posts
    5

    Handling controls (buttons, edit boxes) width WndProc on a custom class.

    edit : with WndProc...*

    Hello you!
    First of all, let me apologize if I'm in the wrong section of the forum. If I am, please indicate me where is the right place.

    Well, as a Win32 programmer, there was a day when I said: "For me enough of all of this window creation procedures" (refering to those WNDCLASS, HWND, CreateWindow, etc...). So I wanted to make my own class, in a way that I could be able to create my windows with just one or two lines in my main method. Like:

    Window w("WindowName", 0, 0, 500, 500);

    After good hours of research, I made it. I created my own class with the static WndProc redirecting to the non-static one.
    Even, in my main I can do stuffs like:

    w.attachEvent(eventFunction, WM_MOUSEMOVE);

    Properly creating the eventFunction and passing it's pointer.
    However, my problem now is to deal with controls (buttons, edit boxes, scroll bars, and so). I guess there is no how to indicate their respectives WndProcs, since the WM_NCCREATE does not get call when dealing with these controls.

    My static WndProc process follows:

    Code:
    LRESULT CALLBACK OglWindow::staticHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
    {
        OglWindow *window = NULL;
    
        if (msg == WM_NCCREATE)
            SetWindowLong(hWnd, GWL_USERDATA, (long)((LPCREATESTRUCT(lParam))->lpCreateParams));
        else window = (OglWindow *)GetWindowLong(hWnd, GWL_USERDATA);
        if (window)
        {
            currentWindow = window;
            window->mainHandler(msg, wParam, lParam);
        }
        return DefWindowProc(hWnd, msg, wParam, lParam);
    }
    And in my class constructor, after creating the HWND, I call
    Code:
    this->oldProc = (WNDPROC)SetWindowLongPtr(window, GWL_WNDPROC, (LONG_PTR)staticHandler);
    Now I just need a way to deal with my controls, and call the CallWindowProc(oldProc, hWnd, msg, wParam, lParam) at the end.


    I want to sorry you for my english, as well. I made my best with some help of the Google Tradutor

    Thank you
    Last edited by Antony Kossoski; 04-13-2012 at 09:11 PM. Reason: Wrong Title

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to change the color of Buttons and edit controls
    By jayapalchandran in forum Windows Programming
    Replies: 2
    Last Post: 08-26-2006, 10:47 AM
  2. Adding buttons, edit boxes, etc to the window
    By rainmanddw in forum Windows Programming
    Replies: 1
    Last Post: 04-10-2006, 03:07 PM
  3. Edit Boxes and Command buttons
    By MetallicA in forum Windows Programming
    Replies: 6
    Last Post: 06-15-2005, 09:26 PM
  4. Buttons In Dialog Boxes
    By ElWhapo in forum Windows Programming
    Replies: 2
    Last Post: 02-10-2005, 06:46 PM
  5. Edit boxes, and list boxes
    By osal in forum Windows Programming
    Replies: 2
    Last Post: 07-07-2004, 12:34 PM