Fixed issue #673: Applying a patch does not honour CRLF in files
[TortoiseGit.git] / src / TortoiseProc / ImportPatchDlg.cpp
blob93e1c7fe3f4daf316a6b146861b8311ef9f342a4
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2011 - 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 // ImportPatchDlg.cpp : implementation file
22 #include "stdafx.h"
23 #include "TortoiseProc.h"
24 #include "ImportPatchDlg.h"
25 #include "git.h"
26 #include "MessageBox.h"
27 #include "AppUtils.h"
29 // CImportPatchDlg dialog
31 IMPLEMENT_DYNAMIC(CImportPatchDlg, CResizableStandAloneDialog)
33 CImportPatchDlg::CImportPatchDlg(CWnd* pParent /*=NULL*/)
34 : CResizableStandAloneDialog(CImportPatchDlg::IDD, pParent)
36 m_cList.m_ContextMenuMask &=~ m_cList.GetMenuMask(CPatchListCtrl::MENU_APPLY);
38 m_CurrentItem =0;
40 m_bExitThread = false;
41 m_bThreadRunning =false;
43 m_b3Way = 1;
44 m_bIgnoreSpace = 1;
45 m_bAddSignedOffBy = FALSE;
46 m_bKeepCR = TRUE;
49 CImportPatchDlg::~CImportPatchDlg()
54 void CImportPatchDlg::DoDataExchange(CDataExchange* pDX)
56 CDialog::DoDataExchange(pDX);
57 DDX_Control(pDX, IDC_LIST_PATCH,m_cList);
58 DDX_Control(pDX, IDC_AM_SPLIT, m_wndSplitter);
59 DDX_Check(pDX, IDC_CHECK_3WAY, m_b3Way);
60 DDX_Check(pDX, IDC_CHECK_IGNORE_SPACE, m_bIgnoreSpace);
61 DDX_Check(pDX, IDC_SIGN_OFF, m_bAddSignedOffBy);
62 DDX_Check(pDX, IDC_KEEP_CR, m_bKeepCR);
65 void CImportPatchDlg::AddAmAnchor()
67 AddAnchor(IDC_AM_TAB,TOP_LEFT,BOTTOM_RIGHT);
68 AddAnchor(IDC_LIST_PATCH, TOP_LEFT, TOP_RIGHT);
69 AddAnchor(IDC_AM_SPLIT, TOP_LEFT, TOP_RIGHT);
70 AddAnchor(IDC_BUTTON_ADD, TOP_RIGHT);
71 AddAnchor(IDC_BUTTON_UP, TOP_RIGHT);
72 AddAnchor(IDC_BUTTON_DOWN, TOP_RIGHT);
73 AddAnchor(IDC_BUTTON_REMOVE, TOP_RIGHT);
75 AddAnchor(IDOK,BOTTOM_RIGHT);
76 AddAnchor(IDCANCEL,BOTTOM_RIGHT);
77 AddAnchor(IDHELP, BOTTOM_RIGHT);
79 AddAnchor(IDC_AM_DUMY_TAB, TOP_LEFT, BOTTOM_RIGHT);
81 this->AddOthersToAnchor();
84 void CImportPatchDlg::SetSplitterRange()
86 if ((m_cList)&&(m_ctrlTabCtrl))
88 CRect rcTop;
89 m_cList.GetWindowRect(rcTop);
90 ScreenToClient(rcTop);
91 CRect rcMiddle;
92 m_ctrlTabCtrl.GetWindowRect(rcMiddle);
93 ScreenToClient(rcMiddle);
94 if (rcMiddle.Height() && rcMiddle.Width())
95 m_wndSplitter.SetRange(rcTop.top+160, rcMiddle.bottom-160);
99 BOOL CImportPatchDlg::OnInitDialog()
101 CResizableStandAloneDialog::OnInitDialog();
102 CAppUtils::MarkWindowAsUnpinnable(m_hWnd);
104 // Let the TaskbarButtonCreated message through the UIPI filter. If we don't
105 // do this, Explorer would be unable to send that message to our window if we
106 // were running elevated. It's OK to make the call all the time, since if we're
107 // not elevated, this is a no-op.
108 CHANGEFILTERSTRUCT cfs = { sizeof(CHANGEFILTERSTRUCT) };
109 typedef BOOL STDAPICALLTYPE ChangeWindowMessageFilterExDFN(HWND hWnd, UINT message, DWORD action, PCHANGEFILTERSTRUCT pChangeFilterStruct);
110 HMODULE hUser = ::LoadLibrary(_T("user32.dll"));
111 if (hUser)
113 ChangeWindowMessageFilterExDFN *pfnChangeWindowMessageFilterEx = (ChangeWindowMessageFilterExDFN*)GetProcAddress(hUser, "ChangeWindowMessageFilterEx");
114 if (pfnChangeWindowMessageFilterEx)
116 pfnChangeWindowMessageFilterEx(m_hWnd, WM_TASKBARBTNCREATED, MSGFLT_ALLOW, &cfs);
118 FreeLibrary(hUser);
120 m_pTaskbarList.Release();
121 m_pTaskbarList.CoCreateInstance(CLSID_TaskbarList);
123 CRect rectDummy;
125 GetClientRect(m_DlgOrigRect);
126 m_cList.GetClientRect(m_PatchListOrigRect);
128 CWnd *pwnd=this->GetDlgItem(IDC_AM_DUMY_TAB);
129 pwnd->GetWindowRect(&rectDummy);
130 this->ScreenToClient(rectDummy);
132 if (!m_ctrlTabCtrl.Create(CMFCTabCtrl::STYLE_FLAT, rectDummy, this, IDC_AM_TAB))
134 TRACE0("Failed to create output tab window\n");
135 return FALSE; // fail to create
137 m_ctrlTabCtrl.SetResizeMode(CMFCTabCtrl::RESIZE_NO);
138 // Create output panes:
139 //const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL;
140 DWORD dwStyle =LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP |LVS_SINGLESEL |WS_CHILD | WS_VISIBLE;
142 if( ! this->m_PatchCtrl.Create(_T("Scintilla"),_T("source"),0,rectDummy,&m_ctrlTabCtrl,0,0) )
144 TRACE0("Failed to create log message control");
145 return FALSE;
147 m_PatchCtrl.Init(0);
148 m_PatchCtrl.Call(SCI_SETREADONLY, TRUE);
149 m_PatchCtrl.SetUDiffStyle();
151 dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL;
153 if (!m_wndOutput.Create(_T("Scintilla"),_T("source"),0,rectDummy, &m_ctrlTabCtrl, 0,0) )
155 TRACE0("Failed to create output windows\n");
156 return -1; // fail to create
158 m_wndOutput.Init(0);
159 m_wndOutput.Call(SCI_SETREADONLY, TRUE);
161 m_tooltips.Create(this);
163 m_tooltips.AddTool(IDC_CHECK_3WAY,IDS_AM_3WAY_TT);
164 m_tooltips.AddTool(IDC_CHECK_IGNORE_SPACE,IDS_AM_IGNORE_SPACE_TT);
166 m_ctrlTabCtrl.AddTab(&m_PatchCtrl,_T("Patch"),0);
167 m_ctrlTabCtrl.AddTab(&m_wndOutput,_T("Log"),1);
169 AddAmAnchor();
171 m_PathList.SortByPathname(true);
172 m_cList.SetExtendedStyle( m_cList.GetExtendedStyle()| LVS_EX_CHECKBOXES );
174 for(int i=0;i<m_PathList.GetCount();i++)
176 m_cList.InsertItem(0,m_PathList[i].GetWinPath());
177 m_cList.SetCheck(0,true);
180 DWORD yPos = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\AMDlgSizer"));
181 RECT rcDlg, rcLogMsg, rcFileList;
182 GetClientRect(&rcDlg);
183 m_cList.GetWindowRect(&rcLogMsg);
184 ScreenToClient(&rcLogMsg);
185 this->m_ctrlTabCtrl.GetWindowRect(&rcFileList);
186 ScreenToClient(&rcFileList);
187 if (yPos)
189 RECT rectSplitter;
190 m_wndSplitter.GetWindowRect(&rectSplitter);
191 ScreenToClient(&rectSplitter);
192 int delta = yPos - rectSplitter.top;
193 if ((rcLogMsg.bottom + delta > rcLogMsg.top)&&(rcLogMsg.bottom + delta < rcFileList.bottom - 30))
195 m_wndSplitter.SetWindowPos(NULL, 0, yPos, 0, 0, SWP_NOSIZE);
196 DoSize(delta);
200 //CAppUtils::SetListCtrlBackgroundImage(m_cList.GetSafeHwnd(), nID);
202 CString title;
203 this->GetWindowText(title);
204 this->SetWindowText(title+_T(" - ")+g_Git.m_CurrentDir);
205 EnableSaveRestore(_T("ImportDlg"));
207 SetSplitterRange();
209 return TRUE;
212 BEGIN_MESSAGE_MAP(CImportPatchDlg, CResizableStandAloneDialog)
213 ON_LBN_SELCHANGE(IDC_LIST_PATCH, &CImportPatchDlg::OnLbnSelchangeListPatch)
214 ON_BN_CLICKED(IDC_BUTTON_ADD, &CImportPatchDlg::OnBnClickedButtonAdd)
215 ON_BN_CLICKED(IDC_BUTTON_UP, &CImportPatchDlg::OnBnClickedButtonUp)
216 ON_BN_CLICKED(IDC_BUTTON_DOWN, &CImportPatchDlg::OnBnClickedButtonDown)
217 ON_BN_CLICKED(IDC_BUTTON_REMOVE, &CImportPatchDlg::OnBnClickedButtonRemove)
218 ON_BN_CLICKED(IDOK, &CImportPatchDlg::OnBnClickedOk)
219 ON_WM_SIZE()
220 ON_BN_CLICKED(IDCANCEL, &CImportPatchDlg::OnBnClickedCancel)
221 ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST_PATCH, &CImportPatchDlg::OnHdnItemchangedListPatch)
222 ON_REGISTERED_MESSAGE(WM_TASKBARBTNCREATED, OnTaskbarBtnCreated)
223 END_MESSAGE_MAP()
226 // CImportPatchDlg message handlers
228 void CImportPatchDlg::OnLbnSelchangeListPatch()
230 if(m_cList.GetSelectedCount() == 0)
232 this->GetDlgItem(IDC_BUTTON_UP)->EnableWindow(FALSE);
233 this->GetDlgItem(IDC_BUTTON_DOWN)->EnableWindow(FALSE);
234 this->GetDlgItem(IDC_BUTTON_REMOVE)->EnableWindow(FALSE);
235 }else
237 this->GetDlgItem(IDC_BUTTON_UP)->EnableWindow(TRUE);
238 this->GetDlgItem(IDC_BUTTON_DOWN)->EnableWindow(TRUE);
239 this->GetDlgItem(IDC_BUTTON_REMOVE)->EnableWindow(TRUE);
243 void CImportPatchDlg::OnBnClickedButtonAdd()
245 CFileDialog dlg(TRUE,NULL,
246 NULL,
247 OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT,
248 _T("Patch Files(*.patch)|*.patch|Diff Files(*.diff)|*.diff|All Files(*.*)|*.*||"));
249 if(dlg.DoModal()==IDOK)
251 POSITION pos;
252 pos=dlg.GetStartPosition();
253 while(pos)
255 CString file=dlg.GetNextPathName(pos);
256 file.Trim();
257 if(!file.IsEmpty())
259 m_cList.InsertItem(0,file);
260 m_cList.SetCheck(0,true);
266 void CImportPatchDlg::OnBnClickedButtonUp()
268 POSITION pos;
269 pos=m_cList.GetFirstSelectedItemPosition();
270 while(pos)
272 int index=m_cList.GetNextSelectedItem(pos);
273 if(index>1)
275 CString old=m_cList.GetItemText(index,0);
276 m_cList.DeleteItem(index);
278 m_cList.InsertItem(index-1,old);
284 void CImportPatchDlg::OnBnClickedButtonDown()
286 POSITION pos;
287 pos=m_cList.GetFirstSelectedItemPosition();
288 while(pos)
290 int index=m_cList.GetNextSelectedItem(pos);
292 CString old=m_cList.GetItemText(index,0);
293 m_cList.DeleteItem(index);
295 m_cList.InsertItem(index+1,old);
300 void CImportPatchDlg::OnBnClickedButtonRemove()
302 POSITION pos;
303 pos=m_cList.GetFirstSelectedItemPosition();
304 while(pos)
306 int index=m_cList.GetNextSelectedItem(pos);
307 m_cList.DeleteItem(index);
308 pos=m_cList.GetFirstSelectedItemPosition();
312 UINT CImportPatchDlg::PatchThread()
314 CTGitPath path;
315 path.SetFromWin(g_Git.m_CurrentDir);
317 int i=0;
319 for(i=m_CurrentItem;i<m_cList.GetItemCount();i++)
321 if (m_pTaskbarList)
323 m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NORMAL);
324 m_pTaskbarList->SetProgressValue(m_hWnd, i+1, m_cList.GetItemCount());
327 m_cList.SetItemData(i, CPatchListCtrl::STATUS_APPLYING|m_cList.GetItemData(i));
329 if(m_bExitThread)
330 break;
332 if(m_cList.GetCheck(i))
334 CString cmd;
336 while(path.HasRebaseApply())
338 if (m_pTaskbarList)
339 m_pTaskbarList->SetProgressState(m_hWnd, TBPF_ERROR);
341 int ret = CMessageBox::Show(NULL, _T("<ct=0x0000FF>previous rebase directory rebase-apply still exists but mbox given</ct>\n\n Do you want to"),
342 _T("TortoiseGit"),
343 1,IDI_ERROR ,_T("&Abort"), _T("&Skip"),_T("&Resolved"));
345 switch(ret)
347 case 1:
348 cmd=_T("git.exe am --abort");
349 break;
350 case 2:
351 cmd=_T("git.exe am --skip");
352 i++;
353 break;
354 case 3:
355 cmd=_T("git.exe am --resolved");
356 break;
357 default:
358 cmd.Empty();
360 if(cmd.IsEmpty())
362 m_bExitThread = TRUE;
363 break;
366 this->AddLogString(cmd);
367 CString output;
368 if(g_Git.Run(cmd,&output,CP_ACP))
370 this->AddLogString(output);
371 this->AddLogString(_T("Fail"));
372 }else
374 this->AddLogString(_T("Done"));
378 if(m_bExitThread)
379 break;
381 cmd=_T("git.exe am ");
383 if(this->m_bAddSignedOffBy)
384 cmd+=_T("--signoff ");
386 if(this->m_b3Way)
387 cmd+=_T("--3way ");
389 if(this->m_bIgnoreSpace)
390 cmd+=_T("--ignore-space-change ");
392 if(this->m_bKeepCR)
393 cmd+=_T("--keep-cr ");
395 cmd +=_T("\"");
396 cmd += m_cList.GetItemText(i,0);
397 cmd +=_T("\"");
399 this->AddLogString(cmd);
400 CString output;
401 if(g_Git.Run(cmd,&output,CP_ACP))
403 //keep STATUS_APPLYING to let user retry failed patch
404 m_cList.SetItemData(i, CPatchListCtrl::STATUS_APPLY_FAIL|CPatchListCtrl::STATUS_APPLYING);
405 this->AddLogString(output);
406 this->AddLogString(_T("Fail"));
407 if (m_pTaskbarList)
408 m_pTaskbarList->SetProgressState(m_hWnd, TBPF_ERROR);
409 break;
411 }else
413 m_cList.SetItemData(i, CPatchListCtrl::STATUS_APPLY_SUCCESS);
414 this->AddLogString(_T("Success"));
417 }else
419 AddLogString(CString(_T("Skip Patch: "))+m_cList.GetItemText(i,0));
420 m_cList.SetItemData(i, CPatchListCtrl::STATUS_APPLY_SKIP);
423 m_cList.SetItemData(m_CurrentItem, (~CPatchListCtrl::STATUS_APPLYING)&m_cList.GetItemData(i));
424 m_CurrentItem++;
425 m_cList.SetItemData(m_CurrentItem, CPatchListCtrl::STATUS_APPLYING|m_cList.GetItemData(i));
427 CRect rect;
428 this->m_cList.GetItemRect(i,&rect,LVIR_BOUNDS);
429 this->m_cList.InvalidateRect(rect);
431 this->m_cList.GetItemRect(m_CurrentItem,&rect,LVIR_BOUNDS);
432 this->m_cList.InvalidateRect(rect);
434 if (m_pTaskbarList)
435 m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NOPROGRESS);
437 UpdateOkCancelText();
440 //in case am fail, need refresh finial item status
441 CRect rect;
442 this->m_cList.GetItemRect(i,&rect,LVIR_BOUNDS);
443 this->m_cList.InvalidateRect(rect);
445 this->m_cList.GetItemRect(m_CurrentItem,&rect,LVIR_BOUNDS);
446 this->m_cList.InvalidateRect(rect);
448 EnableInputCtrl(true);
449 InterlockedExchange(&m_bThreadRunning, FALSE);
450 UpdateOkCancelText();
451 return 0;
454 void CImportPatchDlg::OnBnClickedOk()
456 m_PathList.Clear();
457 this->UpdateData();
459 SaveSplitterPos();
461 if(IsFinish())
463 this->OnOK();
464 return;
467 m_ctrlTabCtrl.SetActiveTab(1);
469 EnableInputCtrl(false);
470 InterlockedExchange(&m_bThreadRunning, TRUE);
471 InterlockedExchange(&this->m_bExitThread, FALSE);
472 if ( (m_LoadingThread=AfxBeginThread(ThreadEntry, this)) ==NULL)
474 InterlockedExchange(&m_bThreadRunning, FALSE);
475 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
480 void CImportPatchDlg::DoSize(int delta)
482 this->RemoveAllAnchors();
484 CSplitterControl::ChangeHeight(GetDlgItem(IDC_LIST_PATCH), delta, CW_TOPALIGN);
485 //CSplitterControl::ChangeHeight(GetDlgItem(), delta, CW_TOPALIGN);
486 CSplitterControl::ChangeHeight(GetDlgItem(IDC_AM_TAB), -delta, CW_BOTTOMALIGN);
487 //CSplitterControl::ChangeHeight(GetDlgItem(), -delta, CW_BOTTOMALIGN);
488 CSplitterControl::ChangePos(GetDlgItem(IDC_CHECK_3WAY),0,delta);
489 CSplitterControl::ChangePos(GetDlgItem(IDC_CHECK_IGNORE_SPACE),0,delta);
490 CSplitterControl::ChangePos(GetDlgItem(IDC_SIGN_OFF),0,delta);
492 this->AddAmAnchor();
493 // adjust the minimum size of the dialog to prevent the resizing from
494 // moving the list control too far down.
495 CRect rcLogMsg;
496 m_cList.GetClientRect(rcLogMsg);
497 SetMinTrackSize(CSize(m_DlgOrigRect.Width(), m_DlgOrigRect.Height()-m_PatchListOrigRect.Height()+rcLogMsg.Height()));
499 SetSplitterRange();
500 // m_CommitList.Invalidate();
502 // GetDlgItem(IDC_LOGMESSAGE)->Invalidate();
504 this->m_ctrlTabCtrl.Invalidate();
507 void CImportPatchDlg::OnSize(UINT nType, int cx, int cy)
509 CResizableStandAloneDialog::OnSize(nType, cx, cy);
511 SetSplitterRange();
514 LRESULT CImportPatchDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
516 switch (message) {
517 case WM_NOTIFY:
518 if (wParam == IDC_AM_SPLIT)
520 SPC_NMHDR* pHdr = (SPC_NMHDR*) lParam;
521 DoSize(pHdr->delta);
523 break;
526 return CResizableStandAloneDialog::DefWindowProc(message, wParam, lParam);
529 void CImportPatchDlg::SaveSplitterPos()
531 if (!IsIconic())
533 CRegDWORD regPos = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\AMDlgSizer"));
534 RECT rectSplitter;
535 m_wndSplitter.GetWindowRect(&rectSplitter);
536 ScreenToClient(&rectSplitter);
537 regPos = rectSplitter.top;
543 void CImportPatchDlg::EnableInputCtrl(BOOL b)
545 this->GetDlgItem(IDC_BUTTON_UP)->EnableWindow(b);
546 this->GetDlgItem(IDC_BUTTON_DOWN)->EnableWindow(b);
547 this->GetDlgItem(IDC_BUTTON_REMOVE)->EnableWindow(b);
548 this->GetDlgItem(IDC_BUTTON_ADD)->EnableWindow(b);
549 this->GetDlgItem(IDOK)->EnableWindow(b);
552 void CImportPatchDlg::UpdateOkCancelText()
554 if( !IsFinish() )
556 this->GetDlgItem(IDOK)->SetWindowText(_T("&Apply"));
558 else
560 this->GetDlgItem(IDOK)->SetWindowText(_T("&OK"));
563 if(this->m_bThreadRunning)
564 this->GetDlgItem(IDCANCEL)->SetWindowText(_T("A&bort"));
565 else
566 this->GetDlgItem(IDCANCEL)->SetWindowText(_T("&Cancel"));
569 void CImportPatchDlg::OnBnClickedCancel()
571 if(this->m_bThreadRunning)
573 InterlockedExchange(&m_bExitThread,TRUE);
574 }else
575 OnCancel();
578 void CImportPatchDlg::AddLogString(CString str)
580 this->m_wndOutput.SendMessage(SCI_SETREADONLY, FALSE);
581 CStringA sTextA = m_wndOutput.StringForControl(str);//CUnicodeUtils::GetUTF8(str);
582 this->m_wndOutput.SendMessage(SCI_REPLACESEL, 0, (LPARAM)(LPCSTR)sTextA);
583 this->m_wndOutput.SendMessage(SCI_REPLACESEL, 0, (LPARAM)(LPCSTR)"\n");
584 this->m_wndOutput.SendMessage(SCI_SETREADONLY, TRUE);
585 //this->m_wndOutput.SendMessage(SCI_LINESCROLL,0,0x7FFFFFFF);
587 BOOL CImportPatchDlg::PreTranslateMessage(MSG* pMsg)
589 if (pMsg->message == WM_KEYDOWN)
591 switch (pMsg->wParam)
594 /* Avoid TAB control destroy but dialog exist*/
595 case VK_ESCAPE:
596 case VK_CANCEL:
598 TCHAR buff[128];
599 ::GetClassName(pMsg->hwnd,buff,128);
601 if(_tcsnicmp(buff,_T("RichEdit20W"),128)==0 ||
602 _tcsnicmp(buff,_T("Scintilla"),128)==0 ||
603 _tcsnicmp(buff,_T("SysListView32"),128)==0||
604 ::GetParent(pMsg->hwnd) == this->m_ctrlTabCtrl.m_hWnd)
606 this->PostMessage(WM_KEYDOWN,VK_ESCAPE,0);
607 return TRUE;
612 m_tooltips.RelayEvent(pMsg);
613 return CResizableStandAloneDialog::PreTranslateMessage(pMsg);
616 void CImportPatchDlg::OnHdnItemchangedListPatch(NMHDR * /*pNMHDR*/, LRESULT *pResult)
618 *pResult = 0;
620 if(this->m_cList.GetSelectedCount() != 1)
622 m_PatchCtrl.SendMessage(SCI_SETREADONLY, FALSE);
623 m_PatchCtrl.SetText(CString());
624 m_PatchCtrl.SendMessage(SCI_SETREADONLY, TRUE);
625 }else
627 CString text;
629 POSITION pos;
630 pos = m_cList.GetFirstSelectedItemPosition();
631 int selected = m_cList.GetNextSelectedItem(pos);
633 if(selected>=0&& selected< m_cList.GetItemCount())
635 CString str = m_cList.GetItemText(selected,0);
636 m_PatchCtrl.SendMessage(SCI_SETREADONLY, FALSE);
637 m_PatchCtrl.SetText(text);
638 m_PatchCtrl.LoadFromFile(str);
639 m_PatchCtrl.SendMessage(SCI_SETREADONLY, TRUE);
641 }else
643 m_PatchCtrl.SendMessage(SCI_SETREADONLY, FALSE);
644 m_PatchCtrl.SetText(text);
645 m_PatchCtrl.SendMessage(SCI_SETREADONLY, TRUE);
650 LRESULT CImportPatchDlg::OnTaskbarBtnCreated(WPARAM /*wParam*/, LPARAM /*lParam*/)
652 m_pTaskbarList.Release();
653 m_pTaskbarList.CoCreateInstance(CLSID_TaskbarList);
654 return 0;