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
[10973] Re:[질문] 메세지 맵 사용시에 경고가 나타 납니다.
박세호 [oxengs] 859 읽음    2001-09-11 20:02
이창환 님이 쓰신 글 :
: 메세지 맵을 사용하여 다른 폼에 메세지를 전송하는
:
: 일을 할 경우에 "Functions containing switch are not expanded line"이라는 메세지가 나타납니다.
:
: 메세지 맵을 쓸 경우 항상 이렇제 나타나는데여.
:
: (Command-line option to suppress warning: -w-inl)
:
: 도움말에는 이런 메세지가 나오는 것으로 봐서는 컴파일 옵션을 바꾸어 주어야 하는 것은데
:
: 자세한 것을 알고 싶습니다.
:
: 메세지 맵 사용한 소스는
:
: //////////////////////////////////////////////////////////////////////////////
: // Form1.h
: //////////////////////////////////////////////////////////////////////////////
:
: #define WM_MYMESSAGE (WM_APP + 400)
: //---------------------------------------------------------------------------
: class TForm1 : public TForm
: {
: __published:    // IDE-managed Components
:     TButton *Button1;
:     TButton *Button2;
:     void __fastcall Button1Click(TObject *Sender);
:     void __fastcall Button2Click(TObject *Sender);
: private:    // User declarations
: public:        // User declarations
:     __fastcall TForm1(TComponent* Owner);
:
: };
:
: //////////////////////////////////////////////////////////////////////////////
: // Form1.cpp
: //////////////////////////////////////////////////////////////////////////////
: void __fastcall TForm1::Button2Click(TObject *Sender)
: {
:     PostMessage(Form2->Handle, WM_MYMESSAGE, 0,0);
: }
:
:
: //////////////////////////////////////////////////////////////////////////////
: // Form2.h
: //////////////////////////////////////////////////////////////////////////////
: #define WM_MYMESSAGE (WM_APP + 400)
: //---------------------------------------------------------------------------
: class TForm2 : public TForm
: {
: __published:    // IDE-managed Components
:     TEdit *Edit1;
: private:    // User declarations
: public:        // User declarations
:     __fastcall TForm2(TComponent* Owner);
:
: protected:
:     void __fastcall OnMyMessage(TMessage &Message);
: BEGIN_MESSAGE_MAP
:   MESSAGE_HANDLER(WM_MYMESSAGE, TMessage, OnMyMessage)
: END_MESSAGE_MAP(TControl)
: };
:
: //////////////////////////////////////////////////////////////////////////////
: // Form2.cpp
: //////////////////////////////////////////////////////////////////////////////
: void __fastcall TForm2::OnMyMessage(TMessage &Message)
: {
:     static int i = 0;
:     Edit1->Text = IntToStr(i++);
: }
:
: 입니다.
:
:
Form1에서 Form2에게 메세지를 전송 하려면 우선 Form1에 Form2의 헤더 파일을 Include시키신다음에요
Form1에서 Send Message나 Post Message를 사용 하시기 전에 Form2를 new 하시고 메세지를
사용해보세요^^

ex)

//////////////////////////////////////////////////////////////////////////////
// Form1.cpp
//////////////////////////////////////////////////////////////////////////////
#include "Form2.h"
void __fastcall TForm1::Button2Click(TObject *Sender)
{
      TForm2* m_Form = new TForm2(this);
     PostMessage(m_Form->Handle, WM_MYMESSAGE, 0,0);
      delete m_Form;
}
이렇게하면 경고메세지 안올겁니다..
위에 소스는 버튼 누룰때마다 Form을 New하는데 그게 싫으시면 Form1의 해더파일에
Form2해더파일을 Include하시고 Form1의 해더에 Form2를 정의 하신후 생성자나 FormShow하실때
new를 하신후 소멸자나 Form Close시 delete하시면 됩니다...

+ -

관련 글 리스트
10972 [질문] 메세지 맵 사용시에 경고가 나타 납니다. 이창환 799 2001/09/11
11073     Re:[질문] 메세지 맵 사용시에 경고가 나타 납니다. 박지훈.임프 1062 2001/09/14
10973     Re:[질문] 메세지 맵 사용시에 경고가 나타 납니다. 박세호 859 2001/09/11
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.