예제 #1
0
bool DesktopWindow::onMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
  switch (message) {
    case WM_HSCROLL:
      return onHScroll(wParam, lParam);
    case WM_VSCROLL:
      return onVScroll(wParam, lParam);
    case WM_ERASEBKGND:
      return onEraseBackground(reinterpret_cast<HDC>(wParam));
    case WM_DEADCHAR:
    case WM_SYSDEADCHAR:
      return onDeadChar(wParam, lParam);
    case WM_DRAWCLIPBOARD:
      return onDrawClipboard();
    case WM_CREATE:
      return onCreate(reinterpret_cast<LPCREATESTRUCT>(lParam));
    case WM_SIZE:
      return onSize(wParam, lParam);
    case WM_DESTROY:
      return onDestroy();
    case WM_CHAR:
    case WM_SYSCHAR:
      return onChar(wParam, lParam);
    case WM_KEYDOWN:
    case WM_KEYUP:
    case WM_SYSKEYDOWN:
    case WM_SYSKEYUP:
      return onKey(wParam, lParam);
    case WM_SETFOCUS:
      m_rfbKeySym->processFocusRestoration();
      return true;
    case WM_KILLFOCUS:
      m_rfbKeySym->processFocusLoss();
      return true;
  }
  return false;
}
예제 #2
0
BOOL CALLBACK SizeableDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
	case WM_INITDIALOG :
		return onInitDialog();

	case WM_GETMINMAXINFO :
		onGetMinMaxInfo((MINMAXINFO*)lParam);
		return TRUE;

	case WM_SIZE:
		onSize(wParam, LOWORD(lParam), HIWORD(lParam));
		return TRUE;

	default:
		if (message == WM_WINMGR)
		{
			return (BOOL)onWinMgr(wParam, lParam);
		}
		break;
	}
	return FALSE;
}
예제 #3
0
//----------------------------------------------
//    Process function of dialog
//
BOOL CALLBACK DockingCont::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam)
{
	switch (Message) 
	{
		case WM_NCACTIVATE:
		{
			// Note: lParam to identify the trigger window
			if ((int)lParam != -1)
			{
				::SendMessage(_hParent, WM_NCACTIVATE, wParam, 0);
			}
			break;
		}
		case WM_INITDIALOG:
		{
			_hContTab = ::GetDlgItem(_hSelf, IDC_TAB_CONT);
			_hCaption = ::GetDlgItem(_hSelf, IDC_BTN_CAPTION);

			// intial subclassing of caption
			::SetWindowLongPtr(_hCaption, GWLP_USERDATA, (LONG_PTR)this);
			_hDefaultCaptionProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hCaption, GWLP_WNDPROC, (LONG_PTR)wndCaptionProc));

			// intial subclassing of tab
			::SetWindowLongPtr(_hContTab, GWLP_USERDATA, (LONG_PTR)this);
			_hDefaultTabProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hContTab, GWLP_WNDPROC, (LONG_PTR)wndTabProc));

			// set min tab width
			::SendMessage(_hContTab, TCM_SETMINTABWIDTH, 0, (LPARAM)MIN_TABWIDTH);
			break;
		}
		case WM_NCCALCSIZE:
		case WM_SIZE:
		{
			onSize();
			break;
		}
		case WM_DRAWITEM :
		{
			// draw tab or caption
			if (((DRAWITEMSTRUCT *)lParam)->CtlID == IDC_TAB_CONT)
			{
				drawTabItem((DRAWITEMSTRUCT *)lParam);
				return TRUE;
			}
			else
			{
				drawCaptionItem((DRAWITEMSTRUCT *)lParam);
				return TRUE;
			}
			break;
		}
		case WM_NCLBUTTONDBLCLK :
		{
			RECT	rcWnd		= {0};
			RECT	rcClient	= {0};
			POINT	pt			= {HIWORD(lParam), LOWORD(lParam)};

			getWindowRect(rcWnd);
			getClientRect(rcClient);
			ClientRectToScreenRect(_hSelf, &rcClient);
			rcWnd.bottom = rcClient.top;

			// if in caption
			if ((rcWnd.top  < pt.x) && (rcWnd.bottom > pt.x) &&
				(rcWnd.left < pt.y) && (rcWnd.right  > pt.y))
			{
				NotifyParent(DMM_DOCKALL);
				return TRUE;
			}
			break;
		}
		case WM_SYSCOMMAND :
		{
			switch (wParam & 0xfff0)
			{
				case SC_MOVE:
					NotifyParent(DMM_MOVE);
					return TRUE;
				default: 
					break;
			}
			return FALSE;
		}
		case WM_COMMAND : 
		{
			switch (LOWORD(wParam))
			{   
				case IDCANCEL:
					doClose();
					return TRUE;
				default :
					break;
			}
			break;
		}
		default:
			break;
	}

	return FALSE;
}
예제 #4
0
void DockingCont::SelectTab(int iTab)
{
	if (iTab != -1)
	{
		const TCHAR	*pszMaxTxt	= NULL;
		TCITEM	tcItem		= {0};
		SIZE	size		= {0};
		int		maxWidth	= 0;
		int		iItemCnt	= ::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0);

		// get data of new active dialog
		tcItem.mask		= TCIF_PARAM;
		::SendMessage(_hContTab, TCM_GETITEM, iTab, (LPARAM)&tcItem);
		// show active dialog
		if (!tcItem.lParam)
			return;

		::ShowWindow(((tTbData*)tcItem.lParam)->hClient, SW_SHOW);
		::SetFocus(((tTbData*)tcItem.lParam)->hClient);

		// Notify switch in
		NMHDR nmhdr;
		nmhdr.code		= DMN_SWITCHIN;
		nmhdr.hwndFrom	= _hSelf;
		nmhdr.idFrom	= 0;
		::SendMessage(((tTbData*)tcItem.lParam)->hClient, WM_NOTIFY, nmhdr.idFrom, (LPARAM)&nmhdr);

		if ((unsigned int)iTab != _prevItem)
		{
			// hide previous dialog
			::SendMessage(_hContTab, TCM_GETITEM, _prevItem, (LPARAM)&tcItem);

			if (!tcItem.lParam)
				return;
			::ShowWindow(((tTbData*)tcItem.lParam)->hClient, SW_HIDE);
		
			// Notify switch off
			NMHDR nmhdr;
			nmhdr.code		= DMN_SWITCHOFF;
			nmhdr.hwndFrom	= _hSelf;
			nmhdr.idFrom	= 0;
			::SendMessage(((tTbData*)tcItem.lParam)->hClient, WM_NOTIFY, nmhdr.idFrom, (LPARAM)&nmhdr);
		}

		// resize tab item

		// get at first largest item ...
		HDC		hDc	= ::GetDC(_hContTab);
		SelectObject(hDc, _hFont);

		for (int iItem = 0; iItem < iItemCnt; ++iItem)
		{
			const TCHAR *pszTabTxt = NULL;

			::SendMessage(_hContTab, TCM_GETITEM, iItem, (LPARAM)&tcItem);
			if (!tcItem.lParam)
				continue;
			pszTabTxt = ((tTbData*)tcItem.lParam)->pszName;

			// get current font width
			GetTextExtentPoint32(hDc, pszTabTxt, lstrlen(pszTabTxt), &size);

			if (maxWidth < size.cx) 
			{
				maxWidth	= size.cx;
				pszMaxTxt	= pszTabTxt;
			}
		}
		::ReleaseDC(_hSelf, hDc);

		tcItem.mask	= TCIF_TEXT;

		for (int iItem = 0; iItem < iItemCnt; ++iItem)
		{
			generic_string szText(TEXT(""));
			if (iItem == iTab && pszMaxTxt)
			{
				// fake here an icon before text ...
				szText = TEXT("    ");
				szText += pszMaxTxt;
			}
			tcItem.pszText = (TCHAR *)szText.c_str();
			::SendMessage(_hContTab, TCM_SETITEM, iItem, (LPARAM)&tcItem);
		}

		// selects the pressed tab and store previous tab
		::SendMessage(_hContTab, TCM_SETCURSEL, iTab, 0);
		_prevItem = iTab;

		// update caption text
		updateCaption();

		onSize();
	}
}
예제 #5
0
LRESULT DockingManager::runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
		case WM_NCACTIVATE:
		{
			// activate/deactivate titlebar of toolbars
			for (size_t iCont = DOCKCONT_MAX, len = _vContainer.size(); iCont < len; ++iCont)
			{
				::SendMessage(_vContainer[iCont]->getHSelf(), WM_NCACTIVATE, wParam, (LPARAM)-1);
			}

			if ((int)lParam != -1)
			{
				::SendMessage(_hParent, WM_NCACTIVATE, wParam, (LPARAM)-1);
			}
			break;
		}
		case WM_MOVE:
		case WM_SIZE:
		{
			onSize();
			break;
		}
		case WM_DESTROY:
		{
			// unregister window event hooking BEFORE EVERYTHING ELSE
			if (hWndServer == hwnd) {
				UnhookWindowsHookEx(gWinCallHook);
				gWinCallHook = NULL;
				hWndServer = NULL;
			}

			// destroy imagelist if it exists
			if (_hImageList != NULL)
			{
				::ImageList_Destroy(_hImageList);
			}

			// destroy containers
			for (int i = _vContainer.size(); i > 0; i--)
			{
				_vContainer[i-1]->destroy();
				delete _vContainer[i-1];
			}
			CoUninitialize();
			break;
		}
		case DMM_LBUTTONUP:	//is this message still relevant?
		{
			if (::GetActiveWindow() != _hParent)
				break;

			// set respective activate state
			for (int i = 0; i < DOCKCONT_MAX; ++i)
			{
				_vContainer[i]->SetActive(IsChild(_vContainer[i]->getHSelf(), ::GetFocus()));
			}
			return TRUE;
		}

		case DMM_MOVE:
		{
			Gripper *pGripper = new Gripper;
			pGripper->init(_hInst, _hParent);
			pGripper->startGrip((DockingCont*)lParam, this);
			break;
		}

		case DMM_MOVE_SPLITTER:
		{
			int offset = wParam;

			for (int iCont = 0; iCont < DOCKCONT_MAX; ++iCont)
			{
				if (_vSplitter[iCont]->getHSelf() == (HWND)lParam)
				{
					switch (iCont)
					{
						case CONT_TOP:
							_dockData.rcRegion[iCont].bottom -= offset;
							if (_dockData.rcRegion[iCont].bottom < 0)
							{
								_dockData.rcRegion[iCont].bottom = 0;
							}
							if ((_rcWork.bottom < (-SPLITTER_WIDTH)) && (offset < 0))
							{
								_dockData.rcRegion[iCont].bottom += offset;
							}
							break;
						case CONT_BOTTOM:
							_dockData.rcRegion[iCont].bottom   += offset;
							if (_dockData.rcRegion[iCont].bottom < 0)
							{
								_dockData.rcRegion[iCont].bottom   = 0;
							}
							if ((_rcWork.bottom < (-SPLITTER_WIDTH)) && (offset > 0))
							{
								_dockData.rcRegion[iCont].bottom -= offset;
							}
							break;
						case CONT_LEFT:
							_dockData.rcRegion[iCont].right    -= offset;
							if (_dockData.rcRegion[iCont].right < 0)
							{
								_dockData.rcRegion[iCont].right = 0;
							}
							if ((_rcWork.right < SPLITTER_WIDTH) && (offset < 0))
							{
								_dockData.rcRegion[iCont].right += offset;
							}
							break;
						case CONT_RIGHT:
							_dockData.rcRegion[iCont].right    += offset;
							if (_dockData.rcRegion[iCont].right < 0)
							{
								_dockData.rcRegion[iCont].right = 0;
							}
							if ((_rcWork.right < SPLITTER_WIDTH) && (offset > 0))
							{
								_dockData.rcRegion[iCont].right -= offset;
							}
							break;
					}
					onSize();
					break;
				}
			}
			break;
		}
		case DMM_DOCK:
		case DMM_FLOAT:
		{
			toggleActiveTb((DockingCont*)lParam, message);
			return FALSE;
		}
		case DMM_CLOSE:
		{
			tTbData	TbData	= *((DockingCont*)lParam)->getDataOfActiveTb();
			return SendNotify(TbData.hClient, DMN_CLOSE);
		}
		case DMM_FLOATALL:
		{
			toggleVisTb((DockingCont*)lParam, DMM_FLOAT);
			return FALSE;
		}
		case DMM_DOCKALL:
		{
			toggleVisTb((DockingCont*)lParam, DMM_DOCK);
			return FALSE;
		}
		case DMM_GETIMAGELIST:
		{
			return (LPARAM)_hImageList;
		}
		case DMM_GETICONPOS:
		{
			for (UINT uImageCnt = 0, len = _vImageList.size(); uImageCnt < len; ++uImageCnt)
			{
				if ((HWND)lParam == _vImageList[uImageCnt])
				{
					return uImageCnt;
				}
			}
			return -1;
		}
		default :
			break;
	}

	return ::DefWindowProc(_hSelf, message, wParam, lParam);
}
예제 #6
0
void DockingCont::SelectTab(INT iTab)
{
	if (iTab != -1)
	{
		LPSTR	pszMaxTxt	= NULL;
		TCITEM	tcItem		= {0};
		SIZE	size		= {0};
		INT		maxWidth	= 0;
		INT		iItemCnt	= ::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0);

		/* get data of new active dialog */
		tcItem.mask		= TCIF_PARAM;
		::SendMessage(_hContTab, TCM_GETITEM, iTab, (LPARAM)&tcItem);

		/* show active dialog */
		::ShowWindow(((tTbData*)tcItem.lParam)->hClient, SW_SHOW);
		::SetFocus(((tTbData*)tcItem.lParam)->hClient);

		if (iTab != _prevItem)
		{
			/* hide previous dialog */
			::SendMessage(_hContTab, TCM_GETITEM, _prevItem, (LPARAM)&tcItem);
			::ShowWindow(((tTbData*)tcItem.lParam)->hClient, SW_HIDE);
		}

		/* resize tab item */

		/* get at first largest item ... */
		HDC		hDc	= ::GetDC(_hContTab);
		SelectObject(hDc, _hFont);

		for (INT iItem = 0; iItem < iItemCnt; iItem++)
		{
			LPSTR	pszTabTxt	= NULL;

			::SendMessage(_hContTab, TCM_GETITEM, iItem, (LPARAM)&tcItem);
			pszTabTxt = ((tTbData*)tcItem.lParam)->pszName;

			/* get current font width */
			GetTextExtentPoint32(hDc, pszTabTxt, strlen(pszTabTxt), &size);

			if (maxWidth < size.cx) 
			{
				maxWidth	= size.cx;
				pszMaxTxt	= pszTabTxt;
			}
		}
		::ReleaseDC(_hSelf, hDc);

		tcItem.mask	= TCIF_TEXT;
		for (INT iItem = 0; iItem < iItemCnt; iItem++)
		{
			if (iItem == iTab)
			{
				/* fake here an icon before text ... */
				char	szText[64];

				strcpy(szText, "    ");
				strcat(szText, pszMaxTxt);
				tcItem.pszText		= szText;
				tcItem.cchTextMax	= strlen(szText);
			}
			else
			{
				/* ... and resize old and new item */
				tcItem.pszText		= "";
				tcItem.cchTextMax	= strlen("");
			}
			::SendMessage(_hContTab, TCM_SETITEM, iItem, (LPARAM)&tcItem);
		}

		/* selects the pressed tab and store previous tab */
		::SendMessage(_hContTab, TCM_SETCURSEL, iTab, 0);
		_prevItem = iTab;

		/* update caption text */
		updateCaption();

		onSize();
	}
}
예제 #7
0
파일: Window.cpp 프로젝트: yuen33/Neutron
		LRESULT Window::msgproc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
		{
			switch( msg )
			{
				case WM_ACTIVATE:
				{
					boolean newActive = LOWORD( wParam ) == WA_ACTIVE;
					if( active != newActive )
					{
						onActive( newActive );
						active = newActive;
					}
				}
				break;
				
				case WM_ERASEBKGND:
				{
				}
				break;

				case WM_PAINT:
				{
					onPaint();
				}
				break;

				case WM_ENTERSIZEMOVE:
				{
					updateFlag = false;
					onEnterSizeMove();
				}
				break;

				case WM_SIZE:
				{
					boolean newActive = ( wParam != SIZE_MAXHIDE ) && ( wParam != SIZE_MINIMIZED );
					if( active != newActive )
					{
						onActive( newActive );
						active = newActive;
					}

					onSize();
				}
				break;

				case WM_EXITSIZEMOVE:
				{
					onExitSizeMove();
					updateFlag = true;
				}
				break;

				case WM_SETCURSOR:
				{
					onSetCursor();
				}
				break;

				case WM_CHAR:
				{
					onChar( static_cast<wchar>( wParam ) );
				}
				break;

				case WM_INPUT:
				{
					onRawInput( reinterpret_cast<HRAWINPUT>( lParam ) );
				}
				break;

				case WM_CLOSE:
				{
					onClose();
				}
				break;
				
				case WM_DESTROY:
				{
					onDestroy();
				}
				break;

				default:
				{
				}
			}

			return DefWindowProcA( hWnd, msg, wParam, lParam );
		}
예제 #8
0
bool ViewerWindow::onMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message) {
	case WM_SIZING:
		m_sizeIsChanged = true;
		return false;
	case WM_NCDESTROY:
		m_stopped = true;
		return true;
	case WM_USER_STOP:
		SendMessage(m_hWnd, WM_DESTROY, 0, 0);
		return true;
	case WM_USER_FS_WARNING:
		return onFsWarning();
	case WM_CLOSE:
		return onClose();
	case WM_DESTROY:
		return onDestroy();
	case WM_CREATE:
		return onCreate((LPCREATESTRUCT)lParam);
	case WM_SIZE:
		return onSize(wParam, lParam);
	case WM_USER_AUTH_ERROR:
		return onAuthError(wParam);
	case WM_USER_ERROR:
		return onError();
	case WM_USER_DISCONNECT:
		return onDisconnect();
	case WM_ACTIVATE:
		if ((LOWORD(wParam) == WA_ACTIVE || LOWORD(wParam) == WA_CLICKACTIVE) && m_isFullScr) {
			try {
				// Registration of keyboard hook.
				m_winHooks.registerKeyboardHook(this);
				// Switching off ignoring win key.
				m_dsktWnd.setWinKeyIgnore(false);
			}
			catch (Exception &e) {
				m_logWriter.error(_T("%s"), e.getMessage());
			}
		}
		else if (LOWORD(wParam) == WA_INACTIVE && m_isFullScr) {
			// Unregistration of keyboard hook.
			m_winHooks.unregisterKeyboardHook(this);
			// Switching on ignoring win key.
			m_dsktWnd.setWinKeyIgnore(true);
		}
		return true;
	case WM_SETFOCUS:
		return onFocus(wParam);
	case WM_ERASEBKGND:
		return onEraseBackground((HDC)wParam);
	case WM_KILLFOCUS:
		return onKillFocus(wParam);
	case WM_TIMER:
		return onTimer(wParam);
	case WM_DISPLAYCHANGE:
		adjustWindowSize();

	}
	return false;
}
예제 #9
0
pxError pxWindow::init(int left, int top, int width, int height)
{
	Rect r;
	r.top = top; r.left = left; r.bottom = top+height; r.right = left+width; 
	
	CreateNewWindow(kDocumentWindowClass,  
		kWindowCloseBoxAttribute | kWindowResizableAttribute | kWindowLiveResizeAttribute | 
		kWindowResizeTransitionAction | kWindowCollapseBoxAttribute | kWindowStandardHandlerAttribute,
		&r, &mWindowRef);

	if (mWindowRef)
	{
		EventTypeSpec		eventType;
		EventHandlerUPP		handlerUPP;
		EventHandlerRef handler;
			
		eventType.eventClass = kEventClassKeyboard;
		eventType.eventKind = kEventRawKeyDown;
		handlerUPP = NewEventHandlerUPP(doKeyDown);
		InstallApplicationEventHandler (handlerUPP, 1, &eventType, this, nil);

		eventType.eventKind = kEventRawKeyUp;
		handlerUPP = NewEventHandlerUPP(doKeyUp);
		InstallApplicationEventHandler (handlerUPP, 1, &eventType, this, nil);

		eventType.eventKind = kEventRawKeyRepeat;
		handlerUPP = NewEventHandlerUPP(doKeyDown);		// 'key repeat' is translated to 'key down'
		InstallApplicationEventHandler (handlerUPP, 1, &eventType, this, nil);	
		
		eventType.eventKind = kEventRawKeyModifiersChanged;
		handlerUPP = NewEventHandlerUPP(doKeyModifierChanged);
		InstallWindowEventHandler (mWindowRef, handlerUPP, 1, &eventType, this, &handler);	
		
		eventType.eventKind = kEventWindowDrawContent;
		eventType.eventClass = kEventClassWindow;
		handlerUPP = NewEventHandlerUPP(doWindowDrawContent);
		InstallWindowEventHandler (mWindowRef, handlerUPP, 1, &eventType, this, &handler);
		
		eventType.eventKind = kEventWindowBoundsChanging;
		eventType.eventClass = kEventClassWindow;

		handlerUPP = NewEventHandlerUPP(doWindowResizeComplete);
		InstallWindowEventHandler (mWindowRef, handlerUPP, 1, &eventType, this, &handler);
		
		eventType.eventKind = kEventWindowBoundsChanged;
		eventType.eventClass = kEventClassWindow;

		handlerUPP = NewEventHandlerUPP(doWindowResizeComplete);
		InstallWindowEventHandler (mWindowRef, handlerUPP, 1, &eventType, this, &handler);

		eventType.eventKind = kEventWindowClose;
		handlerUPP = NewEventHandlerUPP(doWindowCloseRequest);
		InstallWindowEventHandler (mWindowRef, handlerUPP, 1, &eventType, this, &handler);

		eventType.eventKind = kEventWindowClosed;
		eventType.eventClass = kEventClassWindow;

		handlerUPP = NewEventHandlerUPP(doWindowClosed);
		InstallWindowEventHandler (mWindowRef, handlerUPP, 1, &eventType, this, &handler);
		
		eventType.eventKind = kEventMouseDown;
		eventType.eventClass = kEventClassMouse;

		handlerUPP = NewEventHandlerUPP(doMouseDown);
		InstallWindowEventHandler (mWindowRef, handlerUPP, 1, &eventType, this, &handler);	
		
		eventType.eventKind = kEventMouseUp;
		eventType.eventClass = kEventClassMouse;

		handlerUPP = NewEventHandlerUPP(doMouseUp);
		InstallWindowEventHandler (mWindowRef, handlerUPP, 1, &eventType, this, &handler);	
		
		eventType.eventKind = kEventMouseMoved;
		eventType.eventClass = kEventClassMouse;

		handlerUPP = NewEventHandlerUPP(doMouseMove);
		InstallWindowEventHandler (mWindowRef, handlerUPP, 1, &eventType, this, &handler);	
		
		eventType.eventKind = kEventMouseDragged;
		eventType.eventClass = kEventClassMouse;

		handlerUPP = NewEventHandlerUPP(doMouseMove);
		InstallApplicationEventHandler (handlerUPP, 1, &eventType, this, nil);	
	
		{
			Rect r;
			GetWindowBounds(mWindowRef,kWindowContentRgn ,&r);
			onSize(r.right-r.left, r.bottom-r.top);
		}

		onCreate();
	}
	
	return mWindowRef?PX_OK:PX_FAIL;
}