dllee 的 Blog

這是我的第一個 Blog,雖然我已有許多網頁空間,但因為工作的關係,幾乎都不太更新了... Blog 是另一個方便記錄分享的方式,就如同在討論區留言一樣方便,當然,也是要有空才能貼文囉 [:P]

2008年11月16日星期日

我的 blog 目前在天空

我的 Blog 在天空喔 http://blog.yam.com/dllee 歡迎您來坐坐 ^^

2005年9月11日星期日

直接使用 code pre 的效果


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

#ifndef StatPlusTimeUpUnitH
#define StatPlusTimeUpUnitH
//---------------------------------------------------------------------------
#include 
#include 
#include 
#include 
#include 
#include 
//---------------------------------------------------------------------------
class TFormStatPlusTimeUp : public TForm
{
__published: // IDE-managed Components
  TLabel *Label;
  TTimer *Timer1;
  TTimer *Timer2;
  void __fastcall FormKeyPress(TObject *Sender, char &Key);
  void __fastcall Timer1Timer(TObject *Sender);
  void __fastcall FormShow(TObject *Sender);
  void __fastcall FormCloseQuery(TObject *Sender, bool &CanClose);
  void __fastcall Timer2Timer(TObject *Sender);
private: // User declarations
  char KeyString[256];
  unsigned char  KeyCount;
public:  // User declarations
  __fastcall TFormStatPlusTimeUp(TComponent* Owner);
  AnsiString DefaultMessage;
  AnsiString Password;
  POINT      LastMousePos;
  bool       CanCloseNow;
};
//---------------------------------------------------------------------------
extern PACKAGE TFormStatPlusTimeUp *FormStatPlusTimeUp;
//---------------------------------------------------------------------------
#endif
所有 include 的部分都不見了 :(

測試格式範本

要測試文件範本,貼一些程式碼來看看效果如何? C2html 的工具來處理: //---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "StatPlusTimeUpUnit.h"
#include "StatPlusAPI.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TFormStatPlusTimeUp *FormStatPlusTimeUp;
//---------------------------------------------------------------------------
__fastcall TFormStatPlusTimeUp::TFormStatPlusTimeUp(TComponent* Owner)
  : TForm(Owner)
{
  this->DoubleBuffered=true;
  DefaultMessage="時間到了! 換人了!\n\nㄕˊ ㄐㄧㄢ ㄉㄠˋ ˙ㄌㄜ!\n\nㄏㄨㄢˋ ㄖㄣˊ ˙ㄌㄜ!\n\n";
  this->Label->Caption=DefaultMessage;
  KeyCount=0;
  CanCloseNow=true;
}
//---------------------------------------------------------------------------
void __fastcall TFormStatPlusTimeUp::FormKeyPress(TObject *Sender,
      char &Key)
{
  if(Key==0x1B)       // Esc
  {
    KeyCount=0;
    this->Label->Caption=DefaultMessage;
  }
  else if(Key==0x08)  // BackSpace
  {
    if(KeyCount!=0) KeyCount--;
    this->Label->Caption=DefaultMessage+AnsiString::StringOfChar('*', KeyCount);
  }
  else if(Key==0x0D)  // Enter
  {
    if(Password==AnsiString(KeyString,KeyCount))
    {
      Timer2Timer(Sender);  // Close
    }
    KeyCount=0;
    this->Label->Caption=DefaultMessage;
  }
  else                // 一般字元
  {
    KeyString[KeyCount]=Key;
    KeyCount++;
    this->Label->Caption=DefaultMessage+AnsiString::StringOfChar('*', KeyCount);
  }
}
//---------------------------------------------------------------------------
void __fastcall TFormStatPlusTimeUp::Timer1Timer(TObject *Sender)
// 每 50mS 把視窗設為前景並設定一次滑鼠位置
  Application->BringToFront();
  ApplicationSetTopMost();
  SetCursorPos(Screen->Width/2,8);
  mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
  mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
}
//---------------------------------------------------------------------------
void __fastcall TFormStatPlusTimeUp::FormShow(TObject *Sender)
{
  GetCursorPos(&LastMousePos);
  Timer1->Enabled=true;
  Timer2->Enabled=true// 最多等 10 分鐘就關閉
  CanCloseNow=false;    // 無法按 Alt+F4
}
//---------------------------------------------------------------------------
void __fastcall TFormStatPlusTimeUp::FormCloseQuery(TObject *Sender,
      bool &CanClose)
{
  CanClose=CanCloseNow;
}
//---------------------------------------------------------------------------
// 最多不讓使用者操作 10 分鐘,以免無法回到正常畫面
void __fastcall TFormStatPlusTimeUp::Timer2Timer(TObject *Sender)
{
  this->Timer1->Enabled=false;
  this->Timer2->Enabled=false;
  CanCloseNow=true;
  ApplicationClearTopMost();
  WindowClearTopMost(this->Handle);
  Close();
  Application->MainForm->Show();
  SetCursorPos(Application->MainForm->Left+100,Application->MainForm->Top+20);
}
//---------------------------------------------------------------------------

效果不理想...

2005年1月5日星期三

This is my first blog :D

這是我的第一個 Blog :D 個人網站 http://free.greenworld.com.tw/~dllee/ This is my first blog :D My website is http://dllee.ktop.com.tw 「吃軟也吃硬」in Chinese BIG5