MCPcopy Create free account
hub / github.com/ajkhoury/ReClassEx / CompareFunction

Method CompareFunction

ReClass/DialogModules.cpp:229–277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227}
228
229int CALLBACK CDialogModules::CompareFunction( LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort )
230{
231 LPCOMPARESTRUCT Compare = (LPCOMPARESTRUCT)lParamSort;
232 if (Compare)
233 {
234 CListCtrl* pListCtrl = (CListCtrl*)Compare->pListCtrl;
235 int column = Compare->iColumn;
236 bool ascending = Compare->bAscending;
237
238 int item1 = ascending ? static_cast<int>(lParam1) : static_cast<int>(lParam2);
239 int item2 = ascending ? static_cast<int>(lParam2) : static_cast<int>(lParam1);
240
241 if (column == COLUMN_START || column == COLUMN_END || column == COLUMN_SIZE)
242 {
243 CString strValue1 = pListCtrl->GetItemText( item1, column );
244 CString strValue2 = pListCtrl->GetItemText( item2, column );
245
246 size_t value1 = (size_t)_tcstoui64( strValue1.GetBuffer( ), NULL, 16 );
247 size_t value2 = (size_t)_tcstoui64( strValue2.GetBuffer( ), NULL, 16 );
248
249 return (int)(value2 - value1);
250 }
251 else if (column == COLUMN_NAME)
252 {
253 CString strModuleName1 = pListCtrl->GetItemText( item1, column );
254 CString strModuleName2 = pListCtrl->GetItemText( item2, column );
255
256 return _tcsicmp( strModuleName1.GetBuffer( ), strModuleName2.GetBuffer( ) );
257 }
258 else if (column == COLUMN_PATH)
259 {
260 CString strModulePath1 = pListCtrl->GetItemText( item1, column );
261 CString strModulePath2 = pListCtrl->GetItemText( item2, column );
262
263 int idxSlash1 = strModulePath1.ReverseFind( _T( '\\' ) );
264 if (!idxSlash1)
265 idxSlash1 = strModulePath1.ReverseFind( _T( '/' ) );
266 CString strModuleFile1 = strModulePath1.Mid( ++idxSlash1 );
267
268 int idxSlash2 = strModulePath2.ReverseFind( _T( '\\' ) );
269 if (!idxSlash2)
270 idxSlash2 = strModulePath2.ReverseFind( _T( '/' ) );
271 CString strModuleFile2 = strModulePath2.Mid( ++idxSlash2 );
272
273 return _tcsicmp( strModuleFile1.GetBuffer( ), strModuleFile2.GetBuffer( ) );
274 }
275 }
276 return 0;
277}
278
279void CDialogModules::OnColumnClick( NMHDR* pNMHDR, LRESULT* pResult )
280{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected