Пример #1
0
LRESULT CALLBACK cWindow::_WndProc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam)
{  
	cWindow *wnd=0;

	if(message==WM_NCCREATE)
	{
		wnd=(cWindow*)LPCREATESTRUCT(lparam)->lpCreateParams;
		SetWindowLong(hwnd,GWL_USERDATA,LONG(LPCREATESTRUCT(lparam)->lpCreateParams));
		wnd->_hwnd=hwnd;      
	}

	wnd=(cWindow*)GetWindowLong(hwnd,GWL_USERDATA);

	if(wnd)
	{
		std::map<UINT,POINTER>::iterator it;
		it=wnd->_msgmap.find(message);

		if(it==wnd->_msgmap.end()) return DefWindowProc(hwnd,message,wparam,lparam);
		else
		{
			POINTER msg=it->second;        
			LRESULT result=(msg.wnd->*msg.func)(lparam,wparam);
			if(result) return result;
		}
	}
	return DefWindowProc(hwnd,message,wparam,lparam);
}
Пример #2
0
//---------------------------------------------------------
// If the window is associated with a class, call the
// messsage handler of the class
//---------------------------------------------------------
LRESULT CALLBACK Window::wndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	Message message = {uMsg, wParam, lParam, 0};
	Window* window = NULL;

	if (uMsg == WM_CREATE)
	{
		LPVOID& lpCreateParams = LPCREATESTRUCT(lParam)->lpCreateParams;

		if (lpCreateParams)
		{
			window = ((UACreationData*)(lpCreateParams))->window;
			SetWindowLong(hWnd, GWL_CLASSPOINTER, (LONG)window);
		}
	}
	else
		window = (Window*)(GetWindowLong(hWnd, GWL_CLASSPOINTER));

	if (window)
	{
		if (uMsg == WM_CREATE)
			const_cast<HWND>(window->hWnd) = hWnd;
		window->windowProc(message);
		if (uMsg == WM_NCDESTROY)
			const_cast<HWND>(window->hWnd) = NULL;
		return message.lResult;
	}
	return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
Пример #3
0
LRESULT CALLBACK WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
    switch(msg) {
    case WM_CREATE:
        SetWindowLong(hWnd, GWL_USERDATA, LONG(LPCREATESTRUCT(lParam)->lpCreateParams));
        break;

    case WM_DESTROY:
        PostQuitMessage(0);
        printf("Destroy\n");

        return 0;
        break;

    default:
        DisplayWindow* displayWindow = (DisplayWindow*)GetWindowLong(hWnd, GWL_USERDATA);

        if (displayWindow != NULL) {
            return displayWindow->handleMessage(hWnd, msg, wParam, lParam);
        } else {
            return DefWindowProc(hWnd, msg, wParam, lParam);
        }
        break;
    }

    return 0;
}
LRESULT CALLBACK Synchronizer::s_wndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) // Win32-only
{
	Synchronizer * pThis;
	int swlresult;
	switch (msg)
	{
	
	case WM_NCCREATE:
		pThis = (Synchronizer *)((LPCREATESTRUCT(lParam))->lpCreateParams);
		UT_return_val_if_fail(pThis, 0);
		pThis->m_hWnd = hWnd;
		SetLastError(0);
		swlresult=SetWindowLongPtrW(hWnd,GWLP_USERDATA,LONG_PTR(pThis));
		if (swlresult==0)
		{
			// we might have an error
			int errorcode=GetLastError();
			if (errorcode)
			{
				UT_DEBUGMSG(("Error in setting the WindowLong GWLP_USERDATA: %d\n", errorcode));
			}
			
		}
		return 1;
		
	case WM_ABI_SYNCHRONIZER:
		UT_DEBUGMSG(("Received a message in Synchronizer message loop! 0x%x\n", msg));
		pThis = (Synchronizer *)GetWindowLongPtrW(hWnd,GWLP_USERDATA);
		UT_return_val_if_fail(pThis, 0);
		if (pThis->m_bIsProcessing)
		{
			pThis->m_iDeferredMessages++;
		}
		else
		{
			pThis->m_bIsProcessing = true;
			bool bIsDestroyed = false;
			pThis->m_bIsDestroyed = &bIsDestroyed;
			pThis->callMainloop();
			while (!bIsDestroyed && pThis->m_iDeferredMessages)
			{
				pThis->callMainloop();
				--pThis->m_iDeferredMessages;
			}
			if (!bIsDestroyed) 
			{
				pThis->m_bIsProcessing = false;
				pThis->m_bIsDestroyed = NULL;
			}
		}
		return true;

	default:
		UT_DEBUGMSG(("return DefWindowProc for message 0x%x\n", msg));
		// We do not want to handle this message so pass back to Windows
		// to handle it in a default way
		return 0;
	}
}
Пример #5
0
//static function for callback
LRESULT CALLBACK gspOut::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {

	//begin process of routing to the non-static callback function
	if (msg == WM_NCCREATE)
		SetWindowLongPtr(hwnd, GWLP_USERDATA, (long)((LPCREATESTRUCT(lParam))->lpCreateParams));

	//pointer object based off of the current window and point to the non-static callback
	gspOut* base = reinterpret_cast<gspOut*>( GetWindowLongPtr(hwnd, GWLP_USERDATA) );

	if (!base) return DefWindowProc(hwnd,msg,wParam,lParam);
	else return base->WndProcNS(hwnd,msg,wParam,lParam);
}
	LRESULT CALLBACK RouterProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){
		Window *window;
		if(message!=WM_NCCREATE){
			window = (Window *)GetWindowLongPtr(hWnd, GWL_USERDATA);
			if(window == 0) {
				return DefWindowProc(hWnd,message,wParam,lParam);
			}
			return window->WinProc(hWnd, message, wParam, lParam);
		}
		else {
			SetWindowLongPtr(hWnd, GWL_USERDATA, long((LPCREATESTRUCT(lParam))->lpCreateParams));
			return DefWindowProc(hWnd,message,wParam,lParam);
		}
	}
Пример #7
0
//---------------------------------------------------
LRESULT CALLBACK Window::stWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	Window* pWnd;

	if (uMsg == WM_NCCREATE)
		SetWindowLong(hWnd, GWL_USERDATA, (long)((LPCREATESTRUCT(lParam))->lpCreateParams));

	pWnd = GetObjectFromWindow(hWnd);

	if (pWnd)
		return pWnd->m_WndProcFunction(hWnd, uMsg, wParam, lParam, pWnd->m_WndProcOwner);
	else
		return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
Пример #8
0
LRESULT CALLBACK CWindow::stWinMsgHandler(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    CWindow * pWnd = nullptr;

    if (uMsg == WM_NCCREATE)
    {
        // get the pointer to the window from lpCreateParams which was set in CreateWindow
        SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)((LPCREATESTRUCT(lParam))->lpCreateParams));
    }

    // get the pointer to the window
    pWnd = GetObjectFromWindow(hwnd);

    // if we have the pointer, go to the message handler of the window
    // else, use DefWindowProc
    if (pWnd)
    {
        switch (uMsg)
        {
        case WM_ACTIVATE:
            if ((wParam == WA_ACTIVE)&&(!pWnd->bWindowRestored)&&(!pWnd->sRegistryPath.empty()))
            {
                WINDOWPLACEMENT wpl = {0};
                DWORD size = sizeof(wpl);
                if (SHGetValue(HKEY_CURRENT_USER, pWnd->sRegistryPath.c_str(), pWnd->sRegistryValue.c_str(), REG_NONE, &wpl, &size) == ERROR_SUCCESS)
                    SetWindowPlacement(hwnd, &wpl);
                else
                    ShowWindow(hwnd, SW_SHOW);
                pWnd->bWindowRestored = true;
            }
            break;
        case WM_CLOSE:
            if (!pWnd->sRegistryPath.empty())
            {
                WINDOWPLACEMENT wpl = {0};
                wpl.length = sizeof(WINDOWPLACEMENT);
                GetWindowPlacement(hwnd, &wpl);
                SHSetValue(HKEY_CURRENT_USER, pWnd->sRegistryPath.c_str(), pWnd->sRegistryValue.c_str(), REG_NONE, &wpl, sizeof(wpl));
            }
            break;
        }
        return pWnd->WinMsgHandler(hwnd, uMsg, wParam, lParam);
    }
    else
        return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
Пример #9
0
LRESULT CALLBACK WindowFrame::MsgRouter(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	WindowFrame* pWnd;

	if (uMsg == WM_NCCREATE)
	{
		// get the pointer to the window from lpCreateParams which was set in CreateWindow
		SetWindowLong(hwnd, GWL_USERDATA, (long)((LPCREATESTRUCT(lParam))->lpCreateParams));
	}
	
	pWnd =  (WindowFrame *)GetWindowLong(hwnd, GWL_USERDATA);           // get the pointer to the window	

	// if we have the pointer, go to the message handler of the window else, use DefWindowProc
	if (pWnd)
		return pWnd->WindowProc(hwnd, uMsg, wParam, lParam);
	else
		return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
Пример #10
0
/*
	You can not initialize the window class with a class method as the window 
	procedure unless it is a static method, so the class also needs a static 
	message handler that determines which instance of the class is the recipient 
	of the message and calls that instance's window procedure.

	See "http://www.gamedev.net/reference/articles/article1810.asp" for more info.
*/
LRESULT CALLBACK CBaseWindow::stWinMsgHandler(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	CBaseWindow* pWnd;

	if (uMsg == WM_NCCREATE)
	{
		// get the pointer to the window from lpCreateParams which was set in CreateWindow
		SetWindowLong(hwnd, GWL_USERDATA, (long)((LPCREATESTRUCT(lParam))->lpCreateParams));
	}

	// get the pointer to the window
	pWnd = GetObjectFromWindow(hwnd);

	// if we have the pointer, go to the message handler of the window
	// else, use DefWindowProc
	if (pWnd)
		return pWnd->WinMsgHandler(hwnd, uMsg, wParam, lParam);
	else
		return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
Пример #11
0
// this will be WNDCLASSEX::lpfnWndProc
LRESULT CALLBACK BaseWindow::msgRouter (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){
	//pointer to the window that will receive the message
	BaseWindow *wnd = 0;

	if(message == WM_NCCREATE){
		// receiving a WM_NCCREATE message means that a new window has just been created, 
		// so we need to associate the window's handle with its BaseWindow instance pointer
		SetWindowLong(hWnd, GWL_USERDATA, long((LPCREATESTRUCT(lParam))->lpCreateParams));
	}

	// we retrieve the instance of AbstractWindow that corresponds to the destination window's HWND
	wnd = (BaseWindow*) (GetWindowLong (hWnd, GWL_USERDATA));

	// we then route the message to the wndProc method defined in the derived BaseWindow class
	if (wnd)
		return wnd->wndProc(hWnd, message, wParam, lParam);
	else
		// for messages that arrive prior to WM_NCCREATE
		// and the HWND <-> BaseWindow * association was not made
		return DefWindowProc(hWnd, message, wParam, lParam);
}
Пример #12
0
LRESULT CALLBACK Canvas::stWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    Canvas* pWnd;

    if (uMsg == WM_INITDIALOG)
    {
        SetWindowLong(hwnd, GWL_USERDATA, lParam);
    }
    else if (uMsg == WM_CREATE)
    {
        SetWindowLong(hwnd, GWL_USERDATA, (LONG_PTR)((LPCREATESTRUCT(lParam))->lpCreateParams));
    }

    // get the pointer to the window
    pWnd = GetObjectFromWindow(hwnd);

    // if we have the pointer, go to the message handler of the window
    // else, use DefWindowProc
    if (pWnd)
        return pWnd->WindowProc(hwnd, uMsg, wParam, lParam);
    else
        return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
Пример #13
0
LRESULT CALLBACK csGraphics2DOpenGL::DummyWindow (HWND hWnd, UINT message,
  WPARAM wParam, LPARAM lParam)
{
  switch(message)
  {
  case WM_CREATE:
    {
      DummyWndInfo* dwi = (DummyWndInfo*)(LPCREATESTRUCT(lParam)->lpCreateParams);

      HDC hDC = GetDC (hWnd);
      int acceleration = dwi->this_->config->GetBool (
	"Video.OpenGL.FullAcceleration", true) ? WGL_FULL_ACCELERATION_ARB : 
	WGL_GENERIC_ACCELERATION_ARB;
      csGLPixelFormatPicker& picker = *dwi->picker;

      int pixelFormat = dwi->this_->FindPixelFormatGDI (hDC, picker);
      PIXELFORMATDESCRIPTOR pfd;
      if (DescribePixelFormat (hDC, pixelFormat, 
	sizeof(PIXELFORMATDESCRIPTOR), &pfd) == 0)
	SystemFatalError (L"DescribePixelFormat failed.");

      if (SetPixelFormat (hDC, pixelFormat, 0) != TRUE)
      {
	HRESULT spfErr = (HRESULT)GetLastError();
	SystemFatalError (L"SetPixelFormat failed.", spfErr);
      }

      HGLRC hGLRC = wglCreateContext (hDC);
      wglMakeCurrent (hDC, hGLRC);

      csGLExtensionManager& ext = dwi->this_->ext;
      ext.Open();

      dwi->this_->detector.DoDetection (hWnd, hDC);
      dwi->this_->OpenDriverDB ("preinit");

      ext.InitWGL_ARB_pixel_format (hDC);
      if (ext.CS_WGL_ARB_pixel_format)
      {
	unsigned int numFormats = 0;
	int iAttributes[26];
	float fAttributes[] = {0.0f, 0.0f};

	GLPixelFormat format;
	memcpy (format, dwi->chosenFormat, sizeof (GLPixelFormat));
	do
	{
	  int index = 0;
	  iAttributes[index++] = WGL_DRAW_TO_WINDOW_ARB;
	  iAttributes[index++] = GL_TRUE;
	  iAttributes[index++] = WGL_SUPPORT_OPENGL_ARB;
	  iAttributes[index++] = GL_TRUE;
	  iAttributes[index++] = WGL_ACCELERATION_ARB;
	  iAttributes[index++] = acceleration;
	  iAttributes[index++] = WGL_DOUBLE_BUFFER_ARB;
	  iAttributes[index++] = GL_TRUE;
	  iAttributes[index++] = WGL_SAMPLE_BUFFERS_ARB;
	  iAttributes[index++] = 
	    (format[glpfvMultiSamples] != 0) ? 1 : 0;
	  iAttributes[index++] = WGL_SAMPLES_ARB;
	  iAttributes[index++] = format[glpfvMultiSamples];
	  iAttributes[index++] = WGL_COLOR_BITS_ARB;
	  iAttributes[index++] = pfd.cColorBits;
  	  iAttributes[index++] = WGL_ALPHA_BITS_ARB;
  	  iAttributes[index++] = pfd.cAlphaBits;
  	  iAttributes[index++] = WGL_DEPTH_BITS_ARB;
	  iAttributes[index++] = pfd.cDepthBits;
	  iAttributes[index++] = WGL_STENCIL_BITS_ARB;
	  iAttributes[index++] = pfd.cStencilBits;	  
	  iAttributes[index++] = WGL_ACCUM_BITS_ARB;
	  iAttributes[index++] = pfd.cAccumBits;
	  iAttributes[index++] = WGL_ACCUM_ALPHA_BITS_ARB;
	  iAttributes[index++] = pfd.cAccumAlphaBits;
	  iAttributes[index++] = 0;
	  iAttributes[index++] = 0;

	  if ((ext.wglChoosePixelFormatARB (hDC, iAttributes, fAttributes,
	    1, &dwi->pixelFormat, &numFormats) == GL_TRUE) && (numFormats != 0))
	  {
	    int queriedAttrs[] = {WGL_SAMPLES_ARB};
	    const int queriedAttrNum = sizeof(queriedAttrs) / sizeof(int);
	    int attrValues[queriedAttrNum];

	    if (ext.wglGetPixelFormatAttribivARB (hDC, dwi->pixelFormat, 0,
	      queriedAttrNum, queriedAttrs, attrValues) == GL_TRUE)
	    {
	      (*dwi->chosenFormat)[glpfvMultiSamples] = attrValues[0];
	      break;
	    }
	  }
	}
	while (picker.GetNextFormat (format));
      }

      dwi->this_->driverdb.Close ();

      wglMakeCurrent (hDC, 0);
      wglDeleteContext (hGLRC);

      ReleaseDC (hWnd, hDC);
    }
    break;
  }
  return DefWindowProc (hWnd, message, wParam, lParam);
}
LRESULT CEquationEditorWindow::equationEditorWindowProc( HWND handle, UINT message, WPARAM wParam, LPARAM lParam )
{
	CEquationEditorWindow *wnd = nullptr;

	if( message == WM_NCCREATE ) {
		// Получаем указатель на экземпляр нашего окна, который мы передали в функцию CreateWindowEx
		wnd = static_cast< CEquationEditorWindow* >(LPCREATESTRUCT( lParam )->lpCreateParams);
		// И сохраняем в поле GWL_USERDATA
		::SetWindowLong( handle, GWL_USERDATA, reinterpret_cast< LONG >(LPCREATESTRUCT( lParam )->lpCreateParams) );
		// Запоминаем handle
		wnd->hwnd = handle;
	}
	// Теперь получаем указатель на наш экземпляр окна, но уже из поля GWL_USERDATA
	wnd = reinterpret_cast< CEquationEditorWindow* >(::GetWindowLong( handle, GWL_USERDATA ));

	switch( message ) {
		case WM_DESTROY:
			wnd->OnDestroy();
			return 0;

		case WM_CREATE:
			wnd->OnCreate();
			return 0;

		case WM_PAINT:
			wnd->OnDraw();
			return 0;

		case WM_SIZE:
			wnd->OnSize( LOWORD( lParam ), HIWORD( lParam ) );
			return 0;

		case WM_CHAR:
			wnd->OnChar( wParam );
			return 0;

		case WM_LBUTTONDOWN:
			wnd->OnLButtonDown( GET_X_LPARAM( lParam ), GET_Y_LPARAM( lParam ) );
			return 0;

		case WM_MOUSEMOVE:
			wnd->OnMouseMove( wParam, GET_X_LPARAM( lParam ), GET_Y_LPARAM( lParam ) );
			return 0;

		case WM_COMMAND:
			wnd->OnWmCommand( wParam, lParam );
			return 0;

		case WM_KEYDOWN:
			wnd->OnKeyDown( wParam );
			return 0;

		case WM_ERASEBKGND:
			return 0;

		case WM_VSCROLL:
			wnd->OnScroll( wParam );
			return 0;
	}
	return ::DefWindowProc( handle, message, wParam, lParam );
}
Пример #15
0
int OnCreate(LPARAM lParam)
{
	LPCREATESTRUCT p  = LPCREATESTRUCT(lParam);
	hInst			  = p->hInstance;
	return 0;
}
Пример #16
0
//----------------------------------------------------------------------------
LRESULT CALLBACK WinProc (HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
    FWinApplication* pkTheApp = FWinApplication::GetApplication();
    if ( !pkTheApp )
        return DefWindowProc(hWnd,uiMsg,wParam,lParam);

    switch ( uiMsg ) 
    {
        case WM_CREATE:
        {
            LPCREATESTRUCT lpCS = LPCREATESTRUCT(lParam);
            if ( pkTheApp->OnCreate(lpCS) )
                return 0;
            else
                return -1;
        }
        case WM_DESTROY:
        {
            pkTheApp->OnDestroy();
            PostQuitMessage(0);
            return 0;
        }
        case WM_PAINT:
        {
            PAINTSTRUCT kPS;
            HDC hDC = BeginPaint(hWnd,&kPS);
            if ( pkTheApp->OnPaint(hDC) )
            {
                EndPaint(hWnd,&kPS);
                return 0;
            }
            EndPaint(hWnd,&kPS);
            break;
        }
        case WM_ERASEBKGND:
        {
            HDC hDC = HDC(hWnd);
            if ( pkTheApp->OnEraseBkgnd(hDC) )
                return 0;
            break;
        }
        case WM_MOVE:
        {
            int xPos = int(LOWORD(lParam));
            int yPos = int(HIWORD(lParam));
            if ( pkTheApp->OnMove(xPos,yPos) )
                return 0;
            break;
        }
        case WM_SIZE:
        {
            int iWidth = int(LOWORD(lParam));
            int iHeight = int(HIWORD(lParam));
            unsigned int uiSizeType = (unsigned int)(wParam);
            if ( pkTheApp->OnSize(iWidth,iHeight,uiSizeType) )
                return 0;
            break;
        }
        case WM_COMMAND:
        {
            WORD wNotifyCode = HIWORD(wParam);
            WORD wID = LOWORD(wParam);
            HWND hwndCtl = HWND(lParam);
            if ( pkTheApp->OnCommand(wNotifyCode,wID,hwndCtl) )
                return 0;
            break;
        }
        case WM_SYSCHAR:
        {
            char cCharCode = char(wParam);
            long lKeyCode = long(lParam);
            if ( pkTheApp->OnSysChar(cCharCode,lKeyCode) )
                return 0;
            break;
        }
        case WM_SYSKEYDOWN:
        {
            int iVirtKey = int(wParam);
            long lKeyCode = long(lParam);
            if ( pkTheApp->OnSysKeyDown(iVirtKey,lKeyCode) )
                return 0;
            break;
        }
        case WM_SYSKEYUP:
        {
            int iVirtKey = int(wParam);
            long lKeyCode = long(lParam);
            if ( pkTheApp->OnSysKeyUp(iVirtKey,lKeyCode) )
                return 0;
            break;
        }
        case WM_CHAR:
        {
            char cCharCode = char(wParam);
            long lKeyData = long(lParam);
            if ( pkTheApp->OnChar(cCharCode,lKeyData) )
                return 0;
            break;
        }
        case WM_KEYDOWN:
        {
            int iVirtKey = int(wParam);
            long lKeyData = long(lParam);
            if ( pkTheApp->OnKeyDown(iVirtKey,lKeyData) )
                return 0;
            break;
        }
        case WM_KEYUP:
        {
            int iVirtKey = int(wParam);
            long lKeyData = long(lParam);
            if ( pkTheApp->OnKeyUp(iVirtKey,lKeyData) )
                return 0;
            break;
        }
        case WM_LBUTTONDOWN:
        {
            int iXPos = int(LOWORD(lParam));
            int iYPos = int(HIWORD(lParam));
            unsigned int uiKeys = (unsigned int)(wParam);
            if ( pkTheApp->OnLButtonDown(iXPos,iYPos,uiKeys) )
                return 0;
            break;
        }
        case WM_LBUTTONUP:
        {
            int iXPos = int(LOWORD(lParam));
            int iYPos = int(HIWORD(lParam));
            unsigned int uiKeys = (unsigned int)(wParam);
            if ( pkTheApp->OnLButtonUp(iXPos,iYPos,uiKeys) )
                return 0;
            break;
        }
        case WM_RBUTTONDOWN:
        {
            int iXPos = int(LOWORD(lParam));
            int iYPos = int(HIWORD(lParam));
            unsigned int uiKeys = (unsigned int)(wParam);
            if ( pkTheApp->OnRButtonDown(iXPos,iYPos,uiKeys) )
                return 0;
            break;
        }
        case WM_RBUTTONUP:
        {
            int iXPos = int(LOWORD(lParam));
            int iYPos = int(HIWORD(lParam));
            unsigned int uiKeys = (unsigned int)(wParam);
            if ( pkTheApp->OnRButtonUp(iXPos,iYPos,uiKeys) )
                return 0;
            break;
        }
        case WM_MOUSEMOVE:
        {
            int iXPos = int(LOWORD(lParam));
            int iYPos = int(HIWORD(lParam));
            unsigned int uiKeys = (unsigned int)(wParam);
            if ( pkTheApp->OnMouseMove(iXPos,iYPos,uiKeys) )
                return 0;
            break;
        }
        default:
        {
            if ( pkTheApp->OnDefault(wParam,lParam) )
                return 0;
            break;
        }
    }

    return DefWindowProc(hWnd,uiMsg,wParam,lParam);
}
Пример #17
0
LRESULT CALLBACK Listview_WindowProc(

    HWND hwnd,	// handle of window
    UINT uMsg,	// message identifier
    WPARAM wParam,	// first message parameter
    LPARAM lParam 	// second message parameter
   )
{
	LPLISTVIEW_PARAM lv = LPLISTVIEW_PARAM(GetWindowLong(hwnd, 16));
	WNDPROC pwndProc = (WNDPROC) GetWindowLong(hwnd, 12);
	switch(uMsg)
	{
	case WM_NCCREATE:
		{
			lv = InitializeListViewInstance(hwnd);
			TCHAR pszClassName[MAX_PATH] = { 0 };
			GetClassName(hwnd, pszClassName, MAX_PATH);
			if ( lstrcmpi(pszClassName, TEXT("DBFListView32")) )
			{
				int preflen = sizeof(DBF_CONTROL) / sizeof(TCHAR) - 1, chr = 0;
				while(chr <= preflen && pszClassName[chr] == DBF_CONTROL[chr] )
					chr++;

				if ( chr == preflen )
				{
					WNDCLASS wc = { 0 };
					if ( GetClassInfo( (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), &pszClassName[chr], &wc ) )
					{
						SetWindowLong(hwnd, 12, (LONG) wc.lpfnWndProc);
						lv->pfnWndProc = wc.lpfnWndProc;
						lv->fIsListView = FALSE;
						pwndProc = wc.lpfnWndProc;
					}
					else
						return FALSE;
				}
				else
					return FALSE;
			}

			SetRect(&lv->rc,
						LPCREATESTRUCT(lParam)->x,
						LPCREATESTRUCT(lParam)->y,
						LPCREATESTRUCT(lParam)->cx,
						LPCREATESTRUCT(lParam)->cy
						);
			lv->hHeader = NULL;
			break;
		}
	case WM_ERASEBKGND:
		{
			if ( lv->fIsListView )
			{
				if ( !lv->hHeader ) lv->hHeader = (HWND) lv->pfnWndProc(hwnd, LVM_GETHEADER, 0, 0);
				GetClientRect(lv->hHeader, &lv->header_rc);
				return CallWindowProc(lv->pfnWndProc, hwnd, uMsg, WPARAM(lv->hDC), lParam);
			}
			else
				return pwndProc(hwnd, uMsg, WPARAM(lv->hDC), lParam);

			break;
		}
	case WM_SIZING:
	case WM_SIZE:
		{
			GetClientRect(hwnd, &lv->rc);
			if ( lv->fIsListView )
			{
				if ( !lv->hHeader ) lv->hHeader = (HWND) lv->pfnWndProc(hwnd, LVM_GETHEADER, 0, 0);
				GetClientRect(lv->hHeader, &lv->header_rc);
			}
			break;
		}
	case WM_PRINT:
		{
			WNDPROC pwnd = ( lv->fIsListView ? lv->pfnWndProc : pwndProc );
//			pwnd(hwnd, WM_ERASEBKGND, (WPARAM) lv->hDC, 0);
//			pwnd(hwnd, WM_PAINT, (WPARAM) lv->hDC, 0);
			pwnd(hwnd, WM_PRINT, (WPARAM) lv->hDC, lParam);

			if ( !PBYTE(lv->pvBits)[0] )
				FillRect((HDC) wParam, &lv->rc, GetSysColorBrush(COLOR_WINDOW));
			else
				BitBlt((HDC) wParam, 0, 0, lv->rc.right, lv->rc.bottom, lv->hDC, 0, 0, SRCCOPY);
			return 0;
		}
	case WM_PAINT:
		{
			PAINTSTRUCT ps = { 0 };
			HDC hdc = BeginPaint(hwnd, &ps);
			if ( lv->fIsListView )
				CallWindowProc(lv->pfnWndProc, hwnd, uMsg, WPARAM(lv->hDC), lParam);
			else
				pwndProc(hwnd, uMsg, WPARAM(lv->hDC), lParam);
			
			if ( lv->fIsListView )
				BitBlt(hdc, 0, lv->header_rc.bottom, lv->rc.right, lv->rc.bottom - lv->header_rc.bottom, lv->hDC, 0, lv->header_rc.bottom, SRCCOPY);
			else
				BitBlt(hdc, 0, 0, lv->rc.right, lv->rc.bottom, lv->hDC, 0, 0, SRCCOPY);

			EndPaint(hwnd, &ps);
			return 0;
		}
	case WM_NCDESTROY:
		{
			LRESULT ret = ( lv->fIsListView ? lv->pfnWndProc(hwnd, uMsg, wParam, lParam) : pwndProc(hwnd, uMsg, wParam, lParam) );
			UninitializeListViewInstance(hwnd);
			return ret;
		}
	}

	if ( lv->fIsListView && lv->pfnWndProc )
		return lv->pfnWndProc(hwnd, uMsg, wParam, lParam);
	else if ( !lv->fIsListView && pwndProc )
		return pwndProc(hwnd, uMsg, wParam, lParam);

	return DefWindowProc(hwnd, uMsg, wParam, lParam);
}