'MFC'에 해당되는 글 6건
- 2011/09/06 [MFC] 파일 읽기
- 2009/01/16 Vista vs XP Registry 관련 함수
- 2008/09/09 MFC에서 윈도우 환경에 맞는 Control 만들기
- 2008/09/02 다이얼로그 타이틀바 없이 이동시키기
- 2008/03/31 [MFC] 다이얼로그를 전체화면으로 작성
- 2007/10/25 [MFC] Shared DLL을 사용한 2005 버전 프로그램 배포 시 주의
MFC에서 파일 읽고 쓰기
파일 읽고 내용을 리턴한다.
없으면 생성한다.
LPCTSTR testDlg::GetFileRead()
{
CFile theFile;
char* szFileName = "myfile.txt";
BOOL bOpenOK;
char szBuffer[256] = {0, };
UINT nActual = 0;
CString mFile;
CFileStatus status;
if(CFile::GetStatus(szFileName, status)) {
bOpenOK = theFile.Open(szFileName, CFile::modeRead);
theFile.Read(szBuffer, sizeof(szBuffer));
theFile.Seek(0, CFile::begin);
nActual = theFile.Read(szBuffer, sizeof(szBuffer));
mFile.Format("%s", szBuffer);
}
else {
bOpenOK = theFile.Open(szFileName, CFile::modeCreate | CFile::modeWrite);
}
return mFile;
}
msdn에서 참조했으며기타관련 함수 사용법은 msdn에서 찾길 바랍니다.
LONG WINAPI RegGetValue( __in HKEY hkey, __in_opt LPCTSTR lpSubKey, __in_opt LPCTSTR lpValue, __in_opt DWORD dwFlags, __out_opt LPDWORD pdwType, __out_opt PVOID pvData, __inout_opt LPDWORD pcbData );
LSTATUS SHGetValue( HKEY hkey, LPCTSTR pszSubKey, LPCTSTR pszValue, LPDWORD pdwType, LPVOID pvData, LPDWORD pcbData );
#if defined _M_IX86
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_IA64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_X64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") #endif
방법 1. 윈도우 메시지중 WM_NCHITTEST를 추가하여 다음을 코딩한다.
{
CRect rect;
GetClientRect(&rect);
ClientToScreen(&rect);
if(rect.PtInRect(point))
{
return HTCAPTION;
}
return CDialog::OnNcHitTest(point);
}
방법 2. 왼쪽 버튼 다운 함수에서의 처리 방법
void CTestDlg::OnLButtonDown(UINT nFlag, CPoint point)
{
CDialog::OnLButtonDown(nFlag, point)
// 사용자가 캡션을 클릭한 것처럼 인식되게 끔 대화상자를 속인다.
PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x, point.y));
}
LONG style = ::GetWindowLong( m_hWnd, GWL_STYLE );
style &= ~WS_CAPTION;
style &= ~WS_SYSMENU;
::SetWindowLong( m_hWnd, GWL_STYLE, style );
int screenx = GetSystemMetrics( SM_CXSCREEN );
int screeny = GetSystemMetrics( SM_CYSCREEN );
// resize:
SetWindowPos( NULL, -4, -4, screenx+8, screeny+4, SWP_NOZORDER );
Static Library 사용 시엔 문제가 없지만 Share DLL을 사용 시
릴리즈 버전은 ..\Microsoft Visual Studio 8\VC\redist\x86 에서,
디버그 버전은 ..\Microsoft Visual Studio 8\VC\redist\Debug_NonRedist 에서
CRT, MFC, ATL에 맞는 dll과 함께 Microsoft.VC80.*.manifest 도 포함해서 실행파일과 같은 폴더에 넣어주어야 한다.
아니면 ..\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages\vcredist_x86 또는
VC++ 2005 재배포 가능 패키지를 설치하여야 한다.
www.microsoft.com/downloads/details.aspx?FamilyID=32bc1bee-a3f9-4c13-9c99-220b62a191ee&DisplayLang=ko

Prev
