Ejemplo n.º 1
0
bool
TabMenuDisplay::OnMouseUp(PixelScalar x, PixelScalar y)
{
  RasterPoint Pos;
  Pos.x = x;
  Pos.y = y;

  if (dragging) {
    DragEnd();

    const MenuTabIndex di = IsPointOverButton(Pos, GetPageMainIndex(cursor));

    if (di == down_index) {

      // sub menu click
      if (di.IsSub())
        pager.ClickPage(PAGE_OFFSET + GetPageNum(di));

      // main menu click
      else if (di.IsMain()) {
        /* move cursor to first item in this menu */
        cursor = main_menu_buttons[di.main_index].first_page_index;
        Invalidate();
      } else {
        InvalidateButton(down_index);
      }
    }

    down_index = MenuTabIndex::None();

    return true;
  } else {
    return PaintWindow::OnMouseUp(x, y);
  }
}
void ModuleWorldPage::OnLButtonUp(UINT nFlags, CPoint point) 
{
	// TODO: この位置にメッセージ ハンドラ用のコードを追加するかまたはデフォルトの処理を呼び出してください
	ClientToScreen(&point);
	DragEnd(point.x, point.y);
	ScreenToClient(&point);

	CPropertyPage::OnLButtonUp(nFlags, point);
}
void CEditTreeCtrl::OnRButtonUp(UINT nFlags, CPoint point) 
{
	if(m_pDragData) {
		if(m_pDragData->IsRightDragging())
			DragEnd();
		else
			// Right-click during a left-click-drag breaks the drag operation
			DragStop();
	} else
		CTreeCtrl::OnRButtonUp(nFlags, point);
}
Ejemplo n.º 4
0
void CTreeViewEx::OnLButtonUp(UINT nFlags, CPoint point)
{
    if(m_bDragging == TRUE)
    {
        CTreeCtrl &omTreeCtrl = GetTreeCtrl();
        m_bDragging = FALSE;
        DragEnd();
        omTreeCtrl.SelectDropTarget(0);
        SetCursor(m_hOrigCursor);
        GetTreeCtrl().SetInsertMark(0, 0);
        ::ReleaseCapture();
    }
	CTreeView::OnLButtonUp(nFlags, point);
}
Ejemplo n.º 5
0
LOCAL void ListBox_DoDrag(HWND hWindow, BOOL fDoubleClick, int x, int y, UINT keyFlags)
/***********************************************************************/
{
// Let the listbox control handle the mouse down so a selection can happen
FORWARD_WM_LBUTTONDOWN(hWindow, fDoubleClick, x, y, keyFlags, ListBox_CallWindowProc);

// see if it's cool for us to try to drag
LPLISTBOXDATA lpData = DragOK(hWindow);
if (!lpData)
	return;

// make the listbox think it got a mouse up so we can take over 
FORWARD_WM_LBUTTONUP(hWindow, x, y, keyFlags, ListBox_CallWindowProc);

// initialize the dragging
DragBegin(hWindow, x, y);

// dragging loop                      
while (lpData->fCapture)
	{  
	MSG msg;
	// Look for mouse, keyboard, and timer messages. 
	// keystroke messages are retrieved to avoid the message
	// queue from getting full
	while ( !PeekMessage(&msg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE) &&
			!PeekMessage(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE) &&
       		!PeekMessage(&msg, NULL, WM_TIMER, WM_TIMER, PM_REMOVE)) 
	   	WaitMessage();
	switch(msg.message)
 		{
    	case WM_MOUSEMOVE:
			HANDLE_WM_MOUSEMOVE(msg.hwnd, msg.wParam, msg.lParam, Drag_OnMouseMove);
		break;
		case WM_TIMER:
			HANDLE_WM_TIMER(msg.hwnd, msg.wParam, msg.lParam, Drag_OnTimer);
		break;
	 	case WM_LBUTTONUP: 
			HANDLE_WM_LBUTTONUP(msg.hwnd, msg.wParam, msg.lParam, Drag_OnLButtonUp);
		break;
	 	default:
    		// Process messages we don't handle
	   		TranslateMessage(&msg);
	   		DispatchMessage(&msg);
		break;      
		}
	}

// process the drag and cleanup
DragEnd(hWindow);
}
Ejemplo n.º 6
0
bool
TabMenuDisplay::OnMouseDown(PixelScalar x, PixelScalar y)
{
  DragEnd();
  RasterPoint Pos;
  Pos.x = x;
  Pos.y = y;

  // If possible -> Give focus to the Control
  SetFocus();

  down_index = IsPointOverButton(Pos, GetPageMainIndex(cursor));

  if (!down_index.IsNone()) {
    dragging = true;
    SetCapture();

    InvalidateButton(down_index);
    return true;
  }
  return PaintWindow::OnMouseDown(x, y);
}
void CEditTreeCtrl::OnLButtonUp(UINT nFlags, CPoint point) 
{
	if(m_pDragData)
		DragEnd();
	CTreeCtrl::OnLButtonUp(nFlags, point);
}
Ejemplo n.º 8
0
WINDOWPROC MainWndProc(
    HWND hwnd,
    UINT msg,
    WPARAM wParam,
    LONG lParam)
{
    switch (msg) {
        case WM_CREATE:
            {
                RECT rc;

                /*
                 * Create the status window.
                 */
                CreateDialog(ghInst, MAKEINTRESOURCE(DID_STATUS),
                        hwnd, StatusDlgProc);

                /*
                 * Save away its height for sizing later (like when
                 * the app is minimized then restored).
                 */
                GetWindowRect(hwndStatus, &rc);
                gcyStatus = rc.bottom - rc.top;

                ghwndSubClient = CreateWindow(szSubClientClass, NULL,
                        WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
                        hwnd, NULL, ghInst, NULL);

                ghMenuMain = GetMenu(hwnd);
                LoadMenuBitmaps(ghMenuMain);
            }

            break;

        case WM_ACTIVATE:
            /*
             * If the main window is getting activated, there is no
             * currently active dialog.
             */
            if (GET_WM_ACTIVATE_STATE(wParam, lParam))
                gidCurrentDlg = 0;

            goto DoDefault;

        case WM_INITMENU:
            if (GetMenu(ghwndMain) == (HMENU)wParam)
                InitMenu((HMENU)wParam);

            break;

        case WM_MENUSELECT:
            if (GET_WM_MENUSELECT_FLAGS(wParam, lParam) &
                    (MF_POPUP | MF_SYSMENU))
                gMenuSelected = 0;
            else
                gMenuSelected = GET_WM_MENUSELECT_CMD(wParam, lParam);

            break;

        case WM_COMMAND:
            DialogMenu(GET_WM_COMMAND_ID(wParam, lParam));
            break;

        case WM_KEYDOWN:
            switch (wParam) {
                case VK_UP:
                case VK_DOWN:
                case VK_LEFT:
                case VK_RIGHT:
                    if ((GetKeyState(VK_SHIFT) & 0x8000) ||
                            (GetKeyState(VK_CONTROL) & 0x8000))
                        break;

                    /*
                     * Ignore it if we are not in a normal state
                     * (don't allow when dragging).
                     */
                    if (gState != STATE_NORMAL)
                        break;

                    /*
                     * Be sure any outstanding changes get applied
                     * without errors.
                     */
                    if (!StatusApplyChanges())
                        break;

                    /*
                     * Move the control in the specified direction.
                     */
                    MoveControl(wParam);
                    break;

                case VK_TAB:
                    if (GetKeyState(VK_CONTROL) & 0x8000)
                        break;

                    /*
                     * Ignore it if we are not in a normal state
                     * (don't allow when dragging).
                     */
                    if (gState != STATE_NORMAL)
                        break;

                    /*
                     * Be sure any outstanding changes get applied
                     * without errors.
                     */
                    if (!StatusApplyChanges())
                        break;

                    /*
                     * Is the shift key pressed also?
                     */
                    if (GetKeyState(VK_SHIFT) & 0x8000)
                        SelectPrevious();
                    else
                        SelectNext();

                    break;

                case VK_ESCAPE:
                    if ((GetKeyState(VK_SHIFT) & 0x8000) ||
                            (GetKeyState(VK_CONTROL) & 0x8000))
                        break;

                    /*
                     * Be sure any outstanding changes get applied
                     * without errors.
                     */
                    if (!StatusApplyChanges())
                        break;

                    if (gState == STATE_SELECTING)
                        OutlineSelectCancel();

                    /*
                     * Cancel any drag operation they might have been doing.
                     */
                    if (gState != STATE_NORMAL)
                        DragCancel();

                    break;

                case VK_RETURN:
                    if ((GetKeyState(VK_SHIFT) & 0x8000) ||
                            (GetKeyState(VK_CONTROL) & 0x8000))
                        break;

                    /*
                     * Be sure any outstanding changes get applied
                     * without errors.
                     */
                    if (!StatusApplyChanges())
                        break;

                    switch (gState) {
                        MPOINT mpt;
                        POINT pt;
                        DWORD dwPos;

                        case STATE_SELECTING:
                            /*
                             * In outline selection mode.  Map the
                             * location of the mouse at the time that
                             * the user pressed Enter into a point
                             * relative to the dialog client and complete
                             * the selection operation.
                             */
                            dwPos = GetMessagePos();
                            mpt = MAKEMPOINT(dwPos);
                            MPOINT2POINT(mpt, pt);
                            ScreenToClient(gcd.npc->hwnd, &pt);
                            OutlineSelectEnd(pt.x, pt.y);

                            break;

                        case STATE_DRAGGING:
                        case STATE_DRAGGINGNEW:
                            /*
                             * We are dragging something.  Map the
                             * location of the mouse at the time
                             * that the user pressed Enter into a
                             * point relative to the proper window
                             * and complete the drag operation.
                             */
                            dwPos = GetMessagePos();
                            mpt = MAKEMPOINT(dwPos);
                            MPOINT2POINT(mpt, pt);

                            /*
                             * The point must be changed to be relative to
                             * the window that the ending mouse up message
                             * would have come through, which will be the
                             * capture window for the drag.  This will be
                             * the dialog if we are adding a new control,
                             * or it will be the selected control if we are
                             * dragging an existing control.
                             */
                            ScreenToClient((gState == STATE_DRAGGING) ?
                                    gnpcSel->hwnd : gcd.npc->hwnd, &pt);

                            /*
                             * If the dialog is selected, map the points from
                             * the client area to the window.
                             */
                            if (gfDlgSelected)
                                MapDlgClientPoint(&pt, TRUE);

                            DragEnd(pt.x, pt.y);

                            break;
                    }

                    break;
            }

            break;

        case WM_NCCALCSIZE:
            /*
             * Save away what is going to be the new window position.
             */
            if (!IsIconic(hwnd) && !IsZoomed(hwnd))
                grcAppPos = *((LPRECT)lParam);

            /*
             * Now let the DefWindowProc calculate the client area normally.
             */
            goto DoDefault;

        case WM_MOVE:
            if (gfEditingDlg)
                RepositionDialog();

            break;

        case WM_SIZE:
            SizeRibbons(hwnd);

            /*
             * Did the app start minimized and is it being restored
             * for the first time?  If so, show the toolbox if
             * the user has requested it.
             */
            if (fStartAsIcon && !IsIconic(hwnd)) {
                if (gfShowToolbox)
                    ToolboxShow(TRUE);

                fStartAsIcon = FALSE;
            }

            break;

        case WM_SYSCOLORCHANGE:
            LoadSysColorBitmaps();
            break;

        case WM_CLOSE:
            if (ghwndTestDlg)
                DestroyTestDialog();

            if (DoWeSave(FILE_INCLUDE) == IDCANCEL ||
                    DoWeSave(FILE_RESOURCE) == IDCANCEL)
                break;

            /*
             * First destroy the Properties Bar.
             */
            DestroyWindow(hwndStatus);
            hwndStatus = NULL;

            DestroyWindow(hwnd);
            break;

        case WM_QUERYENDSESSION:
            if (ghwndTestDlg)
                DestroyTestDialog();

            if (DoWeSave(FILE_INCLUDE) == IDCANCEL ||
                    DoWeSave(FILE_RESOURCE) == IDCANCEL)
                return FALSE;
            else
                return TRUE;

        case WM_DESTROY:
            /*
             * Save the position of the app's window.
             */
            WriteWindowPos(&grcAppPos, IsZoomed(hwnd), szAppPos);

            WinHelp(hwnd, gszHelpFile, HELP_QUIT, 0L);
            FreeMenuBitmaps();
            PostQuitMessage(0);
            break;

        default:
            /*
             * Is this the registered help message from one of the common
             * dialogs?  If so, show the help for it.
             *
             * The check to be sure gmsgHelp is non-zero is just in
             * case the call to register the help message failed
             * (it will return zero) and there happens to be a zero
             * message that gets sent to this window somehow.
             */
            if (msg == gmsgHelp && gmsgHelp) {
                ShowHelp(FALSE);
                return 0;
            }

        DoDefault:
            return DefWindowProc(hwnd, msg, wParam, lParam);
    }

    return 0;
}