C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[71158] Re:Application->MessagBox 빌더6-->XE2
너브 [nervegum] 4528 읽음    2014-04-07 09:08
CB 2009+ 부터는 Unicode-based Win32 API functions을 사용하기에 아래와 같이 바꿔야 한다고 하네요... ㅜ.ㅜ

The old Application->MessageBox did not compile it gives the error :
Cannot convert 'char *' to 'const wchar_t *'



TApplication::MessageBox() is just a thin wrapper around the Win32 API MessageBox()
function. For whatever reason, Borland decided to make the data types of
the TApplication::MessageBox() parameters match the data types of the Win32
API MessageBox() parameters, instead of using RTL equivilents like other
RTL wrappers do. In BCB v6, the RTL/VCL uses Ansi-based Win32 API functions,
thus MessageBoxA() is used and so the TApplication::MessageBox() parameters
are char*. In CB 2009+, the RTL/VCL uses Unicode-based Win32 API functions,
thus MessageBoxW() is used and the TApplication::MessageBox() parameters
are wchar_t*. Because of that, you have to update your code accordingly, eg:
int res = Application->MessageBox(L"My Text", L"My Caption", MB_YESNO | MB_ICONEXCLAMATION | MB_DEFBUTTON2);
int res = Application->MessageBox(L"My Text", L"My Caption", MB_OK | MB_ICONEXCLAMATION);



아래는 원문입니다.
https://forums.embarcadero.com/thread.jspa?threadID=85183

nervegum 님이 쓰신 글 :
: MessageBox를 사용하는데
: 예전에 사용했던 방법은
: Application->MessageBox("내용","캡션",MB_OKCANCEL);
: 로 사용을 했습니다.
:
: 하지만 이번에 XE2에서 컴파일을 하니까 형변환 에러가 나옵니다.
:
: Cannot convert 'char const[8]' to 'const wchar_t *'
: Type mismatch in parameter 'Caption' (wanted 'const wchar_t *', got 'const char *')
:
:
: 구굴링 하다가 찾은 방법은
: 아래와 같습니다.
:
:
: void __fastcall TForm1::Button1Click(TObject *Sender)
: {
: Application->NormalizeTopMosts();
: #ifdef _DELPHI_STRING_UNICODE
: Application->MessageBox(L"This should be on top.", L"Look", MB_OKCANCEL);
: #else
: Application->MessageBox("This should be on top.", "Look", MB_OKCANCEL);
: #endif
: Application->RestoreTopMosts();
: }
: 

:
: 질문입니다.
: 1. MessageBoX를 사용할때는 L + "메시지"를 해야 되는 것인가요?
:    어딘가에 정의가 되있는것 같은데 혹시 컴파일 옵션처리로 예전처럼 사용할 수 없는 것인가요?
:
: 감사합니다.

+ -

관련 글 리스트
71143 Application->MessagBox 빌더6-->XE2 nervegum 2865 2014/04/02
71158     Re:Application->MessagBox 빌더6-->XE2 너브 4528 2014/04/07
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.