?? xbase.pas
字號:
unit xBASE;
{=======================================================
項目: ZhaoSoft 短信系統
模塊: 全局數據結構
描述:
版本: 1.0
日期: 2005-02-26
作者: 趙建穩
更新:
=======================================================}
interface
uses
Windows, Messages, SysUtils, CommDlg, Classes, Graphics, Controls,
Forms, StdCtrls;
type
xMessageID = (
xMIDConnect, // 連接請求
xMIDConnectS, // 連接成功
xMIDClientData, // 來自客戶端的用戶信息
xMIDClientDataS, // 客戶端的用戶信息發送成功
xMIDClientLogout, // 客戶端注銷
xMIDChat, // 聊天信息
xMIDClientCheck, // 客戶在線檢測
xMIDClientCheckS, // 客戶在線檢測成功
xMIDServerExit, // 服務器關閉通知
xMIDBChat // 廣播消息
);
{============================================================}
TxClientData = record
ClientID: Integer; // 用戶標識
NickName: array [0..15] of Char; // 昵稱
Portrait: Integer; // 頭像
Expression: Integer; // 表情
FontColor: TColor; // 聊天記錄字體顏色
BKColor: TColor; // 聊天記錄背景色
IPAddress: array [0..15] of Char; // IP 地址
end;
PxClientData = ^TxClientData;
{============================================================}
TxChatProperty = record
NickName: string;
Portrait: Integer;
Expression: Integer;
FontColor: TColor;
BKColor: TColor;
end;
PxChatProperty = ^TxChatProperty;
var
MessageID: xMessageID;
xClientData: TxClientData;
ServerAddress: string;
UDPClientServerPort: Integer;
UDPServerPort: Integer;
const
MAX_CHAT_RECORD = 1024;
//BROADCAST_ADDRESS = '192.168.1.255';
function InputDialog(const ACaption, APrompt: string;
var Value: string): Boolean;
procedure Delay(MSecs: Longint);
implementation
function InputDialog(const ACaption, APrompt: string;
var Value: string): Boolean;
var
Form: TForm;
Prompt: TLabel;
Edit: TEdit;
DialogUnits: TPoint;
ButtonTop, ButtonWidth, ButtonHeight: Integer;
function GetAveCharSize(Canvas: TCanvas): TPoint;
var
I: Integer;
Buffer: array[0..51] of Char;
begin
for I := 0 to 25 do Buffer[I] := Chr(I + Ord('A'));
for I := 0 to 25 do Buffer[I + 26] := Chr(I + Ord('a'));
GetTextExtentPoint(Canvas.Handle, Buffer, 52, TSize(Result));
Result.X := Result.X div 52;
end;
begin
Result := False;
Form := TForm.Create(Application);
with Form do
try
Font := Application.MainForm.Font;
Canvas.Font := Font;
DialogUnits := GetAveCharSize(Canvas);
BorderStyle := bsDialog;
Caption := ACaption;
ClientWidth := MulDiv(180, DialogUnits.X, 4);
ClientHeight := MulDiv(63, DialogUnits.Y, 8);
Position := poScreenCenter;
Prompt := TLabel.Create(Form);
with Prompt do
begin
Parent := Form;
AutoSize := True;
Left := MulDiv(8, DialogUnits.X, 4);
Top := MulDiv(8, DialogUnits.Y, 8);
Caption := APrompt;
end;
Edit := TEdit.Create(Form);
with Edit do
begin
Parent := Form;
Left := Prompt.Left;
Top := MulDiv(19, DialogUnits.Y, 8);
Width := MulDiv(164, DialogUnits.X, 4);
MaxLength := 255;
Text := Value;
SelectAll;
end;
ButtonTop := MulDiv(41, DialogUnits.Y, 8);
ButtonWidth := MulDiv(50, DialogUnits.X, 4);
ButtonHeight := MulDiv(14, DialogUnits.Y, 8);
with TButton.Create(Form) do
begin
Parent := Form;
Caption := '確定';
ModalResult := mrOk;
Default := True;
SetBounds(MulDiv(38, DialogUnits.X, 4), ButtonTop, ButtonWidth,
ButtonHeight);
end;
with TButton.Create(Form) do
begin
Parent := Form;
Caption := '取消';
ModalResult := mrCancel;
Cancel := True;
SetBounds(MulDiv(92, DialogUnits.X, 4), ButtonTop, ButtonWidth,
ButtonHeight);
end;
if ShowModal = mrOk then
begin
Value := Edit.Text;
Result := True;
end;
finally
Form.Free;
end;
end;
procedure Delay(MSecs: Longint);
var
FirstTickCount, Now: Longint;
begin
FirstTickCount := GetTickCount;
repeat
Application.ProcessMessages;
Now := GetTickCount;
until (Now - FirstTickCount >= MSecs) or (Now < FirstTickCount);
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -