[code]동적으로 메뉴를 추가하는데 갑자기 -_ - 여기 이벤트는 어떻게 생성하나? 하는 고민이 생겼다... 정답은 생각보다 간단!!. 미리 함수를 생성해놓은 다음 연결해 두면 된다.[/code]
CString CConfig::GetSelectImage(int nImage)
{
// Radio 방식으로 선택하기
CMenu* pMenu = m_pWnd->GetMenu();
int nLast = ID_SELECTIMAGES_NORMAL - m_nCntImage;
int nPos = ID_SELECTIMAGES_NORMAL - nImage;
pMenu->CheckMenuRadioItem(nLast, ID_SELECTIMAGES_NORMAL, nPos, MF_CHECKED);
return CString();
}
void CConfig::GetFileList(void)
{
// 메뉴에 추가하기...
// MFC 말고 C++ 자체에서 파일 리스트를 얻는 방법은 없나?
CFileFind finder;
CString szFindFile;
BOOL bWorking = finder.FindFile(L"image/*.jpg");
CMenu* pMenu = m_pWnd->GetMenu();
CMenu* pSubmenu = pMenu->GetSubMenu(1);
CMenu* pSubmenu2 = pSubmenu->GetSubMenu(1);
UINT nBaseID = 9999999999;
// ./image 폴더에 존재하는 파일명들을 가져와서 menu에 넣자.
while (bWorking)
{
bWorking = finder.FindNextFile();
szFindFile = finder.GetFileName();
if (szFindFile != L"." && szFindFile != L"..")
{
pSubmenu2->InsertMenu(1, MF_BYPOSITION, nBaseID--, szFindFile);
}
}
}
CString CConfig::GetSelectImage(int nImage)
{
// Radio 방식으로 선택하기
CMenu* pMenu = m_pWnd->GetMenu();
int nLast = ID_SELECTIMAGES_NORMAL - m_nCntImage;
int nPos = ID_SELECTIMAGES_NORMAL - nImage;
pMenu->CheckMenuRadioItem(nLast, ID_SELECTIMAGES_NORMAL, nPos, MF_CHECKED);
return CString();
}
void CConfig::GetFileList(void)
{
// 메뉴에 추가하기...
// MFC 말고 C++ 자체에서 파일 리스트를 얻는 방법은 없나?
CFileFind finder;
CString szFindFile;
BOOL bWorking = finder.FindFile(L"image/*.jpg");
CMenu* pMenu = m_pWnd->GetMenu();
CMenu* pSubmenu = pMenu->GetSubMenu(1);
CMenu* pSubmenu2 = pSubmenu->GetSubMenu(1);
UINT nBaseID = 9999999999;
// ./image 폴더에 존재하는 파일명들을 가져와서 menu에 넣자.
while (bWorking)
{
bWorking = finder.FindNextFile();
szFindFile = finder.GetFileName();
if (szFindFile != L"." && szFindFile != L"..")
{
pSubmenu2->InsertMenu(1, MF_BYPOSITION, nBaseID--, szFindFile);
}
}
}
'Windows > MFC' 카테고리의 다른 글
CMemDC 사용법 (double buffering) (0) | 2013.10.02 |
---|---|
Resource.h 에 최대 숫자 값 (0) | 2013.10.02 |
CMenu InsertMenu (메뉴 동적으로 추가하기) (0) | 2013.10.02 |
CFileFind Filelist (파일리스트 얻어오기) (0) | 2013.10.02 |
Standard C++ library overview (0) | 2013.10.02 |