Fixed issue #1076: Error trying to delete remote branch named 1.0.0
[TortoiseGit.git] / src / TortoiseProc / ProgressDlg.cpp
blob30fea84b5ada7c1c14217ba57d5aa882d994f653
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2012 - TortoiseGit
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 // ProgressDlg.cpp : implementation file
22 #include "stdafx.h"
23 #include "TortoiseProc.h"
24 #include "ProgressDlg.h"
25 #include "Git.h"
26 #include "atlconv.h"
27 #include "UnicodeUtils.h"
28 #include "IconMenu.h"
29 #include "LoglistCommonResource.h"
30 #include "Tlhelp32.h"
31 #include "AppUtils.h"
32 #include "SmartHandle.h"
33 #include "../TGitCache/CacheInterface.h"
35 // CProgressDlg dialog
37 IMPLEMENT_DYNAMIC(CProgressDlg, CResizableStandAloneDialog)
39 CProgressDlg::CProgressDlg(CWnd* pParent /*=NULL*/)
40 : CResizableStandAloneDialog(CProgressDlg::IDD, pParent), m_bShowCommand(true), m_bAutoCloseOnSuccess(false), m_bAbort(false), m_bDone(false)
42 m_pThread = NULL;
43 m_bAltAbortPress=false;
44 m_bBufferAll=false;
47 CProgressDlg::~CProgressDlg()
49 if(m_pThread != NULL)
51 delete m_pThread;
55 void CProgressDlg::DoDataExchange(CDataExchange* pDX)
57 CDialog::DoDataExchange(pDX);
58 DDX_Control(pDX, IDC_CURRENT, this->m_CurrentWork);
59 DDX_Control(pDX, IDC_TITLE_ANIMATE, this->m_Animate);
60 DDX_Control(pDX, IDC_RUN_PROGRESS, this->m_Progress);
61 DDX_Control(pDX, IDC_LOG, this->m_Log);
62 DDX_Control(pDX, IDC_PROGRESS_BUTTON1, this->m_ctrlPostCmd);
65 BEGIN_MESSAGE_MAP(CProgressDlg, CResizableStandAloneDialog)
66 ON_WM_CLOSE()
67 ON_MESSAGE(MSG_PROGRESSDLG_UPDATE_UI, OnProgressUpdateUI)
68 ON_BN_CLICKED(IDOK, &CProgressDlg::OnBnClickedOk)
69 ON_BN_CLICKED(IDC_PROGRESS_BUTTON1,&CProgressDlg::OnBnClickedButton1)
70 ON_REGISTERED_MESSAGE(WM_TASKBARBTNCREATED, OnTaskbarBtnCreated)
71 END_MESSAGE_MAP()
73 BOOL CProgressDlg::OnInitDialog()
75 CResizableStandAloneDialog::OnInitDialog();
77 // Let the TaskbarButtonCreated message through the UIPI filter. If we don't
78 // do this, Explorer would be unable to send that message to our window if we
79 // were running elevated. It's OK to make the call all the time, since if we're
80 // not elevated, this is a no-op.
81 CHANGEFILTERSTRUCT cfs = { sizeof(CHANGEFILTERSTRUCT) };
82 typedef BOOL STDAPICALLTYPE ChangeWindowMessageFilterExDFN(HWND hWnd, UINT message, DWORD action, PCHANGEFILTERSTRUCT pChangeFilterStruct);
83 CAutoLibrary hUser = ::LoadLibrary(_T("user32.dll"));
84 if (hUser)
86 ChangeWindowMessageFilterExDFN *pfnChangeWindowMessageFilterEx = (ChangeWindowMessageFilterExDFN*)GetProcAddress(hUser, "ChangeWindowMessageFilterEx");
87 if (pfnChangeWindowMessageFilterEx)
89 pfnChangeWindowMessageFilterEx(m_hWnd, WM_TASKBARBTNCREATED, MSGFLT_ALLOW, &cfs);
92 m_pTaskbarList.Release();
93 m_pTaskbarList.CoCreateInstance(CLSID_TaskbarList);
95 AddAnchor(IDC_TITLE_ANIMATE, TOP_LEFT, TOP_RIGHT);
96 AddAnchor(IDC_RUN_PROGRESS, TOP_LEFT,TOP_RIGHT);
97 AddAnchor(IDC_LOG, TOP_LEFT,BOTTOM_RIGHT);
99 AddAnchor(IDOK,BOTTOM_RIGHT);
100 AddAnchor(IDCANCEL,BOTTOM_RIGHT);
101 AddAnchor(IDC_PROGRESS_BUTTON1,BOTTOM_LEFT);
102 AddAnchor(IDC_CURRENT,TOP_LEFT);
104 this->GetDlgItem(IDC_PROGRESS_BUTTON1)->ShowWindow(SW_HIDE);
105 m_Animate.Open(IDR_DOWNLOAD);
107 CFont m_logFont;
108 CAppUtils::CreateFontForLogs(m_logFont);
109 //GetDlgItem(IDC_CMD_LOG)->SetFont(&m_logFont);
110 m_Log.SetFont(&m_logFont);
112 CString InitialText;
113 if ( !m_PreText.IsEmpty() )
115 InitialText = m_PreText + _T("\r\n");
117 #if 0
118 if (m_bShowCommand && (!m_GitCmd.IsEmpty() ))
120 InitialText += m_GitCmd+_T("\r\n\r\n");
122 #endif
123 m_Log.SetWindowTextW(InitialText);
124 m_CurrentWork.SetWindowTextW(_T(""));
126 EnableSaveRestore(_T("ProgressDlg"));
128 m_pThread = AfxBeginThread(ProgressThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED);
129 if (m_pThread==NULL)
131 // ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED)));
133 else
135 m_pThread->m_bAutoDelete = FALSE;
136 m_pThread->ResumeThread();
139 if(!m_Title.IsEmpty())
140 this->SetWindowText(m_Title);
142 CString sWindowTitle;
143 GetWindowText(sWindowTitle);
144 CAppUtils::SetWindowTitle(m_hWnd, g_Git.m_CurrentDir, sWindowTitle);
146 if(m_PostCmdList.GetCount()>0)
147 m_ctrlPostCmd.AddEntries(m_PostCmdList);
149 return TRUE;
152 UINT CProgressDlg::ProgressThreadEntry(LPVOID pVoid)
154 return ((CProgressDlg*)pVoid)->ProgressThread();
157 //static function, Share with SyncDialog
158 UINT CProgressDlg::RunCmdList(CWnd *pWnd,std::vector<CString> &cmdlist,bool bShowCommand,CString *pfilename,bool *bAbort,CGitByteArray *pdata)
160 UINT ret=0;
162 PROCESS_INFORMATION pi;
163 HANDLE hRead = 0;
165 memset(&pi,0,sizeof(PROCESS_INFORMATION));
167 CBlockCacheForPath cacheBlock(g_Git.m_CurrentDir);
169 pWnd->PostMessage(MSG_PROGRESSDLG_UPDATE_UI,MSG_PROGRESSDLG_START,0);
171 if(pdata)
172 pdata->clear();
174 for(int i=0;i<cmdlist.size();i++)
176 if(cmdlist[i].IsEmpty())
177 continue;
179 if (bShowCommand)
181 CStringA str = CUnicodeUtils::GetMulti(cmdlist[i].Trim() + _T("\n\n"), CP_UTF8);
182 for(int j=0;j<str.GetLength();j++)
184 if(pdata)
186 pdata->m_critSec.Lock();
187 pdata->push_back(str[j]);
188 pdata->m_critSec.Unlock();
190 else
191 pWnd->PostMessage(MSG_PROGRESSDLG_UPDATE_UI,MSG_PROGRESSDLG_RUN,str[j]);
193 if(pdata)
194 pWnd->PostMessage(MSG_PROGRESSDLG_UPDATE_UI,MSG_PROGRESSDLG_RUN,0);
197 g_Git.RunAsync(cmdlist[i].Trim(),&pi, &hRead, NULL, pfilename);
199 DWORD readnumber;
200 char byte;
201 CString output;
202 while(ReadFile(hRead,&byte,1,&readnumber,NULL))
204 if(pdata)
206 if(byte == 0)
207 byte = '\n';
209 pdata->m_critSec.Lock();
210 pdata->push_back( byte);
211 pdata->m_critSec.Unlock();
213 if(byte == '\r' || byte == '\n')
214 pWnd->PostMessage(MSG_PROGRESSDLG_UPDATE_UI,MSG_PROGRESSDLG_RUN,0);
216 else
217 pWnd->PostMessage(MSG_PROGRESSDLG_UPDATE_UI,MSG_PROGRESSDLG_RUN,byte);
220 CloseHandle(pi.hThread);
222 WaitForSingleObject(pi.hProcess, INFINITE);
224 DWORD status=0;
225 if(!GetExitCodeProcess(pi.hProcess,&status) || *bAbort)
227 CloseHandle(pi.hProcess);
229 CloseHandle(hRead);
231 pWnd->PostMessage(MSG_PROGRESSDLG_UPDATE_UI, MSG_PROGRESSDLG_FAILED, status);
232 return TGIT_GIT_ERROR_GET_EXIT_CODE;
234 ret |= status;
237 CloseHandle(pi.hProcess);
239 CloseHandle(hRead);
241 pWnd->PostMessage(MSG_PROGRESSDLG_UPDATE_UI, MSG_PROGRESSDLG_END, ret);
243 return ret;
247 UINT CProgressDlg::ProgressThread()
250 m_GitCmdList.push_back(m_GitCmd);
252 CString *pfilename;
254 if(m_LogFile.IsEmpty())
255 pfilename=NULL;
256 else
257 pfilename=&m_LogFile;
259 m_GitStatus = RunCmdList(this,m_GitCmdList,m_bShowCommand,pfilename,&m_bAbort,&this->m_Databuf);;
260 return 0;
263 LRESULT CProgressDlg::OnProgressUpdateUI(WPARAM wParam,LPARAM lParam)
265 if(wParam == MSG_PROGRESSDLG_START)
267 m_BufStart = 0 ;
268 m_Animate.Play(0, INT_MAX, INT_MAX);
269 this->DialogEnableWindow(IDOK,FALSE);
270 if (m_pTaskbarList)
272 m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NORMAL);
273 m_pTaskbarList->SetProgressValue(m_hWnd, 0, 100);
276 if(wParam == MSG_PROGRESSDLG_END || wParam == MSG_PROGRESSDLG_FAILED)
278 if(m_bBufferAll)
280 m_Databuf.m_critSec.Lock();
281 m_Databuf.push_back(0);
282 m_Databuf.m_critSec.Unlock();
283 InsertCRLF();
284 m_Databuf.m_critSec.Lock();
285 m_Log.SetWindowText(Convert2UnionCode((char*)&m_Databuf[0]));
286 m_Databuf.m_critSec.Unlock();
287 m_Log.LineScroll(m_Log.GetLineCount() - m_Log.GetFirstVisibleLine() - 4);
289 m_BufStart=0;
290 m_Databuf.m_critSec.Lock();
291 this->m_Databuf.clear();
292 m_Databuf.m_critSec.Unlock();
294 m_bDone = true;
295 m_Animate.Stop();
296 m_Progress.SetPos(100);
297 this->DialogEnableWindow(IDOK,TRUE);
299 m_GitStatus = (DWORD)lParam;
301 // detect crashes of perl when performing git svn actions
302 if (m_GitStatus == 0 && m_GitCmd.Find(_T(" svn ")) > 1)
304 CString log;
305 m_Log.GetWindowText(log);
306 if (log.GetLength() > 18 && log.Mid(log.GetLength() - 18) == _T("perl.exe.stackdump"))
307 m_GitStatus = (DWORD)-1;
310 if(this->m_GitStatus)
312 if (m_pTaskbarList)
314 m_pTaskbarList->SetProgressState(m_hWnd, TBPF_ERROR);
315 m_pTaskbarList->SetProgressValue(m_hWnd, 100, 100);
317 CString log;
318 log.Format(IDS_PROC_PROGRESS_GITUNCLEANEXIT, m_GitStatus);
319 CString err;
320 err.Format(_T("\r\n\r\n%s\r\n"), log);
321 InsertColorText(this->m_Log, err, RGB(255,0,0));
323 else {
324 if (m_pTaskbarList)
325 m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NOPROGRESS);
326 CString temp;
327 temp.LoadString(IDS_SUCCESS);
328 CString log;
329 log.Format(_T("\r\n%s\r\n"), temp);
330 InsertColorText(this->m_Log, log, RGB(0,0,255));
331 this->DialogEnableWindow(IDCANCEL,FALSE);
334 if(wParam == MSG_PROGRESSDLG_END && m_GitStatus == 0)
336 if(m_bAutoCloseOnSuccess)
338 m_Log.GetWindowText(this->m_LogText);
339 EndDialog(IDOK);
342 if(m_PostCmdList.GetCount() > 0)
343 GetDlgItem(IDC_PROGRESS_BUTTON1)->ShowWindow(SW_SHOW);
347 if(!m_bBufferAll)
349 if(lParam == 0)
351 m_Databuf.m_critSec.Lock();
352 for(int i=this->m_BufStart;i<this->m_Databuf.size();i++)
354 char c = this->m_Databuf[m_BufStart];
355 m_BufStart++;
356 m_Databuf.m_critSec.Unlock();
357 ParserCmdOutput(c);
359 m_Databuf.m_critSec.Lock();
362 if(m_BufStart>1000)
364 m_Databuf.erase(m_Databuf.begin(), m_Databuf.begin()+m_BufStart);
365 m_BufStart =0;
367 m_Databuf.m_critSec.Unlock();
370 else
371 ParserCmdOutput((char)lParam);
373 return 0;
376 //static function, Share with SyncDialog
377 int CProgressDlg::FindPercentage(CString &log)
379 int s1=log.Find(_T('%'));
380 if(s1<0)
381 return -1;
383 int s2=s1-1;
384 for(int i=s1-1;i>=0;i--)
386 if(log[i]>=_T('0') && log[i]<=_T('9'))
387 s2=i;
388 else
389 break;
391 return _ttol(log.Mid(s2,s1-s2));
394 void CProgressDlg::ParserCmdOutput(char ch)
396 ParserCmdOutput(this->m_Log,this->m_Progress,this->m_hWnd,this->m_pTaskbarList,this->m_LogTextA,ch,&this->m_CurrentWork);
398 void CProgressDlg::ClearESC(CString &str)
400 // see http://ascii-table.com/ansi-escape-sequences.php and http://tldp.org/HOWTO/Bash-Prompt-HOWTO/c327.html
401 str.Replace(_T("\033[K"), _T("")); // erase until end of line; no need to care for this, because we always clear the whole line
403 // drop colors
404 while (true)
406 int escapePosition = str.Find(_T('\033'));
407 if (escapePosition >= 0 && str.GetLength() >= escapePosition + 3)
409 if (str.Mid(escapePosition, 2) == _T("\033["))
411 int colorEnd = str.Find(_T('m'), escapePosition + 2);
412 if (colorEnd > 0)
414 bool found = true;
415 for (int i = escapePosition + 2; i < colorEnd; i++)
417 if (str[i] != _T(';') && (str[i] < _T('0') && str[i] > _T('9')))
419 found = false;
420 break;
423 if (found)
425 if (escapePosition > 0)
426 str = str.Left(escapePosition) + str.Mid(colorEnd + 1);
427 else
428 str = str.Mid(colorEnd);
429 continue;
434 break;
437 void CProgressDlg::ParserCmdOutput(CRichEditCtrl &log,CProgressCtrl &progressctrl,HWND m_hWnd,CComPtr<ITaskbarList3> m_pTaskbarList,CStringA &oneline, char ch, CWnd *CurrentWork)
439 //TRACE(_T("%c"),ch);
440 if( ch == ('\r') || ch == ('\n'))
442 CString str;
444 // TRACE(_T("End Char %s \r\n"),ch==_T('\r')?_T("lf"):_T(""));
445 // TRACE(_T("End Char %s \r\n"),ch==_T('\n')?_T("cr"):_T(""));
447 int lines = log.GetLineCount();
448 g_Git.StringAppend(&str, (BYTE*)oneline.GetBuffer(), CP_UTF8);
449 str.Trim();
450 // TRACE(_T("%s"), str);
452 ClearESC(str);
454 if(ch == ('\r'))
456 int start=log.LineIndex(lines-1);
457 log.SetSel(start, log.GetTextLength());
458 log.ReplaceSel(str);
460 else
462 int length = log.GetWindowTextLength();
463 log.SetSel(length, length);
464 if (length > 0)
465 log.ReplaceSel(_T("\r\n") + str);
466 else
467 log.ReplaceSel(str);
470 if (lines > 500) //limited log length
472 int end=log.LineIndex(1);
473 log.SetSel(0,end);
474 log.ReplaceSel(_T(""));
476 log.LineScroll(log.GetLineCount() - log.GetFirstVisibleLine() - 4);
478 int s1=oneline.ReverseFind(_T(':'));
479 int s2=oneline.Find(_T('%'));
480 if (s1 > 0 && s2 > 0)
482 if(CurrentWork)
483 CurrentWork->SetWindowTextW(str.Left(s1));
485 int pos=FindPercentage(str);
486 TRACE(_T("Pos %d\r\n"),pos);
487 if(pos>0)
489 progressctrl.SetPos(pos);
490 if (m_pTaskbarList)
492 m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NORMAL);
493 m_pTaskbarList->SetProgressValue(m_hWnd, pos, 100);
498 oneline="";
501 else
503 oneline+=ch;
506 void CProgressDlg::RemoveLastLine(CString &str)
508 int start;
509 start=str.ReverseFind(_T('\n'));
510 if(start>0)
511 str=str.Left(start);
512 return;
514 // CProgressDlg message handlers
516 void CProgressDlg::OnBnClickedOk()
518 m_Log.GetWindowText(this->m_LogText);
519 OnOK();
522 void CProgressDlg::OnBnClickedButton1()
524 this->EndDialog((int)(IDC_PROGRESS_BUTTON1 + this->m_ctrlPostCmd.GetCurrentEntry()));
527 void CProgressDlg::OnClose()
529 DialogEnableWindow(IDCANCEL, TRUE);
530 __super::OnClose();
533 void CProgressDlg::OnCancel()
535 m_bAbort = true;
536 if(m_bDone)
538 CResizableStandAloneDialog::OnCancel();
539 return;
542 if( g_Git.m_CurrentGitPi.hProcess )
544 if(::GenerateConsoleCtrlEvent(CTRL_C_EVENT,0))
546 ::WaitForSingleObject(g_Git.m_CurrentGitPi.hProcess ,10000);
548 else
550 GetLastError();
553 KillProcessTree(g_Git.m_CurrentGitPi.dwProcessId);
556 ::WaitForSingleObject(g_Git.m_CurrentGitPi.hProcess ,10000);
557 CResizableStandAloneDialog::OnCancel();
560 void CProgressDlg::KillProcessTree(DWORD dwProcessId, unsigned int depth)
562 // recursively kills a process tree
563 // This is not optimized, but works and isn't called very often ;)
565 if (!dwProcessId || depth > 20)
566 return;
568 PROCESSENTRY32 pe;
569 memset(&pe, 0, sizeof(PROCESSENTRY32));
570 pe.dwSize = sizeof(PROCESSENTRY32);
572 CAutoGeneralHandle hSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
574 if (::Process32First(hSnap, &pe))
578 if (pe.th32ParentProcessID == dwProcessId)
579 KillProcessTree(pe.th32ProcessID, depth + 1);
580 } while (::Process32Next(hSnap, &pe));
582 HANDLE hProc = ::OpenProcess(PROCESS_TERMINATE, FALSE, dwProcessId);
583 if (hProc)
584 ::TerminateProcess(hProc, 1);
588 void CProgressDlg::InsertCRLF()
590 m_Databuf.m_critSec.Lock();
591 for(int i=0;i<m_Databuf.size();i++)
593 if(m_Databuf[i]==('\n'))
595 if(i==0 || m_Databuf[i-1]!= ('\r'))
597 m_Databuf.insert(m_Databuf.begin()+i,('\r'));
598 i++;
602 m_Databuf.m_critSec.Unlock();
605 void CProgressDlg::InsertColorText(CRichEditCtrl &edit,CString text,COLORREF rgb)
607 CHARFORMAT old,cf;
608 edit.GetDefaultCharFormat(cf);
609 old=cf;
610 cf.dwMask|=CFM_COLOR;
611 cf.crTextColor=rgb;
612 cf.dwEffects|=CFE_BOLD;
613 cf.dwEffects &= ~CFE_AUTOCOLOR ;
614 edit.SetSel(edit.GetTextLength()-1,edit.GetTextLength());
615 edit.ReplaceSel(text);
616 edit.SetSel(edit.LineIndex(edit.GetLineCount()-2),edit.GetTextLength());
617 edit.SetSelectionCharFormat(cf);
618 edit.SetSel(edit.GetTextLength(),edit.GetTextLength());
619 edit.SetDefaultCharFormat(old);
620 edit.LineScroll(edit.GetLineCount() - edit.GetFirstVisibleLine() - 4);
623 CString CCommitProgressDlg::Convert2UnionCode(char *buff, int size)
625 CString str;
627 CString cmd, output;
628 int cp=CP_UTF8;
630 cmd=_T("git.exe config i18n.logOutputEncoding");
631 if (g_Git.Run(cmd, &output, NULL, CP_UTF8))
632 cp=CP_UTF8;
634 int start=0;
635 output=output.Tokenize(_T("\n"),start);
636 cp=CUnicodeUtils::GetCPCode(output);
638 start =0;
639 if(size == -1)
640 size = (int)strlen(buff);
642 for(int i=0;i<size;i++)
644 if(buff[i] == ']')
645 start = i;
646 if( start >0 && buff[i] =='\n' )
648 start =i;
649 break;
653 str.Empty();
654 g_Git.StringAppend(&str, (BYTE*)buff, cp, start);
655 g_Git.StringAppend(&str, (BYTE*)buff + start, CP_UTF8, size - start);
657 ClearESC(str);
659 return str;
662 LRESULT CProgressDlg::OnTaskbarBtnCreated(WPARAM /*wParam*/, LPARAM /*lParam*/)
664 m_pTaskbarList.Release();
665 m_pTaskbarList.CoCreateInstance(CLSID_TaskbarList);
666 return 0;
669 BOOL CProgressDlg::PreTranslateMessage(MSG* pMsg)
671 if (pMsg->message == WM_KEYDOWN)
673 if (pMsg->wParam == VK_ESCAPE)
675 // pressing the ESC key should close the dialog. But since we disabled the escape
676 // key (so the user doesn't get the idea that he could simply undo an e.g. update)
677 // this won't work.
678 // So if the user presses the ESC key, change it to VK_RETURN so the dialog gets
679 // the impression that the OK button was pressed.
680 if ((!GetDlgItem(IDCANCEL)->IsWindowEnabled())
681 &&(GetDlgItem(IDOK)->IsWindowEnabled())&&(GetDlgItem(IDOK)->IsWindowVisible()))
683 // since we convert ESC to RETURN, make sure the OK button has the focus.
684 GetDlgItem(IDOK)->SetFocus();
685 pMsg->wParam = VK_RETURN;
689 else if (pMsg->message == WM_CONTEXTMENU || pMsg->message == WM_RBUTTONDOWN)
691 CWnd * pWnd = (CWnd*) GetDlgItem(IDC_LOG);
692 if (pWnd == GetFocus())
694 CIconMenu popup;
695 if (popup.CreatePopupMenu())
697 popup.AppendMenuIcon(WM_COPY, IDS_SCIEDIT_COPY, IDI_COPYCLIP);
698 if (m_Log.GetSelText().IsEmpty())
699 popup.EnableMenuItem(WM_COPY, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
700 popup.AppendMenu(MF_SEPARATOR);
701 popup.AppendMenuIcon(EM_SETSEL, IDS_SCIEDIT_SELECTALL);
702 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, pMsg->pt.x, pMsg->pt.y, this);
703 switch (cmd)
705 case 0: // no command selected
706 break;
707 case EM_SETSEL:
708 case WM_COPY:
709 ::SendMessage(GetDlgItem(IDC_LOG)->GetSafeHwnd(), cmd, 0, -1);
710 break;
712 return TRUE;
716 return __super::PreTranslateMessage(pMsg);