📄 unit2.pas.svn-base
字号:
end; LoadTable(Opendialog1.filename,merge); end; resync; Updatescreen; updatelist;end;procedure TMainForm.FControlEnter(Sender: TObject);begin LastSelected:=LastLastSelected; Updatescreen;end;procedure TMainForm.FControlExit(Sender: TObject);begin LastLastSelected:=LastSelected; Lastselected:=-1; Updatescreen;end;procedure TMainForm.Label28Click(Sender: TObject);var newdesc: string;begin if lastselected<>scrollbar1.position+(sender as TLabel).tag then exit; newdesc:=InputBox('Description','Change the description to:',memrec[scrollbar1.position+(sender as TLabel).tag].Description); if newdesc='' then newdesc:='No description!'; memrec[scrollbar1.position+(sender as TLabel).tag].Description:=newdesc; updatescreen; //updatelist not neededend;procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);begin CanClose:=CheckIfSaved;end;procedure TMainForm.AddressClick(Sender: TObject);var adr: String; newadr: dword; error: Integer; bit: Byte;begin if memrec[scrollbar1.position+(sender as TLabel).tag].Frozen then raise Exception.Create('You first have to unfreeze this address before you can change it'); if memrec[scrollbar1.position+(sender as TLabel).tag].VarType=5 then //bit adr:=inputbox('Address','Give the new address: (use ^ to specify the startbit)',address[(sender as TLabel).tag].caption) else adr:=inputbox('Address','Give the new address:',address[(sender as TLabel).tag].caption); if adr='DEBUG' then begin showmessage(IntToStr(scrollbar1.position)+' - '+IntToStr((Sender As TLabel).tag)); showmessage(IntToStr(scrollbar1.position+(sender as TLabel).tag)+' - '+address[scrollbar1.position+(sender as TLabel).tag].caption); end; if memrec[scrollbar1.position+(sender as TLabel).tag].VarType=5 then if pos('^',adr)=0 then raise exception.Create('A binary type needs a startbit! (notation:xxxxxxxx^x)'); if adr[1]<>'$' then adr:='$'+adr; val(adr,newadr,error); if error=0 then memrec[scrollbar1.position+(sender as TLabel).tag].Address:=newadr else if adr[error]='^' then begin //newadr contains the right address //now just set the right bit if length(adr)-error>1 then raise exception.Create(adr+' is not an valid address!'); try Bit:=StrToInt(adr[length(adr)]); except raise exception.Create(adr+' is not an valid address!'); end; if bit>7 then raise exception.Create(adr+' is not an valid address!'); //we made it to here so I assume this address is valid ;-) memrec[scrollbar1.position+(sender as TLabel).tag].Address:=newadr; memrec[scrollbar1.position+(sender as TLabel).tag].Bit:=Bit; end else raise exception.Create(adr+' is not an valid address!'); updatescreen; updatelist;end;procedure TMainForm.Typeclick(Sender: TObject);var i,j: Integer; oldType: Integer;begin OldType:=memrec[scrollbar1.position+(sender as TLabel).tag].VarType; if memrec[scrollbar1.position+(sender as TLabel).tag].Frozen then Raise Exception.Create('You can''t change the type of an frozen value. First unfreeze it!'); TypeForm.NrOfRecord:=scrollbar1.position+(sender as TLabel).tag; If memrec[scrollbar1.position+(sender as TLabel).tag].VarType=0 then TypeForm.VarType.itemindex:=1 else //byte If memrec[scrollbar1.position+(sender as TLabel).tag].VarType=1 then TypeForm.VarType.itemindex:=2 else //word If memrec[scrollbar1.position+(sender as TLabel).tag].VarType=2 then TypeForm.VarType.itemindex:=3 else //dword If memrec[scrollbar1.position+(sender as TLabel).tag].VarType=3 then TypeForm.VarType.itemindex:=5 else //float If memrec[scrollbar1.position+(sender as TLabel).tag].VarType=4 then TypeForm.VarType.itemindex:=6 else //double If memrec[scrollbar1.position+(sender as TLabel).tag].VarType=5 then TypeForm.VarType.itemindex:=0 else //bit If memrec[scrollbar1.position+(sender as TLabel).tag].VarType=6 then TypeForm.VarType.itemindex:=4 else //int64 If memrec[scrollbar1.position+(sender as TLabel).tag].VarType=7 then TypeForm.VarType.itemindex:=7 else //text if memrec[scrollbar1.position+(sender as TLabel).Tag].VarType=8 then Typeform.VarType.ItemIndex:=8; case memrec[scrollbar1.position+(sender as TLabel).tag].Bit of 0 : TypeForm.RadioButton1.checked:=true; 1 : TypeForm.RadioButton2.checked:=true; 2 : TypeForm.RadioButton3.checked:=true; 3 : TypeForm.RadioButton4.checked:=true; 4 : TypeForm.RadioButton5.checked:=true; 5 : TypeForm.RadioButton6.checked:=true; 6 : TypeForm.RadioButton7.checked:=true; 7 : TypeForm.RadioButton8.checked:=true; end; TypeForm.Showmodal; if oldtype=memrec[scrollbar1.position+(sender as TLabel).tag].VarType then exit; i:=0; j:=0; while (i<numberofrecords-1) and (j<1) do begin if selected[i] then inc(j); inc(i); end; if (i>1) then begin j:=memrec[scrollbar1.position+(sender as TLabel).tag].VarType; for i:=0 to numberofrecords-1 do begin if (selected[i]) and (not memrec[i].Frozen) then memrec[i].VarType:=j; end; end; resync; updatescreen; updatelist;end;procedure TMainForm.FControlKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);var i,j: Integer; comfirm: Dword; doit: Boolean; freeze: Boolean; db: Byte; dw: Word; dd: dword; di64: Int64; a: single; b: double; error: Dword; controle: String; select: Integer; count: integer;begin if ((key=ord('C')) and (ssCtrl in Shift) and not (ssAlt in Shift)) then copyselectedrecords; if ((key=ord('V')) and (ssCtrl in Shift) and not (ssAlt in Shift)) then Paste; if ((key=ord('X')) and (ssCtrl in Shift) and not (ssAlt in Shift)) then begin copyselectedrecords; deleterecords; end; case key of ord('A')..ord('Z'),ord('0')..ord('9'): begin if not (ssCtrl in Shift) then begin select:=-1; for i:=lastselected+1 to numberofrecords-1 do begin if (length(memrec[i].description[1])>0) and (uppercase(memrec[i].description[1])=uppercase(chr(key))) then begin select:=i; break; end; end; if select=-1 then exit; if not ((ssShift) in (Shift)) then FirstShiftSelected:=-1; if ssShift in Shift then //ctrl does nothing begin if lastselected<numberofRecords-1 then begin if FirstShiftSelected=-1 then FirstShiftSelected:=lastselected; //select everything from FirstShiftSelected to sel for i:=0 to numberofrecords-1 do selected[i]:=false; Lastselected:=select; if FirstShiftSelected<lastselected then for i:=FirstShiftselected to lastselected do selected[i]:=true else for i:=FirstShiftSelected downto lastselected do selected[i]:=true; end; end else begin if lastselected<numberofRecords-1 then begin for i:=0 to numberofRecords-1 do selected[i]:=false; Lastselected:=select; selected[LastSelected]:=true; end; end; if lastselected<scrollbar1.position then scrollbar1.Position:=lastselected; if lastselected>scrollbar1.position+5 then scrollbar1.Position:=lastselected-5; Updatescreen; end; end; VK_RETURN:begin value[lastselected-scrollbar1.position].OnDblClick(value[lastselected-scrollbar1.position]); end; VK_HOME: begin if not ((ssShift) in (Shift)) then FirstShiftSelected:=-1; if ssShift in Shift then //ctrl does nothing begin if lastselected>0 then begin if FirstShiftSelected=-1 then FirstShiftSelected:=lastselected; //select everything from FirstShiftSelected to sel for i:=0 to numberofrecords-1 do selected[i]:=false; Lastselected:=0; if FirstShiftSelected<lastselected then for i:=FirstShiftselected to lastselected do selected[i]:=true else for i:=FirstShiftSelected downto lastselected do selected[i]:=true; end; scrollbar1.position:=0; end else begin if lastselected>0 then begin for i:=0 to numberofRecords-1 do selected[i]:=false; Lastselected:=0; selected[lastselected]:=true; scrollbar1.Position:=0; end; end; Updatescreen; end; VK_END: begin // if not ((ssShift) in (Shift)) then FirstShiftSelected:=-1; if ssShift in Shift then //ctrl does nothing begin if lastselected<numberofRecords-1 then begin if FirstShiftSelected=-1 then FirstShiftSelected:=lastselected; //select everything from FirstShiftSelected to sel for i:=0 to numberofrecords-1 do selected[i]:=false; Lastselected:=numberofrecords-1; if FirstShiftSelected<lastselected then for i:=FirstShiftselected to lastselected do selected[i]:=true else for i:=FirstShiftSelected downto lastselected do selected[i]:=true; end; end else begin if lastselected<numberofRecords-1 then begin for i:=0 to numberofRecords-1 do selected[i]:=false; Lastselected:=numberofrecords-1; selected[LastSelected]:=true; end; end; if lastselected<scrollbar1.position then scrollbar1.Position:=lastselected; if lastselected>scrollbar1.position+5 then scrollbar1.Position:=lastselected-5; Updatescreen; end; VK_UP: begin if not ((ssShift) in (Shift)) then FirstShiftSelected:=-1; if ssShift in Shift then //ctrl does nothing begin if lastselected>0 then begin if FirstShiftSelected=-1 then FirstShiftSelected:=lastselected; //select everything from FirstShiftSelected to sel for i:=0 to numberofrecords-1 do selected[i]:=false; Lastselected:=lastselected-1; if FirstShiftSelected<lastselected then for i:=FirstShiftselected to lastselected do selected[i]:=true else for i:=FirstShiftSelected downto lastselected do selected[i]:=true; end; end else begin if lastselected>0 then begin for i:=0 to numberofRecords-1 do selected[i]:=false; Lastselected:=lastselected-1; selected[lastselected]:=true; end; end; if lastselected>scrollbar1.position+5 then scrollbar1.Position:=lastselected-5; if lastselected<scrollbar1.position then scrollbar1.Position:=lastselected; Updatescreen; end; VK_DOWN: begin if not ((ssShift) in (Shift)) then FirstShiftSelected:=-1; if ssShift in Shift then //ctrl does nothing begin if lastselected<numberofRecords-1 then begin if FirstShiftSelected=-1 then FirstShiftSelected:=lastselected; //select everything from FirstShiftSelected to sel for i:=0 to numberofrecords-1 do selected[i]:=false; Lastselected:=lastselected+1; if FirstShiftSelected<lastselected then for i:=FirstShiftselected to lastselected do selected[i]:=true else for i:=FirstShiftSelected downto lastselected do selected[i]:=true; end; end else begin if lastselected<numberofRecords-1 then begin for i:=0 to numberofRecords-1 do selected[i]:=false; Lastselected:=Lastselected+1; selected[LastSelected]:=true; end; end; if lastselected<scrollbar1.position then scrollbar1.Position:=lastselected; if lastselected>scrollbar1.position+5 then scrollbar1.Position:=lastselected-5; Updatescreen; end; vk_prior: begin //page up if not ((ssShift) in (Shift)) then FirstShiftSelected:=-1; if ssShift in Shift then //ctrl does nothing begin if lastselected>0 then begin if FirstShiftSelected=-1 then FirstShiftSelected:=lastselected; //select everything from FirstShiftSelected to sel for i:=0 to numberofrecords-1 do selected[i]:=false; if LastSelected>5 then Lastselected:=lastselected-6 else LastSelected:=0; if FirstShiftSelected<lastselected then for i:=FirstShiftselected to lastselected do selected[i]:=true else for i:=FirstShiftSelected downto lastselected do selected[i]:=true; end; end else begin if lastselected>0 then begin for i:=0 to numberofRecords-1 do selected[i]:=false; if lastselected>5 then Lastselected:=lastselected-6 else LastSelected:=0; selected[lastselected]:=true; end; end; if lastselected<scrollbar1.position then scrollbar1.Position:=lastselected; if lastselected>scrollbar1.position+5 then scrollbar1.Position:=lastselected-5; Updatescreen; end; vk_next: begin //page down if not ((ssShift) in (Shift)) then FirstShiftSelected:=-1; if ssShift in Shift then //ctrl does nothing begin if lastselected<numberofRecords-1 then begin if FirstShiftSelected=-1 then FirstShiftSelected:=lastselected; //select everything from FirstShiftSelected to sel for i:=0 to numberofrecords-1 do selected[i]:=false; if Lastselected+5<numberofrecords-1 then Lastselected:=lastselected+5 else Lastselected:=Numberofrecords-1; if FirstShiftSelected<lastselected then for i:=FirstShiftselected to lastselected do selected[i]:=true else for i:=FirstShiftSelected downto lastselected do selected[i]:=true; end; end else begin if lastselected<numberofRecords-1 then begin for i:=0 to numberofRe
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -