Skip to main content

Featured

Build docker image from multiple build contexts

Build docker image from multiple build contexts Building a docker image requires specifying a source of truth to include in the image from a local directory or a remote git repository. In the previous version, the docker BuildKit allows users to specify the build context from a single source of truth only. However, the engineers may need to have the context from different locations based on the type of files. For instance, icons, images or other resources that are not included in the same package, including the resource from other docker images. Fortunately, the Docker Buildx toolkit supports multiple build context flag for Docker 1.4. Let's learn how to use this new feature. The following list is a shortcut for jumping into a specific topic handy. What version of Docker is this tutorial targeting? How to specify the version of Dockerfile frontend? Ho

[CListCtrl]排序Contorl List內之資料

這邊以檔案清單來說明,需要的欄位有:檔案名稱、副檔名、檔案路徑。

首先先建立用來排序用的資料結構

typedef struct {
    char pszFileName[_MAX_FNAME];
    char pszExtName[_MAX_EXT];
    char pszFilePath[MAX_PATH];
} ITEMDATA, *PITEMDATA; 


再來建立給CListCtrl::SortItems()使用的Call back函式,函式內部就放需要用來sort比對的方法
Head File

friend int CALLBACK SortFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);

Cpp File

int CALLBACK SortFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
    int nRetVal = 0;

    PITEMDATA pData1 = (PITEMDATA)lParam1;
    PITEMDATA pData2 = (PITEMDATA)lParam2;

    switch(lParamSort)
    {
    case 0:    // File Name
        nRetVal = strcmp(pData1->pszFileName, pData2->pszFileName);
        break;

    case 1:    // Extension File Name
        nRetVal = strcmp(pData1->pszExtName, pData2->pszExtName);
        break;

    case 2: // TerFile Path
        nRetVal = strcmp(pData1->pszFilePath, pData2->pszFilePath);
        break;

    default:
        break;
    }

    return nRetVal;
}


再來是建立接收到滑鼠事件後需要執行的函式,在函式內就把先前建立好的Call back函式,SortFunc塞給CListCtrl::SortItems()。
Head File

afx_msg void OnItemClick2Sort(NMHDR* pNMHDR, LRESULT* pResult);

Cpp File

void CFileSearchDlg::OnItemClick2Sort(NMHDR* pNMHDR, LRESULT* pResult)
{
    NMLISTVIEW *pLV = (NMLISTVIEW *) pNMHDR;
    
    m_lstFileItem.SortItems(SortFunc, pLV->iSubItem);

    *pResult = 0;
}



然後在message map鍵入

ON_NOTIFY(LVN_COLUMNCLICK, IDC_LST_FILE, OnItemClick2Sort)

來接收滑鼠點選List的欄位標題時的訊息。

以上動作完成後,就可以利用點擊欄位標題來進行排序了。

Comments

Popular Posts