Bläddra i källkod

when focus is on the search pass on delete and copy messages to the list control
[SAB]


git-svn-id: svn://svn.code.sf.net/p/ditto-cp/code/trunk@194 595ec19a-5cb4-439b-94a8-42fb3063c22c

sabrogden 20 år sedan
förälder
incheckning
81cb864f0a
10 ändrade filer med 172 tillägg och 111 borttagningar
  1. 24 8
      CP_Main.dsp
  2. 32 15
      ClipboardViewer.cpp
  3. 18 1
      ComboBoxSearch.cpp
  4. 0 2
      DatabaseUtilities.cpp
  5. 3 0
      FormatSQL.cpp
  6. 6 1
      Misc.cpp
  7. 7 4
      OptionsGeneral.cpp
  8. 78 70
      QListCtrl.cpp
  9. 3 1
      QListCtrl.h
  10. 1 9
      QPasteWnd.cpp

+ 24 - 8
CP_Main.dsp

@@ -200,10 +200,22 @@ SOURCE=.\Client.cpp
 # End Source File
 # Begin Source File
 
+SOURCE=.\Clip.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\ClipboardViewer.cpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\CopyProperties.cpp
 # End Source File
 # Begin Source File
 
+SOURCE=.\CopyThread.cpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\CP_Main.cpp
 # End Source File
 # Begin Source File
@@ -296,10 +308,6 @@ SOURCE=.\OptionsUtilities.cpp
 # End Source File
 # Begin Source File
 
-SOURCE=.\ProcessCopy.cpp
-# End Source File
-# Begin Source File
-
 SOURCE=.\ProcessPaste.cpp
 # End Source File
 # Begin Source File
@@ -357,10 +365,22 @@ SOURCE=.\Client.h
 # End Source File
 # Begin Source File
 
+SOURCE=.\Clip.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\ClipboardViewer.h
+# End Source File
+# Begin Source File
+
 SOURCE=.\CopyProperties.h
 # End Source File
 # Begin Source File
 
+SOURCE=.\CopyThread.h
+# End Source File
+# Begin Source File
+
 SOURCE=.\CP_Main.h
 # End Source File
 # Begin Source File
@@ -461,10 +481,6 @@ SOURCE=.\OptionsUtilities.h
 # End Source File
 # Begin Source File
 
-SOURCE=.\ProcessCopy.h
-# End Source File
-# Begin Source File
-
 SOURCE=.\ProcessPaste.h
 # End Source File
 # Begin Source File

+ 32 - 15
ClipboardViewer.cpp

@@ -74,7 +74,7 @@ void CClipboardViewer::Disconnect()
 {
 	KillTimer(TIMER_ENSURE_VIEWER_IN_CHAIN);
 
-	CWnd::ChangeClipboardChain( m_hNextClipboardViewer );
+	CWnd::ChangeClipboardChain(m_hNextClipboardViewer);
 	m_hNextClipboardViewer = 0;
 	m_bIsConnected = false;
 }
@@ -149,6 +149,8 @@ void CClipboardViewer::OnDestroy()
 
 void CClipboardViewer::OnChangeCbChain(HWND hWndRemove, HWND hWndAfter) 
 {
+	Log(StrF("OnChangeCbChain Removed = %d After = %d", hWndAfter, hWndAfter));
+
 	// If the next window is closing, repair the chain. 
 	if(m_hNextClipboardViewer == hWndRemove)
     {
@@ -159,6 +161,8 @@ void CClipboardViewer::OnChangeCbChain(HWND hWndRemove, HWND hWndAfter)
     {
 		if(m_hNextClipboardViewer != m_hWnd)
 		{
+			Log(StrF("OnChangeCbChain Sending WM_CHANGECBCHAIN to %d", m_hNextClipboardViewer));
+
 			::SendMessage(m_hNextClipboardViewer, WM_CHANGECBCHAIN, (WPARAM) hWndRemove, (LPARAM) hWndAfter);
 		}
 		else
@@ -171,40 +175,53 @@ void CClipboardViewer::OnChangeCbChain(HWND hWndRemove, HWND hWndAfter)
 //Message that the clipboard data has changed
 void CClipboardViewer::OnDrawClipboard() 
 {
-	if( m_bPinging )
+	if(m_bPinging)
 	{
 		m_bPingSuccess = true;
 		return;
 	}
+
+	Log("Start of OnDrawClipboard");
+	bool bPassOn = false;
 	
 	if((GetTickCount() - m_lLastCopy) > g_Opt.m_lSaveClipDelay)
 	{
 		// don't process the event when we first attach
-		if( m_pHandler && !m_bCalling_SetClipboardViewer )
+		if(m_pHandler && !m_bCalling_SetClipboardViewer)
 		{
-			if( !::IsClipboardFormatAvailable( theApp.m_cfIgnoreClipboard ) )
+			if(!::IsClipboardFormatAvailable(theApp.m_cfIgnoreClipboard))
+			{
 				m_pHandler->OnClipboardChange();
+
+				bPassOn = true;
+				m_lLastCopy = GetTickCount();
+			}
 		}
 	}
 	else
 	{
-		CString cs;
-		cs.Format("Clip copy to fast difference from last copy = %d", (GetTickCount() - m_lLastCopy));
-		Log(cs);
+		Log(StrF("Clip copy to fast difference from last copy = %d", (GetTickCount() - m_lLastCopy)));
 	}
 	
-	// pass the event to the next Clipboard viewer in the chain
-	if( m_hNextClipboardViewer != NULL )
+	if(bPassOn)
 	{
-		if(m_hNextClipboardViewer != m_hWnd)
+		// pass the event to the next Clipboard viewer in the chain
+		if(m_hNextClipboardViewer != NULL)
 		{
-			::SendMessage(m_hNextClipboardViewer, WM_DRAWCLIPBOARD, 0, 0);	
-		}
-		else
-		{
-			m_hNextClipboardViewer = NULL;
+			if(m_hNextClipboardViewer != m_hWnd)
+			{
+				Log(StrF("OnDrawClipboard Sending WM_DRAWCLIPBOARD to %d", m_hNextClipboardViewer));
+
+				::SendMessage(m_hNextClipboardViewer, WM_DRAWCLIPBOARD, 0, 0);	
+			}
+			else
+			{
+				m_hNextClipboardViewer = NULL;
+			}
 		}
 	}
+
+	Log("End of OnDrawClipboard");
 }
 
 void CClipboardViewer::OnTimer(UINT nIDEvent) 

+ 18 - 1
ComboBoxSearch.cpp

@@ -84,7 +84,7 @@ BOOL CComboBoxSearch::PreTranslateMessage(MSG* pMsg)
 
 				return TRUE;
 			}	
-			if (pMsg->wParam == VK_DOWN ||
+			else if (pMsg->wParam == VK_DOWN ||
 				pMsg->wParam == VK_UP ||
 				pMsg->wParam == VK_F3)
 			{
@@ -103,6 +103,23 @@ BOOL CComboBoxSearch::PreTranslateMessage(MSG* pMsg)
 //					return TRUE;
 //				}
 			}
+			else if(pMsg->wParam == 'C' && 
+					GetKeyState(VK_CONTROL) & 0x8000 ||
+					pMsg->wParam == 'X' && 
+					GetKeyState(VK_CONTROL) & 0x8000 ||
+					pMsg->wParam == VK_DELETE)
+			{
+				LONG lEditSel = GetEditSel();
+				if(LOWORD(lEditSel) == HIWORD(lEditSel))
+				{
+					CWnd *pWnd = GetParent();
+					if(pWnd)
+					{
+						pWnd->SendMessage(CB_UPDOWN, pMsg->wParam, pMsg->lParam);
+						return TRUE;
+					}
+				}
+			}
 			break;
 		}
 	}

+ 0 - 2
DatabaseUtilities.cpp

@@ -459,8 +459,6 @@ BOOL CompactDatabase()
 {
 	if(!theApp.CloseDB())
 		return FALSE;
-	
-	CWaitCursor wait;
 
 	CString csDBName = GetDBName();
 	CString csTempDBName = csDBName;

+ 3 - 0
FormatSQL.cpp

@@ -33,6 +33,9 @@ void CFormatSQL::Parse(CString cs)
 	//Replace all "|" with a space
 	cs.Replace("|", " ");
 
+	cs.Replace("[", " ");
+	cs.Replace("]", " ");
+
 	int nLength = cs.GetLength();
 
 	CString csCurrentWord;

+ 6 - 1
Misc.cpp

@@ -65,7 +65,12 @@ void Log( const char* msg )
 	csText += msg;
 	csText += "\n";
 	TRACE(csText);
-	AppendToFile( "Ditto.log", csText ); //(LPCTSTR)
+
+	CString csFile = CGetSetOptions::GetExeFileName();
+	csFile = GetFilePath(csFile);
+	csFile += "Ditto.log";
+
+	AppendToFile(csFile, csText);
 }
 
 void LogSendRecieveInfo(CString cs)

+ 7 - 4
OptionsGeneral.cpp

@@ -181,12 +181,15 @@ BOOL COptionsGeneral::OnApply()
 	m_cbLanguage.GetLBText(m_cbLanguage.GetCurSel(), csLanguage);
 	g_Opt.SetLanguageFile(csLanguage);
 	
-	if(!theApp.m_Language.LoadLanguageFile(csLanguage))
+	if(csLanguage.IsEmpty() == FALSE)
 	{
-		CString cs;
-		cs.Format("Error loading language file - %s - \n\n%s", csLanguage, theApp.m_Language.m_csLastError);
+		if(!theApp.m_Language.LoadLanguageFile(csLanguage))
+		{
+			CString cs;
+			cs.Format("Error loading language file - %s - \n\n%s", csLanguage, theApp.m_Language.m_csLastError);
 
-		MessageBox(cs, "Ditto", MB_OK);
+			MessageBox(cs, "Ditto", MB_OK);
+		}
 	}
 
 	CString csMax;

+ 78 - 70
QListCtrl.cpp

@@ -791,88 +791,96 @@ BOOL CQListCtrl::PreTranslateMessage(MSG* pMsg)
 	switch(pMsg->message) 
 	{
 	case WM_KEYDOWN:
-		WPARAM vk = pMsg->wParam;
+		if(HandleKeyDown(pMsg->wParam, pMsg->lParam))
+			return TRUE;
+		
+		break; // end case WM_KEYDOWN
+	} // end switch(pMsg->message)
+		
+	return CListCtrl::PreTranslateMessage(pMsg);
+}
+
+BOOL CQListCtrl::HandleKeyDown(WPARAM wParam, LPARAM lParam)
+{
+	WPARAM vk = wParam;
 				
-		// if a number key was pressed
-		if( '0' <= vk && vk <= '9' )
+	// if a number key was pressed
+	if( '0' <= vk && vk <= '9' )
+	{
+		// if <Ctrl> is required but is absent, then break
+		if( g_Opt.m_bUseCtrlNumAccel && !(GetKeyState(VK_CONTROL) & 0x8000) )
+			return FALSE;
+		
+		int index = vk - '0';
+		// '0' is actually 10 in the ditto window
+		if( index == 0 )
+			index = 10;
+		// translate num 1-10 into the actual index (based upon m_bStartTop)
+		index = GetFirstTenIndex( index );
+		GetParent()->SendMessage(NM_SELECT_INDEX, index, 0);
+		return TRUE;
+	}
+	
+	switch( vk )
+	{
+	case 'X': // Ctrl-X = Cut (prepare for moving the items into a Group)
+		if(GetKeyState(VK_CONTROL) & 0x8000)
 		{
-			// if <Ctrl> is required but is absent, then break
-			if( g_Opt.m_bUseCtrlNumAccel && !(GetKeyState(VK_CONTROL) & 0x8000) )
-				break;
+			LoadCopyOrCutToClipboard();		
 			
-			int index = vk - '0';
-			// '0' is actually 10 in the ditto window
-			if( index == 0 )
-				index = 10;
-			// translate num 1-10 into the actual index (based upon m_bStartTop)
-			index = GetFirstTenIndex( index );
-			GetParent()->SendMessage(NM_SELECT_INDEX, index, 0);
+			theApp.IC_Cut(); // uses selection
 			return TRUE;
 		}
+		break;
 		
-		switch( vk )
+	case 'C': // Ctrl-C = Copy (prepare for copying the items into a Group)
+		if(GetKeyState(VK_CONTROL) & 0x8000)
 		{
-		case 'X': // Ctrl-X = Cut (prepare for moving the items into a Group)
-			if(GetKeyState(VK_CONTROL) & 0x8000)
-			{
-				LoadCopyOrCutToClipboard();		
-				
-				theApp.IC_Cut(); // uses selection
-				return TRUE;
-			}
-			break;
-			
-		case 'C': // Ctrl-C = Copy (prepare for copying the items into a Group)
-			if(GetKeyState(VK_CONTROL) & 0x8000)
-			{
-				LoadCopyOrCutToClipboard();
-				
-				theApp.IC_Copy(); // uses selection
-				return TRUE;
-			}
-			break;
-			
-		case 'V': // Ctrl-V = Paste (actually performs the copy or move of items into the current Group)
-			if(GetKeyState(VK_CONTROL) & 0x8000)
-			{
-				theApp.IC_Paste();
-				return TRUE;
-			}
-			break;
-			
-		case 'A': // Ctrl-A = Select All
-			if(GetKeyState(VK_CONTROL) & 0x8000)
-			{
-				int nCount = GetItemCount();
-				for(int i = 0; i < nCount; i++)
-				{
-					SetSelection(i);
-				}
-				return TRUE;
-			}
-			break;
+			LoadCopyOrCutToClipboard();
 			
-		case VK_F3:
-			{
-				ShowFullDescription();
-				return TRUE;
-			}
-		case VK_BACK:
-			theApp.EnterGroupID( theApp.m_GroupParentID );
+			theApp.IC_Copy(); // uses selection
 			return TRUE;
-		case VK_SPACE:
-			if(GetKeyState(VK_CONTROL) & 0x8000)
+		}
+		break;
+		
+	case 'V': // Ctrl-V = Paste (actually performs the copy or move of items into the current Group)
+		if(GetKeyState(VK_CONTROL) & 0x8000)
+		{
+			theApp.IC_Paste();
+			return TRUE;
+		}
+		break;
+		
+	case 'A': // Ctrl-A = Select All
+		if(GetKeyState(VK_CONTROL) & 0x8000)
+		{
+			int nCount = GetItemCount();
+			for(int i = 0; i < nCount; i++)
 			{
-				theApp.ShowPersistent( !g_Opt.m_bShowPersistent );
-				return TRUE;
+				SetSelection(i);
 			}
-			break;
-		} // end switch(vk)
-		
-		break; // end case WM_KEYDOWN
-	} // end switch(pMsg->message)
+			return TRUE;
+		}
+		break;
 		
-	return CListCtrl::PreTranslateMessage(pMsg);
+	case VK_F3:
+		{
+			ShowFullDescription();
+			return TRUE;
+		}
+	case VK_BACK:
+		theApp.EnterGroupID( theApp.m_GroupParentID );
+		return TRUE;
+	case VK_SPACE:
+		if(GetKeyState(VK_CONTROL) & 0x8000)
+		{
+			theApp.ShowPersistent( !g_Opt.m_bShowPersistent );
+			return TRUE;
+		}
+		break;
+	} // end switch(vk)
+	
+	return FALSE;
 }
 
 void CQListCtrl::LoadCopyOrCutToClipboard()

+ 3 - 1
QListCtrl.h

@@ -104,10 +104,12 @@ public:
 
 	HWND GetToolTipHWnd();
 
+	BOOL CQListCtrl::HandleKeyDown(WPARAM wParam, LPARAM lParam);
+
 protected:
 	void SendSelection(int nItem);;
-	void SendSelection(ARRAY &arrItems);
 	void LoadCopyOrCutToClipboard();
+	void SendSelection(ARRAY &arrItems);
 	BOOL GetClipData(int nItem, CClipFormat &Clip);
 	BOOL DrawBitMap(int nItem, CRect &crRect, CDC *pDC);
 

+ 1 - 9
QPasteWnd.cpp

@@ -2234,16 +2234,8 @@ void CQPasteWnd::OnSearchEditChange()
 
 LRESULT CQPasteWnd::OnUpDown(WPARAM wParam, LPARAM lParam)
 {
-	if(wParam == VK_F3)
-	{
-		m_lstHeader.ShowFullDescription();
-	}
-	else
-	{
-		m_lstHeader.HidePopup();
-
+	if(m_lstHeader.HandleKeyDown(wParam, lParam) == FALSE)
 		m_lstHeader.SendMessage(WM_KEYDOWN, wParam, lParam);
-	}
 
 	return TRUE;
 }