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
23 #include "TortoiseProc.h"
24 #include "ImportPatchDlg.h"
26 #include "MessageBox.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
);
40 m_bExitThread
= false;
41 m_bThreadRunning
=false;
45 m_bAddSignedOffBy
= FALSE
;
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
))
89 m_cList
.GetWindowRect(rcTop
);
90 ScreenToClient(rcTop
);
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"));
113 ChangeWindowMessageFilterExDFN
*pfnChangeWindowMessageFilterEx
= (ChangeWindowMessageFilterExDFN
*)GetProcAddress(hUser
, "ChangeWindowMessageFilterEx");
114 if (pfnChangeWindowMessageFilterEx
)
116 pfnChangeWindowMessageFilterEx(m_hWnd
, WM_TASKBARBTNCREATED
, MSGFLT_ALLOW
, &cfs
);
120 m_pTaskbarList
.Release();
121 m_pTaskbarList
.CoCreateInstance(CLSID_TaskbarList
);
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");
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
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);
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
);
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
);
200 CAppUtils::SetListCtrlBackgroundImage(m_cList
.GetSafeHwnd(), IDI_IMPORTPATHCES_BKG
);
202 CString sWindowTitle
;
203 GetWindowText(sWindowTitle
);
204 CAppUtils::SetWindowTitle(m_hWnd
, g_Git
.m_CurrentDir
, sWindowTitle
);
206 EnableSaveRestore(_T("ImportDlg"));
213 BEGIN_MESSAGE_MAP(CImportPatchDlg
, CResizableStandAloneDialog
)
214 ON_LBN_SELCHANGE(IDC_LIST_PATCH
, &CImportPatchDlg::OnLbnSelchangeListPatch
)
215 ON_BN_CLICKED(IDC_BUTTON_ADD
, &CImportPatchDlg::OnBnClickedButtonAdd
)
216 ON_BN_CLICKED(IDC_BUTTON_UP
, &CImportPatchDlg::OnBnClickedButtonUp
)
217 ON_BN_CLICKED(IDC_BUTTON_DOWN
, &CImportPatchDlg::OnBnClickedButtonDown
)
218 ON_BN_CLICKED(IDC_BUTTON_REMOVE
, &CImportPatchDlg::OnBnClickedButtonRemove
)
219 ON_BN_CLICKED(IDOK
, &CImportPatchDlg::OnBnClickedOk
)
221 ON_BN_CLICKED(IDCANCEL
, &CImportPatchDlg::OnBnClickedCancel
)
222 ON_NOTIFY(LVN_ITEMCHANGED
, IDC_LIST_PATCH
, &CImportPatchDlg::OnHdnItemchangedListPatch
)
223 ON_REGISTERED_MESSAGE(WM_TASKBARBTNCREATED
, OnTaskbarBtnCreated
)
227 // CImportPatchDlg message handlers
229 void CImportPatchDlg::OnLbnSelchangeListPatch()
231 if(m_cList
.GetSelectedCount() == 0)
233 this->GetDlgItem(IDC_BUTTON_UP
)->EnableWindow(FALSE
);
234 this->GetDlgItem(IDC_BUTTON_DOWN
)->EnableWindow(FALSE
);
235 this->GetDlgItem(IDC_BUTTON_REMOVE
)->EnableWindow(FALSE
);
239 this->GetDlgItem(IDC_BUTTON_UP
)->EnableWindow(TRUE
);
240 this->GetDlgItem(IDC_BUTTON_DOWN
)->EnableWindow(TRUE
);
241 this->GetDlgItem(IDC_BUTTON_REMOVE
)->EnableWindow(TRUE
);
245 void CImportPatchDlg::OnBnClickedButtonAdd()
247 CFileDialog
dlg(TRUE
,NULL
,
249 OFN_HIDEREADONLY
| OFN_OVERWRITEPROMPT
|OFN_ALLOWMULTISELECT
,
250 _T("Patch Files(*.patch)|*.patch|Diff Files(*.diff)|*.diff|All Files(*.*)|*.*||"));
251 if(dlg
.DoModal() == IDOK
)
254 pos
= dlg
.GetStartPosition();
257 CString file
= dlg
.GetNextPathName(pos
);
261 int index
= m_cList
.InsertItem(m_cList
.GetItemCount(), file
);
263 m_cList
.SetCheck(index
, true);
269 void CImportPatchDlg::OnBnClickedButtonUp()
272 pos
= m_cList
.GetFirstSelectedItemPosition();
274 // do nothing if the first selected item is the first item in the list
275 if (m_cList
.GetNextSelectedItem(pos
) == 0)
278 pos
= m_cList
.GetFirstSelectedItemPosition();
282 int index
= m_cList
.GetNextSelectedItem(pos
);
285 CString old
= m_cList
.GetItemText(index
, 0);
286 BOOL oldState
= m_cList
.GetCheck(index
);
287 m_cList
.DeleteItem(index
);
288 m_cList
.InsertItem(index
- 1, old
);
289 m_cList
.SetCheck(index
- 1, oldState
);
290 m_cList
.SetItemState(index
- 1, LVIS_SELECTED
, LVIS_SELECTED
);
291 m_cList
.SetItemState(index
, 0, LVIS_SELECTED
);
297 void CImportPatchDlg::OnBnClickedButtonDown()
299 if (m_cList
.GetSelectedCount() == 0)
303 pos
= m_cList
.GetFirstSelectedItemPosition();
304 // use an array to store all selected item indexes; the user won't select too much items
306 indexes
= new int[m_cList
.GetSelectedCount()];
310 indexes
[i
++] = m_cList
.GetNextSelectedItem(pos
);
313 // don't move any item if the last selected item is the last item in the m_CommitList
314 // (that would change the order of the selected items)
315 if(indexes
[m_cList
.GetSelectedCount() - 1] < m_cList
.GetItemCount() - 1)
317 // iterate over the indexes backwards in order to correctly move multiselected items
318 for (i
= m_cList
.GetSelectedCount() - 1; i
>= 0; i
--)
320 int index
= indexes
[i
];
321 CString old
= m_cList
.GetItemText(index
, 0);
322 BOOL oldState
= m_cList
.GetCheck(index
);
323 m_cList
.DeleteItem(index
);
324 m_cList
.InsertItem(index
+ 1, old
);
325 m_cList
.SetCheck(index
+ 1, oldState
);
326 m_cList
.SetItemState(index
+ 1, LVIS_SELECTED
, LVIS_SELECTED
);
327 m_cList
.SetItemState(index
, 0, LVIS_SELECTED
);
334 void CImportPatchDlg::OnBnClickedButtonRemove()
337 pos
= m_cList
.GetFirstSelectedItemPosition();
340 int index
= m_cList
.GetNextSelectedItem(pos
);
341 m_cList
.DeleteItem(index
);
342 pos
= m_cList
.GetFirstSelectedItemPosition();
346 UINT
CImportPatchDlg::PatchThread()
349 path
.SetFromWin(g_Git
.m_CurrentDir
);
352 UpdateOkCancelText();
353 for(i
=m_CurrentItem
;i
<m_cList
.GetItemCount();i
++)
357 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_NORMAL
);
358 m_pTaskbarList
->SetProgressValue(m_hWnd
, i
, m_cList
.GetItemCount());
361 m_cList
.SetItemData(i
, CPatchListCtrl::STATUS_APPLYING
|m_cList
.GetItemData(i
));
364 this->m_cList
.GetItemRect(i
,&rect
,LVIR_BOUNDS
);
365 this->m_cList
.InvalidateRect(rect
);
370 if(m_cList
.GetCheck(i
))
374 while(path
.HasRebaseApply())
377 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_ERROR
);
379 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"),
381 1,IDI_ERROR
,_T("&Abort"), _T("&Skip"),_T("&Resolved"));
386 cmd
= _T("git.exe am --abort");
389 cmd
= _T("git.exe am --skip");
393 cmd
= _T("git.exe am --resolved");
400 m_bExitThread
= TRUE
;
404 this->AddLogString(cmd
);
406 if(g_Git
.Run(cmd
, &output
, CP_ACP
))
408 this->AddLogString(output
);
409 this->AddLogString(_T("Fail"));
413 this->AddLogString(_T("Done"));
420 cmd
= _T("git.exe am ");
422 if(this->m_bAddSignedOffBy
)
423 cmd
+= _T("--signoff ");
426 cmd
+= _T("--3way ");
428 if(this->m_bIgnoreSpace
)
429 cmd
+= _T("--ignore-space-change ");
432 cmd
+= _T("--keep-cr ");
435 cmd
+= m_cList
.GetItemText(i
,0);
438 this->AddLogString(cmd
);
440 if(g_Git
.Run(cmd
,&output
,CP_ACP
))
442 //keep STATUS_APPLYING to let user retry failed patch
443 m_cList
.SetItemData(i
, CPatchListCtrl::STATUS_APPLY_FAIL
|CPatchListCtrl::STATUS_APPLYING
);
444 this->AddLogString(output
);
445 this->AddLogString(_T("Fail"));
447 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_ERROR
);
453 m_cList
.SetItemData(i
, CPatchListCtrl::STATUS_APPLY_SUCCESS
);
454 this->AddLogString(_T("Success"));
460 AddLogString(CString(_T("Skip Patch: "))+m_cList
.GetItemText(i
,0));
461 m_cList
.SetItemData(i
, CPatchListCtrl::STATUS_APPLY_SKIP
);
464 m_cList
.SetItemData(m_CurrentItem
, (~CPatchListCtrl::STATUS_APPLYING
)&m_cList
.GetItemData(i
));
467 this->m_cList
.GetItemRect(i
,&rect
,LVIR_BOUNDS
);
468 this->m_cList
.InvalidateRect(rect
);
470 UpdateOkCancelText();
473 //in case am fail, need refresh finial item status
475 this->m_cList
.GetItemRect(i
,&rect
,LVIR_BOUNDS
);
476 this->m_cList
.InvalidateRect(rect
);
478 this->m_cList
.GetItemRect(m_CurrentItem
,&rect
,LVIR_BOUNDS
);
479 this->m_cList
.InvalidateRect(rect
);
483 m_pTaskbarList
->SetProgressValue(m_hWnd
, m_CurrentItem
, m_cList
.GetItemCount());
484 if (m_bExitThread
&& m_CurrentItem
!= m_cList
.GetItemCount())
485 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_PAUSED
);
486 else if (!m_bExitThread
&& m_CurrentItem
== m_cList
.GetItemCount())
487 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_NORMAL
);
490 EnableInputCtrl(true);
491 InterlockedExchange(&m_bThreadRunning
, FALSE
);
492 UpdateOkCancelText();
496 void CImportPatchDlg::OnBnClickedOk()
509 m_ctrlTabCtrl
.SetActiveTab(1);
511 EnableInputCtrl(false);
512 InterlockedExchange(&m_bThreadRunning
, TRUE
);
513 InterlockedExchange(&this->m_bExitThread
, FALSE
);
514 if ( (m_LoadingThread
=AfxBeginThread(ThreadEntry
, this)) ==NULL
)
516 InterlockedExchange(&m_bThreadRunning
, FALSE
);
517 CMessageBox::Show(NULL
, IDS_ERR_THREADSTARTFAILED
, IDS_APPNAME
, MB_OK
| MB_ICONERROR
);
522 void CImportPatchDlg::DoSize(int delta
)
524 this->RemoveAllAnchors();
526 CSplitterControl::ChangeHeight(GetDlgItem(IDC_LIST_PATCH
), delta
, CW_TOPALIGN
);
527 //CSplitterControl::ChangeHeight(GetDlgItem(), delta, CW_TOPALIGN);
528 CSplitterControl::ChangeHeight(GetDlgItem(IDC_AM_TAB
), -delta
, CW_BOTTOMALIGN
);
529 //CSplitterControl::ChangeHeight(GetDlgItem(), -delta, CW_BOTTOMALIGN);
530 CSplitterControl::ChangePos(GetDlgItem(IDC_CHECK_3WAY
), 0, delta
);
531 CSplitterControl::ChangePos(GetDlgItem(IDC_CHECK_IGNORE_SPACE
), 0, delta
);
532 CSplitterControl::ChangePos(GetDlgItem(IDC_SIGN_OFF
), 0, delta
);
533 CSplitterControl::ChangePos(GetDlgItem(IDC_KEEP_CR
), 0, delta
);
536 // adjust the minimum size of the dialog to prevent the resizing from
537 // moving the list control too far down.
539 m_cList
.GetClientRect(rcLogMsg
);
540 SetMinTrackSize(CSize(m_DlgOrigRect
.Width(), m_DlgOrigRect
.Height()-m_PatchListOrigRect
.Height()+rcLogMsg
.Height()));
543 // m_CommitList.Invalidate();
545 // GetDlgItem(IDC_LOGMESSAGE)->Invalidate();
547 this->m_ctrlTabCtrl
.Invalidate();
550 void CImportPatchDlg::OnSize(UINT nType
, int cx
, int cy
)
552 CResizableStandAloneDialog::OnSize(nType
, cx
, cy
);
557 LRESULT
CImportPatchDlg::DefWindowProc(UINT message
, WPARAM wParam
, LPARAM lParam
)
561 if (wParam
== IDC_AM_SPLIT
)
563 SPC_NMHDR
* pHdr
= (SPC_NMHDR
*) lParam
;
569 return CResizableStandAloneDialog::DefWindowProc(message
, wParam
, lParam
);
572 void CImportPatchDlg::SaveSplitterPos()
576 CRegDWORD regPos
= CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\AMDlgSizer"));
578 m_wndSplitter
.GetWindowRect(&rectSplitter
);
579 ScreenToClient(&rectSplitter
);
580 regPos
= rectSplitter
.top
;
586 void CImportPatchDlg::EnableInputCtrl(BOOL b
)
588 this->GetDlgItem(IDC_BUTTON_UP
)->EnableWindow(b
);
589 this->GetDlgItem(IDC_BUTTON_DOWN
)->EnableWindow(b
);
590 this->GetDlgItem(IDC_BUTTON_REMOVE
)->EnableWindow(b
);
591 this->GetDlgItem(IDC_BUTTON_ADD
)->EnableWindow(b
);
592 this->GetDlgItem(IDOK
)->EnableWindow(b
);
595 void CImportPatchDlg::UpdateOkCancelText()
597 if (this->m_bThreadRunning
&& !IsFinish())
599 this->GetDlgItem(IDOK
)->EnableWindow(FALSE
);
600 this->GetDlgItem(IDCANCEL
)->SetWindowText(_T("A&bort"));
602 else if (!IsFinish())
604 this->GetDlgItem(IDOK
)->EnableWindow(TRUE
);
608 this->GetDlgItem(IDCANCEL
)->EnableWindow(FALSE
);
609 this->GetDlgItem(IDOK
)->SetWindowText(_T("&OK"));
612 void CImportPatchDlg::OnBnClickedCancel()
614 if(this->m_bThreadRunning
)
616 InterlockedExchange(&m_bExitThread
,TRUE
);
621 path
.SetFromWin(g_Git
.m_CurrentDir
);
622 if(path
.HasRebaseApply())
623 if(MessageBox(_T("\"git am\" is still in apply mode.\nDo you want to abort?"), _T("TortoiseGit"), MB_YESNO
| MB_ICONQUESTION
) == IDYES
)
626 if(g_Git
.Run(_T("git.exe am --abort"), &output
, CP_ACP
))
627 MessageBox(output
, _T("TortoiseGit error"), MB_OK
);
633 void CImportPatchDlg::AddLogString(CString str
)
635 this->m_wndOutput
.SendMessage(SCI_SETREADONLY
, FALSE
);
636 CStringA sTextA
= m_wndOutput
.StringForControl(str
);//CUnicodeUtils::GetUTF8(str);
637 this->m_wndOutput
.SendMessage(SCI_REPLACESEL
, 0, (LPARAM
)(LPCSTR
)sTextA
);
638 this->m_wndOutput
.SendMessage(SCI_REPLACESEL
, 0, (LPARAM
)(LPCSTR
)"\n");
639 this->m_wndOutput
.SendMessage(SCI_SETREADONLY
, TRUE
);
640 //this->m_wndOutput.SendMessage(SCI_LINESCROLL,0,0x7FFFFFFF);
642 BOOL
CImportPatchDlg::PreTranslateMessage(MSG
* pMsg
)
644 if (pMsg
->message
== WM_KEYDOWN
)
646 switch (pMsg
->wParam
)
649 /* Avoid TAB control destroy but dialog exist*/
654 ::GetClassName(pMsg
->hwnd
,buff
,128);
656 if(_tcsnicmp(buff
,_T("RichEdit20W"),128)==0 ||
657 _tcsnicmp(buff
,_T("Scintilla"),128)==0 ||
658 _tcsnicmp(buff
,_T("SysListView32"),128)==0||
659 ::GetParent(pMsg
->hwnd
) == this->m_ctrlTabCtrl
.m_hWnd
)
661 this->PostMessage(WM_KEYDOWN
,VK_ESCAPE
,0);
667 m_tooltips
.RelayEvent(pMsg
);
668 return CResizableStandAloneDialog::PreTranslateMessage(pMsg
);
671 void CImportPatchDlg::OnHdnItemchangedListPatch(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
675 if(this->m_cList
.GetSelectedCount() != 1)
677 m_PatchCtrl
.SendMessage(SCI_SETREADONLY
, FALSE
);
678 m_PatchCtrl
.SetText(CString());
679 m_PatchCtrl
.SendMessage(SCI_SETREADONLY
, TRUE
);
686 pos
= m_cList
.GetFirstSelectedItemPosition();
687 int selected
= m_cList
.GetNextSelectedItem(pos
);
689 if(selected
>=0&& selected
< m_cList
.GetItemCount())
691 CString str
= m_cList
.GetItemText(selected
,0);
692 m_PatchCtrl
.SendMessage(SCI_SETREADONLY
, FALSE
);
693 m_PatchCtrl
.SetText(text
);
694 m_PatchCtrl
.LoadFromFile(str
);
695 m_PatchCtrl
.SendMessage(SCI_SETREADONLY
, TRUE
);
700 m_PatchCtrl
.SendMessage(SCI_SETREADONLY
, FALSE
);
701 m_PatchCtrl
.SetText(text
);
702 m_PatchCtrl
.SendMessage(SCI_SETREADONLY
, TRUE
);
707 LRESULT
CImportPatchDlg::OnTaskbarBtnCreated(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
709 m_pTaskbarList
.Release();
710 m_pTaskbarList
.CoCreateInstance(CLSID_TaskbarList
);