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
[18891] TSpeedButton의 문제
유지상 [newjisang] 916 읽음    2002-05-26 05:31
Spd.zip 703.5KB 프로젝트파일
void __fastcall TForm1::WMNCHitTest(TWMNCHitTest& Msg)
{
  TForm::Dispatch(&Msg);
  if( Msg.Result == HTCLIENT)
    Msg.Result = HTCAPTION;
}
프로젝트에서 폼 하나만 만들고, 위와 같은 코딩을 추가하였습니다.
위 코딩은 프로그램실행시, 폼의 클라이언트영역을 클릭해서 폼을 드레그할 수 있게 해줍니다. (즉, 제목표시줄을 클릭해서 윈도우를 드레그하는 것과 같은 효과가 나옵니다.)
그 폼 위에 두 개의 버튼을 올려놓았는데,
하나는 TButton 이고, 다른 하나느 TSpeedButton입니다.
프로그램을 실행해보면, TButton을 누르면 버튼이 눌려집니다.
그러나, TSpeedBUtton 은 눌려지지가 않습니다.
TSpeedButton에 마우스를 누르면, 버튼이 눌려지지 않는 대신, 폼을 드레그할 수 있게 됩니다.
왜 이렇게 TButton과 TSpeedButton이 다르게 행동하는 거지요?
TSpeedButton도 눌려질 수 있도록 하려면 어떻게 해야 하죠?





전체 소스코드. (CBuilder 5 의 프로젝트파일이 첨부되어있습니다.)

(Unit1.h)


//---------------------------------------------------------------------------

#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Buttons.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:    // IDE-managed Components
  TButton *Button1;
  TSpeedButton *SpeedButton1;
private:    // User declarations
public:        // User declarations
  __fastcall TForm1(TComponent* Owner);
  void __fastcall WMNCHitTest(TWMNCHitTest& Msg);
protected:
  BEGIN_MESSAGE_MAP
    VCL_MESSAGE_HANDLER(WM_NCHITTEST, TWMNCHitTest, WMNCHitTest)
  END_MESSAGE_MAP(TForm)

// void __fastcall WMNCHitTest(TWMNCHitTest& Msg);

};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif


(Unit1.cpp)


#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
  : TForm(Owner)
{
}
//---------------------------------------------------------------------------

/*
void __fastcall TForm1::WMNCHitTest(TWMNCHitTest& Msg)
{
  //Enabling this form to be dragged by clicking the client region.
}  */



void __fastcall TForm1::WMNCHitTest(TWMNCHitTest& Msg)
{
  TForm::Dispatch(&Msg);
  if( Msg.Result == HTCLIENT)
    Msg.Result = HTCAPTION;
}

+ -

관련 글 리스트
18891 TSpeedButton의 문제 유지상 916 2002/05/26
18892     Re:TSpeedButton의 문제 유영인.Chris 983 2002/05/26
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.