GME  13
SyncAspListCtrl.cpp
Go to the documentation of this file.
00001 // SyncAspListCtrl.cpp : implementation file
00002 //
00003 
00004 #include "stdafx.h"
00005 #include "GMEApp.h"
00006 #include "SyncAspListCtrl.h"
00007 #include "GMEstd.h"
00008 #include "GuiMeta.h"
00009 
00010 #ifdef _DEBUG
00011 #define new DEBUG_NEW
00012 #undef THIS_FILE
00013 static char THIS_FILE[] = __FILE__;
00014 #endif
00015 
00017 // CSyncAspListCtrl
00018 
00019 bool CSyncAspListCtrl::isAscending[] = {true};
00020 
00021 CSyncAspListCtrl::CSyncAspListCtrl()
00022 {
00023 }
00024 
00025 CSyncAspListCtrl::~CSyncAspListCtrl()
00026 {
00027 }
00028 
00029 
00030 BEGIN_MESSAGE_MAP(CSyncAspListCtrl, CListCtrl)
00031         //{{AFX_MSG_MAP(CSyncAspListCtrl)
00032         ON_NOTIFY_REFLECT(LVN_COLUMNCLICK, OnColumnclick)
00033         //}}AFX_MSG_MAP
00034 END_MESSAGE_MAP()
00035 
00037 // CSyncAspListCtrl message handlers
00038 
00039 void CSyncAspListCtrl::OnColumnclick(NMHDR* pNMHDR, LRESULT* pResult) 
00040 {
00041         NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
00042         
00043         SortItems(AspectCompare, pNMListView->iSubItem);
00044         
00045         *pResult = 0;
00046 }
00047 
00048 int CALLBACK CSyncAspListCtrl::AspectCompare(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
00049 {
00050         CGuiMetaAspect* pItem1 = (CGuiMetaAspect*) lParam1;
00051         CGuiMetaAspect* pItem2 = (CGuiMetaAspect*) lParam2;
00052         int nResult = 0;
00053 
00054         switch (lParamSort) {
00055 
00056         case 0: // Aspect name.
00057                 nResult = (isAscending[0] ? 1 : -1) * pItem1->name.CompareNoCase(pItem2->name);
00058                 isAscending[0] = !isAscending[0];
00059                 break;
00060         }
00061         return nResult;
00062 }