MFC 메시지박스 사용법 예제 4개 (AfxMessageBox 버튼 종류, 반환값)
MFC에서 메시지박스를 조금 더 유연하게 사용할 수 있는 방법을 소개합니다. 제목, 버튼, 아이콘, 반환값을 제어하는 총 4가지 방법을 다루는 데, 각각 간단한 예제와 결과 화면을 보여줍니다. 예제 소스에 나온 텍스트와 결과 화면을 잘 매칭시켜 확인해 보세요. 어렵지 않습니다.
아래에 4가지 방법에 대한 간단한 예제를 확인해 보세요.
MFC 메세지박스 제목
1 2 3 | MessageBox(NULL, L"Due to an unknown internal error, this application will now close.", L"Regular Warning", 0); | cs |
MFC 메시지 박스 예 - 메시지 박스 제목1
1 2 3 | MessageBox(NULL, L"Due to an unknown internal error, this application will now close.", NULL, 0); | cs |
MFC 메시지 박스 예 - 박스 제목2
MFC 메세지박스 버튼
MFC 메시지 박스 예 - 버튼 옵션
1 2 3 | AfxMessageBox( L"Due to an unknown internal error, this application will now close.\n" L"Do you want to save the file before closing?", MB_YESNO); | cs |
MFC 메시지 박스 예 - 버튼 예제
MFC 메세지박스 아이콘
MFC 메시지 박스 예 - 박스 아이콘 옵션
1 2 3 | AfxMessageBox( L"Due to an unknown internal error, this application will now close.\n" L"Do you want to save the file before closing?", MB_YESNO | MB_ICONWARNING); | cs |
MFC 메시지 박스 예 - 박스 아이콘 예제
MFC 메세지박스 반환값
MFC 메시지 박스 예 - 박스 반환값 옵션
사용 예
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include <afxwin.h> #include "resource.h" class CExerciseApp : public CWinApp { BOOL InitInstance() { int Answer; Answer = AfxMessageBox(L"Due to an unknown internal error, " L"this application will now close.\n" L"Do you want to save the file before closing?", MB_YESNO | MB_ICONWARNING | MB_DEFBUTTON2); if( Answer == IDYES ) AfxMessageBox(L"You selected Yes"); else // if( Answer == IDNO ) AfxMessageBox(L"You selected No"); return TRUE; } }; CExerciseApp theApp; | cs |
MFC 메시지박스 사용법 예제 4개 (AfxMessageBox 버튼 종류, 반환값)
댓글