怎样初始化一个二维结构数组常量?如Shape : Array[0..9,0..9] of TPoint = (???);

chen_jianxiong 2002-09-18 08:18:05
怎样初始化一个二维结构数组常量?如Shape : Array[0..9,0..9] of TPoint = (???);我想定义一个二维数组常量,数组中的值是点,怎样初始化?
...全文
81 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
CHENGXB 2002-09-19
  • 打赏
  • 举报
回复
99523193
chen_jianxiong 2002-09-19
  • 打赏
  • 举报
回复
Thanks。Would you like to tell me your QQ?
CHENGXB 2002-09-18
  • 打赏
  • 举报
回复
Shape:Array[0..2,0..1] of Tpoint=(
((x:1;y:1),(x:1;y:1)),
((x:1;y:1),(x:1;y:1)),
((x:1;y:1),(x:1;y:1)));
blazingfire 2002-09-18
  • 打赏
  • 举报
回复
靠!慢了几分钟!
blazingfire 2002-09-18
  • 打赏
  • 举报
回复
const
Arry:array[0..2,0..1]of char=(('a','b'),('c','a'),('b','c'));
liang_z 2002-09-18
  • 打赏
  • 举报
回复
a : array[0..2,0..2]of integer=((0,0,1),(0,0,1),(0,0,1));
类似QQ,MSN的窗口震动效果,里面有源代码。 unit ShakeWindow; interface uses Classes, Windows, Forms; const Max_PTCount = 40; type TShakeThread = class(TThread) private FForm: TCustomForm; FXStrength: Integer; FYStrength: Integer; FPTArray: array [0..Max_PTCount - 1] of TPoint; procedure InitPTArray; procedure SetXStrength(const Value: Integer); procedure SetYStrength(const Value: Integer); protected procedure Execute; override; public property Form: TCustomForm read FForm write FForm; property XStrength: Integer read FXStrength write SetXStrength; property YStrength: Integer read FYStrength write SetYStrength; end; procedure Shake(valForm: TCustomForm; valXStrength: Integer = 4; valYStrength: Integer = 4); implementation uses Math; procedure Shake(valForm: TCustomForm; valXStrength: Integer = 4; valYStrength: Integer = 4); begin with TShakeThread.Create(True) do begin Form := valForm; XStrength := valXStrength; YStrength := valYStrength; FreeOnTerminate := True; Resume; end; end; procedure TShakeThread.Execute; var I: Integer; P: TPoint; begin InitPTArray; P := Point(FForm.Left, FForm.Top); for I := Max_PTCount - 1 downto 0 do begin SetWindowPos(FForm.Handle, 0, P.X + FPTArray[I].X, P.Y + FPTArray[I].Y, 0, 0, SWP_NOSIZE or SWP_NOREPOSITION); Sleep(20); end; end; procedure TShakeThread.InitPTArray; var I: Integer; function Sign(): Integer; begin Result := IfThen(RandomRange(0, 36635) mod 2 = 0, -1, 1); end; begin Randomize; for I := Max_PTCount - 1 downto 0 do begin FPTArray[i].X := Sign()*RandomRange(0, 36635) mod FXStrength*i div 10; FPTArray[i].Y := Sign()*RandomRange(0, 36635) mod FYStrength*i div 10; end; end; procedure TShakeThread.SetXStrength(const Value: Integer); begin if Value < 4 then FXStrength := 4 else if Value > 20 then FXStrength := 20 else FXStrength := Value; end; procedure TShakeThread.SetYStrength(const Value: Integer); begin if Value < 4 then FYStrength := 4 else if Value > 20 then FYStrength := 20 else FYStrength := Value; end; end.
unit Unit3; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, xpWindow, StdCtrls, AAFont, AACtrls; type TForm3 = class(TForm) Label2: TLabel; xpWindow1: TxpWindow; AAFadeText1: TAAFadeText; private { Private declarations } public { Public declarations } end; var Form3: TForm3; implementation {$R *.dfm} end. unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, shellapi, Menus, StdCtrls, ExtCtrls, AAFont, AACtrls, AAFontDialog,Registry, xpWindow; const wm_traynotify=wm_user+1000; type TForm1 = class(TForm) PopupMenu1: TPopupMenu; NToDos: TMenuItem; NCancel: TMenuItem; NReboot: TMenuItem; NClose: TMenuItem; Memo1: TMemo; N1: TMenuItem; GroupBox1: TGroupBox; Timer1: TTimer; CheckBox1: TCheckBox; CheckBox2: TCheckBox; CheckBox3: TCheckBox; AAFontDialog1: TAAFontDialog; xpWindow1: TxpWindow; AAScrollText1: TAAScrollText; Label1: TLabel; procedure FormCreate(Sender: TObject); procedure formdestroy(sender:tobject); procedure btnCancelClick(Sender: TObject); procedure btnToDosClick(Sender: TObject); procedure btnRebootClick(Sender: TObject); procedure btnCloseClick(Sender: TObject); procedure CheckBox1Click(Sender: TObject); procedure CheckBox2Click(Sender: TObject); procedure CheckBox3Click(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure N1Click(Sender: TObject); private { Private declarations } my_tray_icon:tnotifyicondata; procedure wmmytrayiconcallback(var msg:tmessage); message wm_traynotify; public { Public declarations } // procedure GameGontrol(sender:TObject); end; var Form1: TForm1; game:array[0..255] of string; FilePath : string; implementation uses Unit2, Unit3; {$R *.DFM} // 自定义过程,用于程序运行后,屏蔽操作系统的任务管理器 procedure DisableTaskmgr(Key: Boolean); Var Reg:TRegistry; Begin Reg:=TRegistry.Create; try Reg.RootKey := HKEY_CURRENT_USER; if Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\Policies\System', True) then begin if Key then Reg.WriteString('DisableTaskMgr','1') else Reg.WriteInteger('DisableTaskMgr',0); Reg.CloseKey; end; except Reg.Free; end; end; procedure TForm1.FormCreate(Sender: TObject); var key:boolean; hKey:string; hReg:TregIniFile; registerTemp:TRegistry; begin // 程序开机自动运行 try registerTemp:=TRegistry.create; registerTemp.RootKey:=HKEY_LOCAL_MACHINE; if registerTemp.OpenKey('software\Microsoft\Windows\currentversion\run',True) then begin registerTemp.WriteString(extractfilename(application.ExeName),application.ExeName); end; except Showmessage('该程序无法自动运行,请及时与作者联系!'); end; disableTaskmgr(true); // 程序运行后,屏蔽系统任务管理器,防止学生强制关闭软件 visible:=false; application.ShowMainForm:=visible; with my_tray_icon do begin cbsize:=sizeof(tnotifyicondata); wnd:=handle; uid:=1; uflags:=nif_message or nif_icon or nif_tip; ucallbackmessage:=wm_traynotify; hicon:=loadicon(0,idi_winlogo); sztip:=''; end; shell_notifyicon(nim_add,@my_tray_icon); end; procedure tform1.formdestroy(sender:tobject); begin shell_notifyicon(nim_delete,@my_tray_icon); end; procedure tform1.wmmytrayiconcallback(var msg:tmessage); var cursorpos:tpoint; begin case msg.LParam of wm_lbuttondown: begin visible:=not visible; application.ShowMainForm:=visible; setforegroundwindow(application.handle); end; wm_rbuttondown: begin getcursorpos(cursorpos); popupmenu1.Popup(cursorpos.x,cursorpos.y); end; end; end; procedure TForm1.btnCancelClick(Sender: TObject); begin exitwindowsex(ewx_force,0); end; procedure TForm1.btnToDosClick(Sender: TObject); begin exitwindowsex(ewx_logoff,0); end; procedure TForm1.btnRebootClick(Sender: TObject); var st : SYSTEMTIME; hToken : THANDLE; tkp : TOKEN_PRIVILEGES; rr : Dword; begin OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY,hToken); LookupPrivilegeValue(nil,'SeShutdownPrivilege',tkp.Privileges[0].Luid); // 设定权限为1 tkp.PrivilegeCount := 1; tkp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED; // 得到权限 AdjustTokenPrivileges(hToken, FALSE, tkp, 0,nil,rr); // 重起计算机 ExitWindowsEx(EWX_REBOOT , 0) end; procedure TForm1.btnCloseClick(Sender: TObject); begin // exitwindowsex(ewx_shutdown,0); Formclose.Show; end; procedure TForm1.CheckBox1Click(Sender: TObject); begin if checkbox1.Checked=true then begin checkbox2.Checked:=false; checkbox3.Checked:=false; end ; end; procedure TForm1.CheckBox2Click(Sender: TObject); begin if checkbox2.Checked=true then begin checkbox1.Checked:=false; checkbox3.Checked:=false; end; end; procedure TForm1.CheckBox3Click(Sender: TObject); begin if checkbox3.Checked=true then begin checkbox2.Checked:=false; checkbox1.Checked:=false; end; end; procedure TForm1.Timer1Timer(Sender: TObject); var hcurrentWindow:HWnd; szText:array[0..254] of char; Gamefile:TextFile; // 文本文件,存放已经知道的游戏句柄 s:string; // i,j:integer; st:SYSTEMTIME; hToken:THANDLE; tkp:TOKEN_PRIVILEGES; RR:Dword; begin try if form3.Showing=true then begin form3.Close; end; memo1.Clear; hCurrentWindow:=GetWindow(Handle,GW_HWNDFIRST); While hCurrentWindow<>0 do begin if GetWindowText(hCurrentWindow,@szText,255)>0 then Memo1.Lines.Add(strpas(@sztext)+Datetimetostr(now)); // for i:=0 to 254 do // begin try FilePath := ExtractFilePath(Application.ExeName); // 程序运行后,自动获取Game.txt的路径 assignfile(Gamefile,FilePath+'\game.txt'); // 准备读取game.txt中的信息 reset(Gamefile); except showmessage('^_^'); end; while not eof(Gamefile) do begin readln(Gamefile,s); if strPas(@szText)=s then begin form3.Show; // 发现游戏后,分别处理 if checkbox1.Checked=true then begin sendMessage(hCurrentWindow,WM_CLOSE,0,0); // 关闭游戏 end; if checkbox3.Checked=true then // 关闭计算机 begin openProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES OR TOKEN_QUERY,hToken); LookupPrivilegeValue(nil,'SeShutdownPrivilege',tkp.Privileges[0].Luid); tkp.privilegecount:=1; tkp.privileges[0].Attributes:=se_privilege_enabled; adjusttokenprivileges(hToken,false,tkp,0,nil,rr); exitwindowsex(ewx_poweroff,0); end; if checkbox2.Checked=true then begin exitwindowsex(ewx_force,0); // 注销计算机 end; end; end; // end; hcurrentwindow:=getwindow( hCurrentWindow,gw_hwndnext); end; finally end; end; procedure TForm1.N1Click(Sender: TObject); var p:pchar; //指针,指向将被打开的帮助文件 begin p:=pchar(ExtractFilePath(Application.ExeName)+'Help.chm'); shellexecute(0,nil,p,nil,nil,SW_NORMAL); end; end. unit Unit2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,registry,xpWindow; type TFormclose = class(TForm) GroupBox1: TGroupBox; Label1: TLabel; Edit1: TEdit; Button1: TButton; xpWindow1: TxpWindow; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Formclose: TFormclose; implementation uses Unit1; {$R *.dfm} // 自定义过程,用于程序运行后,屏蔽操作系统的任务管理器 procedure DisableTaskmgr(Key: Boolean); Var Reg:TRegistry; Begin Reg:=TRegistry.Create; try Reg.RootKey := HKEY_CURRENT_USER; if Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\Policies\System', True) then begin if Key then Reg.WriteString('DisableTaskMgr','1') else Reg.WriteInteger('DisableTaskMgr',0); Reg.CloseKey; end; except Reg.Free; end; end; // 自定义过程,实现系统开机自动运行 procedure SetAuttorun(aProgTitle,aCmdLine:string;aRunOnce:boolean); var hKey:string; hReg:TRegIniFile; begin if aRunOnce then hKey:='Once' else hKey:=''; hReg:=TRegIniFile.Create(''); hReg.RootKey:=HKEY_LOCAL_MACHINE; hReg.WriteString('software\microsoft\windows\currentversion\run' +hKey+#0,aProgTitle,aCmdLine); // 修改操作系统注册表 hReg.Destroy; end; procedure TFormclose.Button1Click(Sender: TObject); var key:boolean; begin if edit1.Text='162534' then begin key:=false; DisableTaskmgr(key); // 当系统推出时恢复任务管理器 application.Terminate; end else begin showmessage('密码错误!'); formclose.Close; end; edit1.Clear; end; end.

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧