Intercept mesages from a control ? - Programmers Heaven

Howdy, Stranger!

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

Categories

Intercept mesages from a control ?


How do I intercept WM_LBUTTONDOWN of edit control?

Many thanks.

Comments

  • pseudocoderpseudocoder Posts: 689Member ✭✭✭
    subclass the control

    [code]

    HWND hParent;
    WNDPROC wpEdit;

    LRESULT CALLBACK EditProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {

    LRESULT lRes;

    if(msg != WM_MOUSEMOVE) {
    lRes = CallWindowProc(wpEdit, hwnd, msg, wParam, lParam);
    } else {
    return DefWindowProc(hwnd, msg, wParam, lParam);
    }

    if(msg == WM_LBUTTONDOWN) {
    // code
    MessageBox(hwnd, TEXT("lbutton click test"), TEXT(""), MB_OK);
    }
    return lRes;
    }

    LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {

    // bits of code
    static HWND hEdit1; // handle to edit control

    switch(msg) {

    WM_CREATE : // bits of code
    hParent = hwnd;
    wpEdit = (WNDPROC) SetWindowLong(hEdit1, GWL_WNDPROC, (LONG) EditProc);
    // bits of code
    break;

    WM_DESTORY : // bits of code
    SetWindowLong(hEdit1, GWL_WNDPROC, (LONG) wpEdit);
    // bits of code
    }
    // bits of code
    }[/code]

    something like that, I think.

Sign In or Register to comment.