I create .rc file where put my DialogBar. In section of this DialogBar i create CListViewCtrl.And fill it. Then i need to receive messages on SelectedItem. Please, give me some code, or links to read about my problem. Thank you. Here is my code of DialogBar, where i calling the function to create CListViewCtrl
#include <thread>
#include "resource.h"
#include "resource2.h"
#include "MyListView.h"
class MyDialogBar:public CDialogImpl<MyDialogBar>
{
public:
enum { IDD = IDD_MYDIALOGBAR };
BEGIN_MSG_MAP(MyDialogBar)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
MESSAGE_HANDLER(WM_COMMAND,OnCommand)
MESSAGE_HANDLER(WM_NOTIFY,OnLButtonDown)
MESSAGE_HANDLER(WM_CLOSE,OnCloseCmd)
END_MSG_MAP()
LRESULT OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
CString parameter = TEXT("C:\\Users\\Огурчик\\Desktop\\");
switch (wParam)
{
case IDC_BUTTON_EXIT:
OnCloseCmd(uMsg,wParam,lParam,bHandled);
return 0;
case IDC_BUTTON_APPLY:
ListView_DeleteAllItems(this->myListView.m_hWnd);
if (FindThread.joinable())
{
FindThread.detach();
FindThread = std::thread((&MyListView::FindFile),this->myListView, parameter);
}
else
{
FindThread = std::thread((&MyListView::FindFile), this->myListView, parameter);
}
return 0;
case IDC_SEARCH_TEXT_BAR :
GetDlgItemText(IDC_SEARCH_TEXT_BAR, FileName);
return 0;
case IDC_EXTENTION_TEXT_BAR:
GetDlgItemText(IDC_EXTENTION_TEXT_BAR, FileExtention);
return 0;
}
return 0;
}
LRESULT OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
switch (LOWORD(wParam))
{
case (int)LVN_ITEMCHANGED:
MessageBox(TEXT("U am here"), TEXT("Here"), NULL);
}
return 0;
}
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
myListView.Create(m_hWnd);
return 0;
}
LRESULT OnCloseCmd(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
if (FindThread.joinable())
{
FindThread.detach();
}
EndDialog(NULL);
return 0;
}
private:
CString FileName;
CString FileExtention;
MyListView myListView;
std::thread FindThread;
};
//code of CListViewCtrl
#pragma once
#include <atlbase.h>
#include <atlapp.h>
#include <atlmisc.h>
#include <atlwin.h>
#include <atlctrls.h>
#include <atlfile.h>
#include <atlstr.h>
class MyListView:public CListViewCtrl
{
private:
LVITEM lvItem;
CListViewCtrl myListView;
CString path;
int i;
public:
void Create(HWND m_hWnd);
void FindFile(CString szPath);
void View_List(CString buf, int i,CString path);
BOOL InitListViewImage(int size, CString path);
};