unit4.cpp
来自「本书《C++Builder与WindowsAPI经典范例》附含配套光盘包括132」· C++ 代码 · 共 44 行
CPP
44 行
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit4.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
//动态新建一个POP菜单,用来显示鼠标在Panel1范围中位置
popMenu = new TPopupMenu(this);
pop1 = new TMenuItem(this);
popMenu->Items->Add(pop1);
pop1->Caption = "这是Panel1范围中";
//将闲置属性作为布尔值运算
Button1->Default = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{//取得Panel1的原有类型数据
LONG ExStyle = ::GetWindowLong(Panel1->Handle, GWL_EXSTYLE);
//将Panel1设为透明状态
::SetWindowLong(Panel1->Handle, GWL_EXSTYLE,
ExStyle | WS_EX_TRANSPARENT);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
delete pop1;
delete popMenu;
}
//---------------------------------------------------------------------------
//当鼠标点取Panel1而按键跳起时,删除POP菜单上的显示字符串
void __fastcall TForm1::Panel1MouseUp(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
pop1->Caption = "";
}
//---------------------------------------------------------------------------
//当鼠标点取Panel1而按键单击时,检测鼠标位置并显示在POP选单上
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?