📄 main.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <registry.hpp>
#include "main.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TMainForm *MainForm;
//---------------------------------------------------------------------------
__fastcall TMainForm::TMainForm(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::btnOpenClick(TObject *Sender)
{
if (dlgOpenPicture->Execute())
imgPreview->Picture->LoadFromFile(dlgOpenPicture->FileName);
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::btnExitClick(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::btnWallpaperClick(TObject *Sender)
{
AnsiString S = dlgOpenPicture->FileName;
if (S.IsEmpty()) return;
// first, modify the value of registry keys for wallpaper styles
TRegIniFile* r = new TRegIniFile("\Control Panel");
try {
// my own habit: always set TileWallPaper key to zero }
r->WriteInteger("Desktop", "TileWallPaper", 0);
/* set WallPaperStyle key to corresponding value:
0 = Center
1 = Tile
2 = Fit to screen */
r->WriteInteger("Desktop", "WallPaperStyle", rgpStyle->ItemIndex);
} __finally {
delete r;
}
// second, change wallpaper
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, S.c_str(),
SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::FormCreate(TObject *Sender)
{
ShowPattern();
}
//---------------------------------------------------------------------------
typedef bool TPatternArray[8][8];
bool ParsePatternString(AnsiString sPattern, TPatternArray& aPattern)
{
int x, y, i, val;
y = 0;
while (sPattern.Length() > 0) {
if ((i = sPattern.Pos(" ")) != 0) {
val = StrToIntDef(sPattern.SubString(1, i - 1), 0);
sPattern.Delete(1, i);
} else {
val = StrToIntDef(sPattern, 0);
sPattern = "";
}
x = 7;
while (x >= 0) {
aPattern[y][x] = val & 1;
val >>= 1;
x--;
}
y++;
}
return (y == 8); // successfully parsed
}
void __fastcall TMainForm::ShowPattern()
{
/* should be "(None)", but Windows NT 4.0 Traditional Chinese
version translated it to "(礚)". */
const char* NON_PATTERN_STR = "(None)";
TPatternArray aPattern;
AnsiString sPattern;
TRegIniFile* r = new TRegIniFile("Control Panel");
try {
/* the name of key should be "Pattern", but Windows NT 4.0
Traditional Chinese version translated it to "摸
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -