Explorar o código

- output 32 vs 64 bit build in options - about
- support horizontal scrolling in image viewer

sabrogden %!s(int64=7) %!d(string=hai) anos
pai
achega
4a6896a179
Modificáronse 6 ficheiros con 68 adicións e 1 borrados
  1. 5 0
      About.cpp
  2. 11 0
      ImageViewer.cpp
  3. 1 0
      ImageViewer.h
  4. 6 1
      MainFrm.cpp
  5. 44 0
      ScrollHelper.cpp
  6. 1 0
      ScrollHelper.h

+ 5 - 0
About.cpp

@@ -66,6 +66,11 @@ BOOL CAbout::OnInitDialog()
 
 	CString csText;
 	csText = "    Version " + cs;
+#if _WIN64
+	csText += " 64bit";
+#else
+	csText += " 32bit";
+#endif
 	m_List.AddString(csText);
 
 	const char *SqliteVersion = sqlite3_libversion();

+ 11 - 0
ImageViewer.cpp

@@ -32,6 +32,7 @@ BEGIN_MESSAGE_MAP(CImageViewer, CWnd)
 	ON_WM_SIZE()
 	ON_WM_SETCURSOR()
 	ON_WM_LBUTTONUP()
+	ON_WM_MOUSEHWHEEL()
 END_MESSAGE_MAP()
 
 BOOL CImageViewer::Create(CWnd* pParent)
@@ -174,6 +175,13 @@ BOOL CImageViewer::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
 	return wasScrolled;
 }
 
+void CImageViewer::OnMouseHWheel(UINT nFlags, short zDelta, CPoint pt)
+{
+	BOOL wasScrolled = m_scrollHelper.OnMouseHWheel(nFlags, zDelta, pt);
+
+	CWnd::OnMouseHWheel(nFlags, zDelta, pt);
+}
+
 void CImageViewer::OnSize(UINT nType, int cx, int cy)
 {
 	CWnd::OnSize(nType, cx, cy);
@@ -219,3 +227,6 @@ void CImageViewer::OnLButtonUp(UINT nFlags, CPoint point)
 
 	CWnd::OnLButtonUp(nFlags, point);
 }
+
+
+

+ 1 - 0
ImageViewer.h

@@ -33,6 +33,7 @@ protected:
 public:
 	afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
 	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
+	afx_msg void OnMouseHWheel(UINT nFlags, short zDelta, CPoint pt);
 };
 
 

+ 6 - 1
MainFrm.cpp

@@ -835,7 +835,7 @@ BOOL CMainFrame::PreTranslateMessage(MSG *pMsg)
 {
 	//forward the mouse wheel onto the window under the cursor
 	//normally windows only sends it to the window with focus, bypass this
-	if (pMsg->message == WM_MOUSEWHEEL &&
+	if ((pMsg->message == WM_MOUSEWHEEL || pMsg->message == WM_MOUSEHWHEEL) &&
 		::GetCapture() == nullptr)
 	{
 		POINT mouse;
@@ -849,8 +849,13 @@ BOOL CMainFrame::PreTranslateMessage(MSG *pMsg)
 			if (winProcessId == ::GetCurrentProcessId()) //no-fail!
 			{
 				pMsg->hwnd = hwndFromPoint;
+
+				
 			}
 		}
+		
+		//if (GetKeyState(VK_SHIFT) & 0x8000)
+		//	pMsg->message = WM_MOUSEHWHEEL;
 	}
 
     return CFrameWnd::PreTranslateMessage(pMsg);

+ 44 - 0
ScrollHelper.cpp

@@ -295,6 +295,50 @@ BOOL CScrollHelper::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
     return TRUE;
 }
 
+BOOL CScrollHelper::OnMouseHWheel(UINT nFlags, short zDelta, CPoint pt)
+{
+	if (m_attachWnd == NULL)
+		return FALSE;
+
+	// Don't do anything if the vertical scrollbar is not enabled.
+	int scrollMin = 0, scrollMax = 0;
+	m_attachWnd->GetScrollRange(SB_VERT, &scrollMin, &scrollMax);
+	if (scrollMin == scrollMax)
+		return FALSE;
+
+	// Compute the number of scrolling increments requested.
+	int numScrollIncrements = abs(zDelta) / WHEEL_DELTA;
+
+	// Each scrolling increment corresponds to a certain number of
+	// scroll lines (one scroll line is like a SB_LINEUP or SB_LINEDOWN).
+	// We need to query the system parameters for this value.
+	int numScrollLinesPerIncrement = 0;
+	::SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &numScrollLinesPerIncrement, 0);
+
+	// Check if a page scroll was requested.
+	if (numScrollLinesPerIncrement == WHEEL_PAGESCROLL)
+	{
+		// Call the vscroll message handler to do the work.		
+		OnHScroll(zDelta > 0 ? SB_PAGEUP : SB_PAGEDOWN, 0, NULL);
+		return TRUE;
+	}
+
+	// Compute total number of lines to scroll.
+	int numScrollLines = numScrollIncrements * numScrollLinesPerIncrement;
+
+	// Adjust numScrollLines to slow down the scrolling a bit more.
+	numScrollLines = max(numScrollLines / 3, 1);
+
+	// Do the scrolling.
+	for (int i = 0; i < numScrollLines; ++i)
+	{
+		// Call the vscroll message handler to do the work.
+		OnHScroll(zDelta > 0 ? SB_LINEUP : SB_LINEDOWN, 0, NULL);
+	}
+
+	return TRUE;
+}
+
 void CScrollHelper::OnSize(UINT nType, int cx, int cy)
 {
     UpdateScrollInfo();

+ 1 - 0
ScrollHelper.h

@@ -40,6 +40,7 @@ public:
     void   OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
     void   OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
     BOOL   OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
+	BOOL   OnMouseHWheel(UINT nFlags, short zDelta, CPoint pt);
     void   OnSize(UINT nType, int cx, int cy);
 
 private: