Win32 , C++

MFC 메세지박스 제목 바꾸기

김모작자 2008. 7. 25. 14:32
보통 수정을 하지 않은 상태에서
MFC 에 있는 MessageBox 또는 AfxMessageBox 를 사용할 때
메세지박스의 제목(caption) 을 지정하지 않을 경우
실행 파일의 이름이나 처음 프로젝트 만들때 지정한 텍스트가 나오게 된다

더구나 그 제목에 표시되는 텍스트가 레지스트리/INI 에 저장할 때도 그대로 쓰이게 된다

이를 바꾸기 위해서는
1. 리소스 스트링 테이블에 AFX_IDS_APP_TITLE 이 있는 경우 해당 값을 바꾸면 되고
2. CWinApp 의 m_pszAppName 을 초기 코드에서 바꿔주면 된다

참고로 m_pszAppName 을 수정하기 할때 문자열이 지속적으로 메모리에 남아있도록 해야한다.

//First free the string allocated by MFC at CWinApp startup.
//The string is allocated before InitInstance is called.
free((void*)m_pszAppName);
//Change the name of the application file.
//The CWinApp destructor will free the memory.
m_pszAppName=_tcsdup(_T("호호호호"));


MFC 예제