how to invoke class non-static member variables

Hi, all
I am writing a MDI application by using WIN32 API, and now i have a problem with the child window.
I want to invoke class non-static member function in the child window procedure function. let me tell you how i did it.
Right after creating the handle of MDI child window, I use SetWindowLong() function to pass the class pointer to the window. then, in the static window procedure function, I use GetWindowLong() function to take the class pointer. after that, i invoke the non-static class member variables. I compile it, no error, but when I execute it, it get errors. part of codings are shown below:

void Connection::createDisplay()
hwndChild = CreateMDIWindow(...);
SetWindowLong(hwndChild, GWL_USERDATA, (LONG) this);

LRESULT CALLBACK Connection::WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
Connection *pConn = (Connection * ) GetWindowLong(hwnd, GWL_USERDATA);
switch (iMsg)
case WM_SIZE:
RECT rect;
GetClientRect(hwnd, &rect);
pConn->clientwidth = min( rect.right - rect.left, pConn->m_si.bufferwidth);
pConn->clientheight = min( rect.bottom -, pConn->m_si.bufferheight);
return DefMDIChildProc(hwnd, iMsg, wParam, lParam);

So when it is executed, the error points to the line pConn->clientwidth = min(...);
I suspect that the pointer pConn is invalid. But when I use this WndProc function as normal window procedure function (I mean non-MDI window), it doesn't have any errors, can work properly.
Does anybody tell me the reason about that? Is it the problem with MDI? so generally, my question is asked: "how to invoke the class non-static member variables in the static wndproc function?"
Thanks in advance!
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!