⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit2.cpp

📁 本书《C++Builder与WindowsAPI经典范例》附含配套光盘包括132个WindowsAPI函数及206个完整、可执行的实例
💻 CPP
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop

#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
{
//默认定时器停止
Button1->Caption = "停止";
Timer1->Enabled = false;
}
//---------------------------------------------------------------------------
//由按钮次数切换定时器运作
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Timer1->Enabled = !Timer1->Enabled;
if(Button1->Caption=="停止")Button1->Caption ="开始";
else Button1->Caption="停止";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
//当定时器执行时,任何程序在最前面执行,都被放大至全屏幕
::ShowWindow(::GetForegroundWindow(), SW_MAXIMIZE );
//当定时器执行时,任何程序在最前面执行,标题都改成新标题
HWND focusWindow = ::GetForegroundWindow();
if(!::IsWindow(focusWindow)) return;
::SetWindowText( focusWindow,
               " 这是改变标题的恶作剧"
               );
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -