C++Builder Tips


フォーム・移動


タイトルバーを消去したフォームは移動できなくなりますが、そのようなフォームの移動を実現させるサンプルです

//---------------------------------------------------------------------------
// Unit1.h
//---------------------------------------------------------------------------

#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE 管理のコンポーネント
  void __fastcall FormCreate(TObject *Sender);
private:
  
void __fastcall WMLBUTTONDOWN(TWMLButtonDown & msg); // ユーザー宣言
public: // ユーザー宣言
  __fastcall TForm1(TComponent* Owner);
protected:
  BEGIN_MESSAGE_MAP
    VCL_MESSAGE_HANDLER(WM_LBUTTONDOWN, TWMLButtonDown, WMLBUTTONDOWN)
  END_MESSAGE_MAP(TForm)

};
//---------------------------------------------------------------------------
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::FormCreate(TObject *Sender)
{
  BorderStyle = bsNone;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::WMLBUTTONDOWN(TWMLButtonDown & msg)
{
  SendMessage(Handle,WM_SYSCOMMAND,SC_MOVE | 2, 0);
}


DownLoad bcbtips034.lzh 4KB(BCB5)