示例#1
0
LRESULT __stdcall COverlappedWindow::windowProc( HWND _handle, UINT message, WPARAM wParam, LPARAM lParam ) {
		RECT clientRect;
		COverlappedWindow* ptr;
		ptr = reinterpret_cast<COverlappedWindow*>( ::GetWindowLong( _handle, GWL_USERDATA ) );
		switch ( message ) {
			case WM_NCCREATE:
				{
					COverlappedWindow* that = reinterpret_cast<COverlappedWindow*>( reinterpret_cast<LPCREATESTRUCT>( lParam )->lpCreateParams );
					::SetWindowLong(_handle, GWL_USERDATA, reinterpret_cast<LONG>( that ) );
					::DefWindowProc( _handle, message, wParam, lParam );
					::SetTimer( _handle, TIMER_ID, 0.01, NULL );
					break;
				}
			case WM_TIMER:
				ptr->OnTimer();
				break;

			case WM_DESTROY:
				ptr->OnDestroy();
				break;

			case WM_PAINT:
				ptr->OnPaint();
				break;

			default:
				return ::DefWindowProc( _handle, message, wParam, lParam );
		}
		return ::DefWindowProc( _handle, message, wParam, lParam );
}
LRESULT COverlappedWindow::windowProc(HWND handle, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message) {
    case WM_NCCREATE:
    {
        COverlappedWindow* window = reinterpret_cast<COverlappedWindow*>((reinterpret_cast<CREATESTRUCT*>(lParam))->lpCreateParams);
        SetLastError(0);
        SetWindowLongPtr(handle, GWLP_USERDATA, (LONG)window);
        if( GetLastError() != 0 ) {
            return GetLastError();
        }
        window->OnNCCreate(handle);
        return DefWindowProc(handle, message, wParam, lParam);
    }
    case WM_CREATE:
    {
        COverlappedWindow* window = reinterpret_cast<COverlappedWindow*>(GetWindowLongPtr(handle, GWLP_USERDATA));
        window->OnCreate();
        return DefWindowProc(handle, message, wParam, lParam);
    }
    case WM_DESTROY:
    {
        COverlappedWindow* window = reinterpret_cast<COverlappedWindow*>(GetWindowLongPtr(handle, GWLP_USERDATA));
        window->OnDestroy();
        return 0;
    }
    case WM_SIZE:
    {
        COverlappedWindow* window = reinterpret_cast<COverlappedWindow*>(GetWindowLongPtr(handle, GWLP_USERDATA));
        window->OnResize();
        return 0;
    }
    case WM_CLOSE:
    {
        COverlappedWindow* window = reinterpret_cast<COverlappedWindow*>(GetWindowLongPtr(handle, GWLP_USERDATA));
        window->OnClose();
        return 0;
    }
    case WM_COMMAND:
    {
        COverlappedWindow* window = reinterpret_cast<COverlappedWindow*>(GetWindowLongPtr(handle, GWLP_USERDATA));
        if( HIWORD(wParam) == EN_CHANGE ) {
            window->OnChange();
            return 0;
        } else {
            return DefWindowProc(handle, message, wParam, lParam);
        }
    }
    default:
        return DefWindowProc(handle, message, wParam, lParam);
    }
}
示例#3
0
LRESULT __stdcall COverlappedWindow::windowProc( HWND handle, UINT message, WPARAM wParam, LPARAM lParam ) {
	COverlappedWindow* ptr = reinterpret_cast<COverlappedWindow*>( ::GetWindowLong( handle, GWL_USERDATA ) );
	
	switch ( message ) {
		
		case WM_NCCREATE:
			{
				COverlappedWindow* that = reinterpret_cast<COverlappedWindow*>( reinterpret_cast<LPCREATESTRUCT>( lParam )->lpCreateParams );
				::SetWindowLong( handle, GWL_USERDATA, reinterpret_cast<LONG>( that ) );
				//that->handle = handle;
				return ::DefWindowProc( handle, message, wParam, lParam );
			}

		case WM_DESTROY:
			ptr->OnDestroy();
			break;

		default:
			return ::DefWindowProc( handle, message, wParam, lParam );
	}
}
LRESULT __stdcall COverlappedWindow::windowProc(HWND handle, UINT message, WPARAM wParam, LPARAM lParam)
{
	if (message == WM_ERASEBKGND) {
		return true;
	}

	if (message == WM_NCCREATE) {
		COverlappedWindow* window = reinterpret_cast<COverlappedWindow*>(reinterpret_cast<CREATESTRUCT*>(lParam)->lpCreateParams);
		::SetWindowLongPtr(handle, GWLP_USERDATA, reinterpret_cast<LONG>(window));
	}
	else {
		COverlappedWindow* window = reinterpret_cast<COverlappedWindow*>(::GetWindowLongPtr(handle, GWLP_USERDATA));
		switch (message) {
		case WM_CREATE:
			window->OnCreate(handle);
			break;
		case WM_PAINT:
			window->OnPaint();
			break;
		case WM_COMMAND:
			window->OnCommand(wParam, lParam);
			break;
		case WM_LBUTTONDOWN:
			window->OnLButtonDown(wParam, lParam);
			break;
		case WM_CLOSE:
			if (!window->OnClose()) {
				return 0;
			}
			break;
		case WM_DESTROY:
			window->OnDestroy();
			break;
		default:
			break;
		}
	}

	return DefWindowProc(handle, message, wParam, lParam);
}
// Оконная процедура. Обработка сообщений, приходящих в окно.
LRESULT COverlappedWindow::windowProc(HWND handle, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message) {
    case WM_NCCREATE:
    {
        COverlappedWindow* window = (COverlappedWindow*)((CREATESTRUCT*)lParam)->lpCreateParams;
        SetLastError(0);
        SetWindowLongPtr(handle, GWLP_USERDATA, (LONG)window);
        if( GetLastError() != 0 ) {
            return GetLastError();
        }
        window->OnNCCreate(handle);
        return DefWindowProc(handle, message, wParam, lParam);
    }
    case WM_CREATE:
    {
        COverlappedWindow* window = (COverlappedWindow*)GetWindowLongPtr(handle, GWLP_USERDATA);
        window->OnCreate();
        return DefWindowProc(handle, message, wParam, lParam);
    }
    case WM_SIZE:
    {
        COverlappedWindow* window = (COverlappedWindow*)GetWindowLongPtr(handle, GWLP_USERDATA);
        window->OnSize();
        return DefWindowProc(handle, message, wParam, lParam);
    }
    case WM_DESTROY:
    {
        COverlappedWindow* window = (COverlappedWindow*)GetWindowLongPtr(handle, GWLP_USERDATA);
        window->OnDestroy();
        return 0;
    }
    default:
        return DefWindowProc(handle, message, wParam, lParam);
    }
}
LRESULT COverlappedWindow::windowProc(HWND handle, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch( message ) {
		case WM_NCCREATE:
		{
			CREATESTRUCT* pCreate = reinterpret_cast<CREATESTRUCT*>(lParam);
			COverlappedWindow* windowPtr = reinterpret_cast<COverlappedWindow*>(pCreate->lpCreateParams);
			SetWindowLongPtr(handle, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(windowPtr));
			windowPtr->OnNCCreate(handle);
			return true;
		}
		case WM_CREATE:
		{
			COverlappedWindow* windowPtr = reinterpret_cast<COverlappedWindow*>(GetWindowLongPtr(handle, GWLP_USERDATA));
			windowPtr->OnCreate();
			break;
		}
		case WM_SIZE:
		{
			COverlappedWindow* windowPtr = reinterpret_cast<COverlappedWindow*>(GetWindowLongPtr(handle, GWLP_USERDATA));
			windowPtr->OnSize();
			break;
		}
		case WM_CTLCOLOREDIT:
		{
			COverlappedWindow* windowPtr = reinterpret_cast<COverlappedWindow*>(GetWindowLongPtr(handle, GWLP_USERDATA));
			HDC hdc = reinterpret_cast<HDC>(wParam);
			return windowPtr->OnControlColorEdit(hdc);
		}
		case WM_COMMAND:
		{
			if( HIWORD(wParam) == EN_CHANGE ) {
				COverlappedWindow* windowPtr = reinterpret_cast<COverlappedWindow*>(GetWindowLongPtr(handle, GWLP_USERDATA));
				windowPtr->OnTextChange();
				break;
			}
			switch( LOWORD(wParam) ) {
				case ID_FILE_SAVE:
				{
					COverlappedWindow* windowPtr = reinterpret_cast<COverlappedWindow*>(GetWindowLongPtr(handle, GWLP_USERDATA));
					windowPtr->saveFile();
					break;
				}
				case ID_FILE_EXIT:
				{
					COverlappedWindow* windowPtr = reinterpret_cast<COverlappedWindow*>(GetWindowLongPtr(handle, GWLP_USERDATA));
					windowPtr->OnClose();
					break;
				}
				case ID_VIEW_SETTINGS:
				{
					COverlappedWindow* windowPtr = reinterpret_cast<COverlappedWindow*>(GetWindowLongPtr(handle, GWLP_USERDATA));
					windowPtr->showSettings();
					break;
				}
				case ID_KILL:
				{
					COverlappedWindow* windowPtr = reinterpret_cast<COverlappedWindow*>(GetWindowLongPtr(handle, GWLP_USERDATA));
					windowPtr->OnDestroy();
					break;
				}
			}
			break;
		}
		case WM_CLOSE:
		{
			COverlappedWindow* windowPtr = reinterpret_cast<COverlappedWindow*>(GetWindowLongPtr(handle, GWLP_USERDATA));
			windowPtr->OnClose();
			break;
		}
		case WM_DESTROY:
		{
			COverlappedWindow* windowPtr = reinterpret_cast<COverlappedWindow*>(GetWindowLongPtr(handle, GWLP_USERDATA));
			windowPtr->OnDestroy();
			break;
		}
		default:
			return DefWindowProc(handle, message, wParam, lParam);
	}
	return false;
}