Пример #1
0
LRESULT CALLBACK CMainWindow::WinMsgHandler(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    if (uMsg == TaskBarButtonCreated)
    {
        SetUUIDOverlayIcon(hwnd);
    }
    switch (uMsg)
    {
    case WM_CREATE:
        {
            m_hwnd = hwnd;
            picWindow1.RegisterAndCreateWindow(hwnd);
            picWindow2.RegisterAndCreateWindow(hwnd);
            if (selectionPaths.empty())
            {
                picWindow1.SetPic(leftpicpath, leftpictitle, true);
                picWindow2.SetPic(rightpicpath, rightpictitle, false);

                picWindow1.SetOtherPicWindow(&picWindow2);
                picWindow2.SetOtherPicWindow(&picWindow1);
            }
            else
            {
                picWindow3.RegisterAndCreateWindow(hwnd);

                picWindow1.SetPic(selectionPaths[FileTypeMine], selectionTitles[FileTypeMine], false);
                picWindow2.SetPic(selectionPaths[FileTypeBase], selectionTitles[FileTypeBase], false);
                picWindow3.SetPic(selectionPaths[FileTypeTheirs], selectionTitles[FileTypeTheirs], false);
            }

            picWindow1.SetSelectionMode(!selectionPaths.empty());
            picWindow2.SetSelectionMode(!selectionPaths.empty());
            picWindow3.SetSelectionMode(!selectionPaths.empty());

            CreateToolbar();
            // center the splitter
            RECT rect;
            GetClientRect(hwnd, &rect);
            if (selectionPaths.size() != 3)
            {
                nSplitterPos = (rect.right-rect.left)/2;
                nSplitterPos2 = 0;
            }
            else
            {
                nSplitterPos = (rect.right-rect.left)/3;
                nSplitterPos2 = (rect.right-rect.left)*2/3;
            }

            PositionChildren(&rect);
            picWindow1.FitImageInWindow();
            picWindow2.FitImageInWindow();
            picWindow3.FitImageInWindow();
        }
        break;
    case WM_COMMAND:
        {
            return DoCommand(LOWORD(wParam), lParam);
        }
        break;
    case WM_PAINT:
        {
            PAINTSTRUCT ps;
            HDC hdc;
            RECT rect;

            ::GetClientRect(*this, &rect);
            hdc = BeginPaint(hwnd, &ps);
            SetBkColor(hdc, GetSysColor(COLOR_3DFACE));
            ::ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
            EndPaint(hwnd, &ps);
        }
        break;
    case WM_GETMINMAXINFO:
        {
            MINMAXINFO * mmi = (MINMAXINFO*)lParam;
            mmi->ptMinTrackSize.x = WINDOW_MINWIDTH;
            mmi->ptMinTrackSize.y = WINDOW_MINHEIGHT;
            return 0;
        }
        break;
    case WM_SIZE:
        {
            RECT rect;
            GetClientRect(hwnd, &rect);
            if (bVertical)
            {
                RECT tbRect;
                GetWindowRect(hwndTB, &tbRect);
                LONG tbHeight = tbRect.bottom-tbRect.top-1;
                if (selectionPaths.size() != 3)
                {
                    nSplitterPos = (rect.bottom-rect.top)/2+tbHeight;
                    nSplitterPos2 = 0;
                }
                else
                {
                    nSplitterPos = (rect.bottom-rect.top)/3+tbHeight;
                    nSplitterPos2 = (rect.bottom-rect.top)*2/3+tbHeight;
                }
            }
            else
            {
                if (selectionPaths.size() != 3)
                {
                    nSplitterPos = (rect.right-rect.left)/2;
                    nSplitterPos2 = 0;
                }
                else
                {
                    nSplitterPos = (rect.right-rect.left)/3;
                    nSplitterPos2 = (rect.right-rect.left)*2/3;
                }
            }
            PositionChildren(&rect);
        }
        break;
    case WM_SETCURSOR:
        {
            if ((HWND)wParam == *this)
            {
                RECT rect;
                POINT pt;
                GetClientRect(*this, &rect);
                GetCursorPos(&pt);
                ScreenToClient(*this, &pt);
                if (PtInRect(&rect, pt))
                {
                    if (bVertical)
                    {
                        HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZENS));
                        SetCursor(hCur);
                    }
                    else
                    {
                        HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZEWE));
                        SetCursor(hCur);
                    }
                    return TRUE;
                }
            }
            return DefWindowProc(hwnd, uMsg, wParam, lParam);
        }
        break;
    case WM_LBUTTONDOWN:
        Splitter_OnLButtonDown(hwnd, uMsg, wParam, lParam);
        break;
    case WM_LBUTTONUP:
        Splitter_OnLButtonUp(hwnd, uMsg, wParam, lParam);
        break;
    case WM_CAPTURECHANGED:
        Splitter_CaptureChanged();
        break;
    case WM_MOUSEMOVE:
        Splitter_OnMouseMove(hwnd, uMsg, wParam, lParam);
        break;
    case WM_MOUSEWHEEL:
        {
            // find out if the mouse cursor is over one of the views, and if
            // it is, pass the mouse wheel message to that view
            POINT pt;
            DWORD ptW = GetMessagePos();
            pt.x = GET_X_LPARAM(ptW);
            pt.y = GET_Y_LPARAM(ptW);
            RECT rect;
            GetWindowRect(picWindow1, &rect);
            if (PtInRect(&rect, pt))
            {
                picWindow1.OnMouseWheel(GET_KEYSTATE_WPARAM(wParam), GET_WHEEL_DELTA_WPARAM(wParam));
            }
            else
            {
                GetWindowRect(picWindow2, &rect);
                if (PtInRect(&rect, pt))
                {
                    picWindow2.OnMouseWheel(GET_KEYSTATE_WPARAM(wParam), GET_WHEEL_DELTA_WPARAM(wParam));
                }
                else
                {
                    GetWindowRect(picWindow3, &rect);
                    if (PtInRect(&rect, pt))
                    {
                        picWindow3.OnMouseWheel(GET_KEYSTATE_WPARAM(wParam), GET_WHEEL_DELTA_WPARAM(wParam));
                    }
                }
            }
        }
        break;
    case WM_MOUSEHWHEEL:
        {
            // find out if the mouse cursor is over one of the views, and if
            // it is, pass the mouse wheel message to that view
            POINT pt;
            DWORD ptW = GetMessagePos();
            pt.x = GET_X_LPARAM(ptW);
            pt.y = GET_Y_LPARAM(ptW);
            RECT rect;
            GetWindowRect(picWindow1, &rect);
            if (PtInRect(&rect, pt))
            {
                picWindow1.OnMouseWheel(GET_KEYSTATE_WPARAM(wParam)|MK_SHIFT, GET_WHEEL_DELTA_WPARAM(wParam));
            }
            else
            {
                GetWindowRect(picWindow2, &rect);
                if (PtInRect(&rect, pt))
                {
                    picWindow2.OnMouseWheel(GET_KEYSTATE_WPARAM(wParam)|MK_SHIFT, GET_WHEEL_DELTA_WPARAM(wParam));
                }
                else
                {
                    GetWindowRect(picWindow3, &rect);
                    if (PtInRect(&rect, pt))
                    {
                        picWindow3.OnMouseWheel(GET_KEYSTATE_WPARAM(wParam)|MK_SHIFT, GET_WHEEL_DELTA_WPARAM(wParam));
                    }
                }
            }
        }
        break;
    case WM_NOTIFY:
        {
            LPNMHDR pNMHDR = (LPNMHDR)lParam;
            if (pNMHDR->code == TTN_GETDISPINFO)
            {
                LPTOOLTIPTEXT lpttt;

                lpttt = (LPTOOLTIPTEXT) lParam;
                lpttt->hinst = hResource;

                // Specify the resource identifier of the descriptive
                // text for the given button.
                TCHAR stringbuf[MAX_PATH] = {0};
                MENUITEMINFO mii;
                mii.cbSize = sizeof(MENUITEMINFO);
                mii.fMask = MIIM_TYPE;
                mii.dwTypeData = stringbuf;
                mii.cch = _countof(stringbuf);
                GetMenuItemInfo(GetMenu(*this), (UINT)lpttt->hdr.idFrom, FALSE, &mii);
                _tcscpy_s(lpttt->lpszText, 80, stringbuf);
            }
        }
        break;
    case WM_DESTROY:
        bWindowClosed = TRUE;
        PostQuitMessage(0);
        break;
    case WM_CLOSE:
        ImageList_Destroy(hToolbarImgList);
        ::DestroyWindow(m_hwnd);
        break;
    default:
        return DefWindowProc(hwnd, uMsg, wParam, lParam);
    }

    return 0;
};
Пример #2
0
BOOL CALLBACK FileListDialog::run_dlgProc( UINT msg, WPARAM wp, LPARAM lp )
{
	switch ( msg )
	{
		case WM_INITDIALOG:
			InitialiseDialog();
			break;

		case WM_SIZE:
			ResizeListBoxes();
			break;
		case WM_LBUTTONDOWN:
			Splitter_OnLButtonDown(_hSelf, msg, wp, lp);
			return 0;

		case WM_LBUTTONUP:
			Splitter_OnLButtonUp(_hSelf, msg, wp, lp);
			return 0;

		case WM_MOUSEMOVE:
			Splitter_OnMouseMove(_hSelf, msg, wp, lp);
			return 0;
		case WM_MOVE:
		case WM_COMMAND:
			if ( (HWND)lp == gtagSearchResult.getHSelf() )
			{
				switch ( HIWORD(wp) )
				{
				case LBN_SELCHANGE:
					//gtagSearchResult.SetTTText();
					if(IsDefSearch)return 0;

				case LBN_DBLCLK:
					OnFileListDoubleClicked();
					return 0;
				}
			}
			if ( (HWND)lp == gtagFunctionList.getHSelf() )
			{
				switch ( HIWORD(wp) )
				{
				/*case LBN_SELCHANGE:
					gtagFunctionList.SetTTText();
					return 0;*/

				case LBN_DBLCLK:
					int array_index=gtagFunctionList.GetCurrentSelectionIndex();
					std::vector<int>::iterator it=linenum_list.begin()+array_index;
					OpenFileAndGotoLine(fileName.c_str(),*it);
					return 0;
				}
			}

			break;
		case WM_NOTIFY:
			{
				LPNMHDR nmhdr = (LPNMHDR) lp;
				if ( nmhdr->hwndFrom == _hParent )
				{
					switch ( LOWORD( nmhdr->code ) )
					{
					case DMN_FLOAT:
					case DMN_DOCK:
						{
							if ( LOWORD( nmhdr->code ) == DMN_FLOAT )
							{
								_isFloating = true;
							}
							else
							{
								_isFloating = false;
								_iDockedPos = HIWORD( nmhdr->code );
							}
							break;
						}
					default:
						// Parse all other notifications to docking dialog interface
						return DockingDlgInterface::run_dlgProc(msg, wp, lp );
					}
				}
				break;
			}
		default:
			return DockingDlgInterface::run_dlgProc(msg, wp, lp );
	}

	return FALSE;
}