BillsPasteSelectFrm.pas 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. unit BillsPasteSelectFrm;
  2. interface
  3. uses
  4. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5. Dialogs, ExtCtrls, StdCtrls;
  6. type
  7. TBillsPasteSelectForm = class(TForm)
  8. btnOk: TButton;
  9. btnCancel: TButton;
  10. pnlPos: TPanel;
  11. rbNext: TRadioButton;
  12. rbPre: TRadioButton;
  13. rbChild: TRadioButton;
  14. Label1: TLabel;
  15. procedure btnOkClick(Sender: TObject);
  16. private
  17. FCanBeChild: Boolean;
  18. function GetPos: Integer;
  19. procedure SetCanBeChild(const Value: Boolean);
  20. public
  21. property Pos: Integer read GetPos;
  22. property CanBeChild: Boolean read FCanBeChild write SetCanBeChild;
  23. end;
  24. function SelectBillsPasteType(var APos: Integer; ACanBeChild: Boolean): Boolean;
  25. implementation
  26. uses
  27. UtilMethods;
  28. {$R *.dfm}
  29. function SelectBillsPasteType(var APos: Integer; ACanBeChild: Boolean): Boolean;
  30. var
  31. SelectForm: TBillsPasteSelectForm;
  32. begin
  33. SelectForm := TBillsPasteSelectForm.Create(nil);
  34. try
  35. SelectForm.CanBeChild := ACanBeChild;
  36. Result := SelectForm.ShowModal = mrOk;
  37. if Result then
  38. APos := SelectForm.Pos;
  39. finally
  40. SelectForm.Free;
  41. end;
  42. end;
  43. { TBillsPasteSelectForm }
  44. function TBillsPasteSelectForm.GetPos: Integer;
  45. begin
  46. if rbChild.Checked then
  47. Result := 0
  48. else if rbNext.Checked then
  49. Result := 1
  50. else if rbPre.Checked then
  51. Result := 2
  52. else
  53. Result := -1;
  54. end;
  55. procedure TBillsPasteSelectForm.btnOkClick(Sender: TObject);
  56. begin
  57. if (Pos = -1) then
  58. WarningMessage('粘贴层次结构模式下,须选择插入节点的类型!')
  59. else
  60. ModalResult := mrOk;
  61. end;
  62. procedure TBillsPasteSelectForm.SetCanBeChild(const Value: Boolean);
  63. begin
  64. FCanBeChild := Value;
  65. rbChild.Enabled := FCanBeChild;
  66. end;
  67. end.