/components/messagecomposer/messagecomposer.pas

http://github.com/graemeg/lazarus · Pascal · 993 lines · 865 code · 57 blank · 71 comment · 110 complexity · 26bb5453c0df23f2b8a6adad05cbb8dd MD5 · raw file

  1. { Copyright (C) 2007 Salvatore Coppola
  2. This library is free software; you can redistribute it and/or modify it
  3. under the terms of the GNU Library General Public License as published by
  4. the Free Software Foundation; either version 2 of the License, or (at your
  5. option) any later version.
  6. This program is distributed in the hope that it will be useful, but WITHOUT
  7. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  8. FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
  9. for more details.
  10. You should have received a copy of the GNU Library General Public License
  11. along with this library; if not, write to the Free Software Foundation,
  12. Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  13. Abstract:
  14. This unit is a message dialog composer for Lazarus/FPC.
  15. It takes into account all message dialogs platform indpendently.
  16. }
  17. unit MessageComposer;
  18. {$mode objfpc}{$H+}
  19. interface
  20. uses
  21. Classes, SysUtils, LResources, LCLType, Forms, Controls, Graphics, Dialogs,
  22. StdCtrls, ExtCtrls, Spin, Grids, ActnList, Buttons, EditBtn,
  23. IDECommands, MenuIntf, LazIDEIntf, SrcEditorIntf;
  24. type
  25. { TFormMessagesComposer }
  26. TFormMessagesComposer = class(TForm)
  27. KindMessageComboBox: TComboBox;
  28. KindMessageLabel: TLabel;
  29. MsgMemo: TMemo;
  30. ButtonsNotebook: TNotebook;
  31. PageString: TPage;
  32. ButtonPanel: TPanel;
  33. SourceNotebook: TNotebook;
  34. Page1: TPage;
  35. Page2: TPage;
  36. PageIf: TPage;
  37. PageCase: TPage;
  38. UpdateQuestioDlgResult: TAction;
  39. SetIfOrCase: TAction;
  40. PositionBevel: TBevel;
  41. Bevel2: TBevel;
  42. HelpCtxBevel: TBevel;
  43. CaseResultCheckGroup: TCheckGroup;
  44. BeginEndCheckBox: TCheckBox;
  45. IfResultComboBox: TComboBox;
  46. StringResultEdit: TEdit;
  47. GetParamsFmt: TAction;
  48. OkButton: TBitBtn;
  49. CancelButton: TBitBtn;
  50. GetMessageForSource: TAction;
  51. Label1: TLabel;
  52. StringResultLabel: TLabel;
  53. IfThenRadioButton: TRadioButton;
  54. IfThenElseRadioButton: TRadioButton;
  55. CaseOfEndRadioButton: TRadioButton;
  56. CaseOfEndElseRadioButton: TRadioButton;
  57. SourceWrapperGroupBox: TGroupBox;
  58. Test: TAction;
  59. TestButton: TButton;
  60. MaskInputCheckBox: TCheckBox;
  61. PromptEdit: TEdit;
  62. ValueEdit: TEdit;
  63. PromptLabel: TLabel;
  64. HelpFileNameEdit: TFileNameEdit;
  65. HelpFileNameLabel: TLabel;
  66. MessagesInit: TAction;
  67. DefaultEdit: TEdit;
  68. ValueLabel: TLabel;
  69. DefaultValue: TLabel;
  70. XLabel: TLabel;
  71. YLabel: TLabel;
  72. MessageSetup: TAction;
  73. BitBtn1: TBitBtn;
  74. BitBtn2: TBitBtn;
  75. DelConst: TAction;
  76. AddConst: TAction;
  77. ActionList1: TActionList;
  78. CaptionEdit: TEdit;
  79. ButtonsCheckGroup: TCheckGroup;
  80. DlgTypeComboBox: TComboBox;
  81. DlgTypeLabel: TLabel;
  82. HelpKeyWordEdit: TEdit;
  83. HelpContextLabel: TLabel;
  84. HelpKeyWordLabel: TLabel;
  85. CaptionLabel: TLabel;
  86. MsgLabel: TLabel;
  87. HelpContextSpinEdit: TSpinEdit;
  88. ButtonsStringGrid: TStringGrid;
  89. ButtonsPanel: TPanel;
  90. Panel2: TPanel;
  91. XSpinEdit: TSpinEdit;
  92. YSpinEdit: TSpinEdit;
  93. procedure AddConstExecute(Sender: TObject);
  94. procedure ButtonsCheckGroupItemClick(Sender: TObject; {%H-}Index: integer);
  95. procedure ButtonsStringGridSelectEditor(Sender: TObject; aCol,
  96. {%H-}aRow: Integer; var Editor: TWinControl);
  97. procedure DelConstExecute(Sender: TObject);
  98. procedure GetMessageForSourceExecute(Sender: TObject);
  99. procedure GetParamsFmtExecute(Sender: TObject);
  100. procedure MessageSetupExecute(Sender: TObject);
  101. procedure MessagesInitExecute(Sender: TObject);
  102. procedure SetIfOrCaseExecute(Sender: TObject);
  103. procedure TestExecute(Sender: TObject);
  104. procedure UpdateQuestioDlgResultExecute(Sender: TObject);
  105. private
  106. { private declarations }
  107. public
  108. { public declarations }
  109. end;
  110. procedure Register;
  111. var
  112. srcMessage: string;
  113. implementation
  114. {$R *.lfm}
  115. const
  116. cMessageComposer = 'Message Composer';
  117. DoubleSpace = ' ';
  118. idxPageIf = 0;
  119. idxPageCase = 1;
  120. idxPageString = 2;
  121. type
  122. TComposedMsgKind = (
  123. cmkMsgDlgSimple, //MessageDlg[Msg, DlgType, Buttons(TMsgDlgButtons), HelpCtx]
  124. cmkMsgDlgCaption, //MessageDlg[Caption, Msg, DlgType, Buttons(TMsgDlgButtons), HelpCtx]
  125. cmkMsgDlgCaptionHelpKeyWord, //MessageDlg[Caption, Msg, DlgType, Buttons(TMsgDlgButtons), HelpKeyword]
  126. cmkMsgDlgPosSimple, //MessageDlgPos[Msg, DlgType, Buttons(TMsgDlgButtons), HelpCtx, X, Y]
  127. cmkMsgDlgPosHelpSimple, //MessageDlgPosHelp[Msg, DlgType, Buttons(TMsgDlgButtons), HelpCtx, X, Y, HelpFileName]
  128. cmkQDlgHelpCtx, //QuestionDlg[Caption, Msg, DlgType, Buttons(array of const), HelpCtx]
  129. cmkQDlgHelpKeyword, //QuestionDlg[Caption, Msg, DlgType, Buttons(array of const), HelpKeyword]
  130. cmkShowMsg, //ShowMessage[Msg: string];
  131. cmkShowMsgFmt, //ShowMessageFmt[Msg, Params(array of const)];
  132. cmkShowMsgPos, //ShowMessagePos[Msg, X, Y];
  133. cmkInpQMask, //InputQuery[Caption, Prompt, MaskInput(Boolean), Value(String)]
  134. cmkInpQSimple, //InputQuery[Caption, Prompt, Value(String)]
  135. cmkInpBox, //InputBox[Caption, Prompt, Default]
  136. cmkPasswBox //PasswordBox[Caption, Prompt]
  137. );
  138. const ComposedMsgStrings: array[TComposedMsgKind] of string = (
  139. 'MessageDlg[Msg, DlgType, Buttons(TMsgDlgButtons), HelpCtx]',
  140. 'MessageDlg[Caption, Msg, DlgType, Buttons(TMsgDlgButtons), HelpCtx]',
  141. 'MessageDlg[Caption, Msg, DlgType, Buttons(TMsgDlgButtons), HelpKeyword]',
  142. 'MessageDlgPos[Msg, DlgType, Buttons(TMsgDlgButtons), HelpCtx, X, Y]',
  143. 'MessageDlgPosHelp[Msg, DlgType, Buttons(TMsgDlgButtons), HelpCtx, X, Y, HelpFileName]',
  144. 'QuestionDlg[Caption, Msg, DlgType, Buttons(array of const), HelpCtx]',
  145. 'QuestionDlg[Caption, Msg, DlgType, Buttons(array of const), HelpKeyword]',
  146. 'ShowMessage[Msg: string];',
  147. 'ShowMessageFmt[Msg, Params(array of const)];',
  148. 'ShowMessagePos[Msg, X, Y];',
  149. 'InputQuery[Caption, Prompt, MaskInput(Boolean), Value(String)]',
  150. 'InputQuery[Caption, Prompt, Value(String)]',
  151. 'InputBox[Caption, Prompt, Default]',
  152. 'PasswordBox[Caption, Prompt]'
  153. );
  154. resourcestring
  155. SMessageComposerMenuCaption = 'Message Composer ...';
  156. SMessageComposerCaption = 'Message Composer';
  157. SMsgCaption = 'The message to be shown';
  158. SDlgCaption = 'Dialog caption';
  159. SDlgType = 'Dialog type';
  160. SPromptCaption = 'Text asking the user for input';
  161. SMaskInput = 'Mask input';
  162. SSourceWrapper = 'Source wrapper';
  163. SKindofMessage = 'Kind of message';
  164. SNotImplementedYet = 'Not implemented yet';
  165. rsTest = 'Test';
  166. rsOk = 'OK';
  167. rsCancel = 'Cancel';
  168. SHelpContext = 'Help context';
  169. SHelpKeyword = 'Help keyword';
  170. SHelpFilename = 'Help filename';
  171. SValueVar = 'Value (var)';
  172. SDefault = 'Default';
  173. SButtonsTMsgDlgButtons = 'Buttons (TMsgDlgButtons)';
  174. SAdd = 'Add';
  175. SDelete = 'Delete';
  176. SButtonsArrayOfConst = 'Buttons (array of const)';
  177. SModalResult = 'Modal result';
  178. SIfResult = '"If" result';
  179. SCaseResult = '"Case" result';
  180. var
  181. CmdMessageComposer: TIDECommand;
  182. { This is where it all starts. Gets called from Lazarus. }
  183. procedure ExecuteMessagesComposer(Sender: TObject);
  184. var FormMessagesComposer: TFormMessagesComposer;
  185. procedure FormatSrcMessage;
  186. var ListSrcMessages: TStringList;
  187. indx: integer;
  188. BaseStart: string;
  189. begin
  190. BaseStart := EmptyStr;
  191. for indx := 1 to SourceEditorManagerIntf.ActiveEditor.CursorTextXY.x-
  192. Length(SourceEditorManagerIntf.ActiveEditor.Selection)-1 do
  193. BaseStart := BaseStart+#32;
  194. ListSrcMessages := TStringList.Create;
  195. ListSrcMessages.Text := srcMessage;
  196. if (Pos('if ',srcMessage) = 1)or(Pos('case ',srcMessage) = 1) then
  197. for indx := 1 to ListSrcMessages.Count-1 do
  198. ListSrcMessages.Strings[indx] := BaseStart+ListSrcMessages.Strings[indx];
  199. if Pos('case ',srcMessage) = 1 then
  200. for indx := 1 to ListSrcMessages.Count-2 do
  201. ListSrcMessages.Strings[indx] := DoubleSpace+ListSrcMessages.Strings[indx];
  202. srcMessage := ListSrcMessages.Text;
  203. ListSrcMessages.Free;
  204. end;
  205. begin
  206. Assert(Sender <> nil); // removes compiler warning
  207. if SourceEditorManagerIntf.ActiveEditor = nil then exit;
  208. FormMessagesComposer := TFormMessagesComposer.Create(nil);
  209. try
  210. FormMessagesComposer.ShowModal;
  211. if FormMessagesComposer.ModalResult = mrOK then begin
  212. FormMessagesComposer.GetMessageForSource.Execute;
  213. FormatSrcMessage;
  214. SourceEditorManagerIntf.ActiveEditor.Selection := srcMessage;
  215. end;
  216. finally
  217. FormMessagesComposer.Free;
  218. end;
  219. end;
  220. { TFormMessagesComposer }
  221. procedure TFormMessagesComposer.AddConstExecute(Sender: TObject);
  222. begin
  223. ButtonsStringGrid.RowCount := ButtonsStringGrid.RowCount+1;
  224. ButtonsStringGrid.AutoAdjustColumns;
  225. UpdateQuestioDlgResult.Execute;
  226. end;
  227. procedure TFormMessagesComposer.ButtonsCheckGroupItemClick(Sender: TObject;
  228. Index: integer);
  229. begin
  230. MessageSetup.Execute;
  231. end;
  232. procedure TFormMessagesComposer.ButtonsStringGridSelectEditor(Sender: TObject; aCol,
  233. aRow: Integer; var Editor: TWinControl);
  234. var
  235. ComposedMsgKind: TComposedMsgKind;
  236. begin
  237. if aCol<>1 then exit;
  238. ComposedMsgKind := TComposedMsgKind(KindMessageComboBox.ItemIndex);
  239. case ComposedMsgKind of
  240. cmkQDlgHelpCtx, cmkQDlgHelpKeyword: begin
  241. Editor := TStringGrid(Sender).EditorByStyle(cbsPickList);
  242. TPickListCellEditor(Editor).Style := csDropDownList;
  243. TPickListCellEditor(Editor).Clear;
  244. TPickListCellEditor(Editor).Items.Add(ModalResultStr[mrNone]);
  245. TPickListCellEditor(Editor).Items.Add(ModalResultStr[mrOK]);
  246. TPickListCellEditor(Editor).Items.Add(ModalResultStr[mrCancel]);
  247. TPickListCellEditor(Editor).Items.Add(ModalResultStr[mrAbort]);
  248. TPickListCellEditor(Editor).Items.Add(ModalResultStr[mrRetry]);
  249. TPickListCellEditor(Editor).Items.Add(ModalResultStr[mrIgnore]);
  250. TPickListCellEditor(Editor).Items.Add(ModalResultStr[mrYes]);
  251. TPickListCellEditor(Editor).Items.Add(ModalResultStr[mrNo]);
  252. TPickListCellEditor(Editor).Items.Add(ModalResultStr[mrAll]);
  253. TPickListCellEditor(Editor).Items.Add(ModalResultStr[mrNoToAll]);
  254. TPickListCellEditor(Editor).Items.Add(ModalResultStr[mrYesToAll]);
  255. end;
  256. cmkShowMsgFmt: begin
  257. Editor := TStringGrid(Sender).EditorByStyle(cbsAuto);
  258. //D Decimal format. Precision digits in it
  259. //E Scientific format. Args is a Floating point value. Precision is used to specify the total number of decimals (exponent is3 digits)
  260. //F Fixed point format. Args is a floating point value. Precision indicates the number of digits following the decimal point.
  261. //G General number format. Args is a floating point value. The argument is converted to a decimal string using fixed point notation or scientific notation, depending on which gives the shortest result. Precision is used to determine the number of digits after the decimal point.
  262. //M Currency format. Args must be a floating point value. The argument is converted to a decimal string using currency notation. This means that fixed-point notation is used, but that the currency symbol is appended. If precision is specified, then then it overrides the CurrencyDecimals global variable used in the FloatToStrF
  263. //N Number format. This is the same as fixed point format, except that thousand separators are inserted in the resulting string.
  264. //P Pointer format. The next argument in the Args array must be a pointer (typed or untyped). The pointer value is converted to a string of length 8, representing the hexadecimal value of the pointer.
  265. //S String format. The next argument in the Args array must be a string. The argument is simply copied to the result string. If Precision is specified, then only Precision characters are copied to the result string.
  266. //U Unsigned decimal format. The next argument in the Args array should be an unsigned integer. The argument is converted to a decimal string. If precision is specified, then the string will have at least Precision digits in it. If needed, the string is (left) padded with zeroes.
  267. //X hexadecimal format. The next argument in the Args array must be an integer. The argument is converted to a hexadecimal string with just enough characters to contain the value of the integer. If Precision is specified then the resulting hexadecimal representation will have at least Precision characters in it (with a maximum value of 32).
  268. end;
  269. end;
  270. ButtonsStringGrid.AutoAdjustColumns;
  271. end;
  272. procedure TFormMessagesComposer.DelConstExecute(Sender: TObject);
  273. begin
  274. if ButtonsStringGrid.RowCount = 1 then exit;
  275. ButtonsStringGrid.RowCount := ButtonsStringGrid.RowCount-1;
  276. ButtonsStringGrid.AutoAdjustColumns;
  277. UpdateQuestioDlgResult.Execute;
  278. end;
  279. procedure TFormMessagesComposer.GetMessageForSourceExecute(Sender: TObject);
  280. var Msg, MsgCaption, MsgHelpKeyword, HelpFileName, Prompt, MsgDefault,
  281. Value, DlgType, MsgButtons, HelpCtx, X, Y, strParam: string;
  282. i: integer;
  283. intParam: integer;
  284. floatParam: double;
  285. ComposedMsgKind: TComposedMsgKind;
  286. const
  287. BoolS: Array[Boolean] of String = ('False','True');
  288. begin
  289. ComposedMsgKind := TComposedMsgKind(KindMessageComboBox.ItemIndex);
  290. Msg := QuotedStr(MsgMemo.Lines.Text);
  291. if Copy(Msg,Length(Msg)-Length(LineEnding),Length(LineEnding))=LineEnding then
  292. Delete(Msg,Length(Msg)-Length(LineEnding),Length(LineEnding));
  293. i := pos(LineEnding,Msg);
  294. while i>0 do begin
  295. Delete(Msg,i,Length(LineEnding));
  296. system.Insert(QuotedStr('+LineEnding+'),Msg,i);
  297. i := pos(LineEnding,Msg)
  298. end;
  299. DlgType := DlgTypeComboBox.Text;
  300. MsgButtons := EmptyStr;
  301. if ButtonsNotebook.PageIndex = 0 then begin //MessageDlg();
  302. if ButtonsCheckGroup.Checked[0] then
  303. MsgButtons := MsgButtons+' mbYes,';
  304. if ButtonsCheckGroup.Checked[1] then
  305. MsgButtons := MsgButtons+' mbNo,';
  306. if ButtonsCheckGroup.Checked[2] then
  307. MsgButtons := MsgButtons+' mbOK,';
  308. if ButtonsCheckGroup.Checked[3] then
  309. MsgButtons := MsgButtons+' mbCancel,';
  310. if ButtonsCheckGroup.Checked[4] then
  311. MsgButtons := MsgButtons+' mbAbort,';
  312. if ButtonsCheckGroup.Checked[5] then
  313. MsgButtons := MsgButtons+' mbRetry,';
  314. if ButtonsCheckGroup.Checked[6] then
  315. MsgButtons := MsgButtons+' mbIgnore,';
  316. if ButtonsCheckGroup.Checked[7] then
  317. MsgButtons := MsgButtons+' mbAll,';
  318. if ButtonsCheckGroup.Checked[8] then
  319. MsgButtons := MsgButtons+' mbNoToAll,';
  320. if ButtonsCheckGroup.Checked[9] then
  321. MsgButtons := MsgButtons+' mbYesToAll,';
  322. if ButtonsCheckGroup.Checked[10] then
  323. MsgButtons := MsgButtons+' mbHelp,';
  324. if ButtonsCheckGroup.Checked[11] then
  325. MsgButtons := MsgButtons+' mbClose,';
  326. end else begin //maybe QuestionDlg() or ShowMessageFmt();
  327. if ComposedMsgKind=cmkShowMsgFmt then begin //ShowMessageFmt();
  328. for i := 1 to ButtonsStringGrid.RowCount-1 do begin
  329. //'D', 'E', 'F', 'G', 'M', 'N', 'P', 'S', 'U', 'X' format
  330. strParam := #32;
  331. if (ButtonsStringGrid.Cells[0, i] = '%D') then begin
  332. intParam := StrToIntDef(ButtonsStringGrid.Cells[1, i], 0);
  333. strParam := IntToStr(intParam);
  334. end;
  335. if (ButtonsStringGrid.Cells[0, i] = '%E')or
  336. (ButtonsStringGrid.Cells[0, i] = '%F')or
  337. (ButtonsStringGrid.Cells[0, i] = '%G')or
  338. (ButtonsStringGrid.Cells[0, i] = '%M')or
  339. (ButtonsStringGrid.Cells[0, i] = '%N') then begin
  340. floatParam := StrToFloatDef(ButtonsStringGrid.Cells[1, i], 0.0);
  341. strParam := FloatToStr(floatParam);
  342. if pos('.',strParam) = 0 then
  343. strParam := strParam+'.0';
  344. end;
  345. if (ButtonsStringGrid.Cells[0, i] = '%P') then
  346. strParam := ButtonsStringGrid.Cells[1, i];//user must knows pointer var in his source
  347. if (ButtonsStringGrid.Cells[0, i] = '%S') then
  348. strParam := QuotedStr(ButtonsStringGrid.Cells[1, i]);
  349. if (ButtonsStringGrid.Cells[0, i] = '%U') then begin
  350. intParam := abs(StrToIntDef(ButtonsStringGrid.Cells[1, i], 0));
  351. strParam := IntToStr(intParam);
  352. end;
  353. if (ButtonsStringGrid.Cells[0, i] = '%X') then begin
  354. intParam := StrToIntDef(ButtonsStringGrid.Cells[1, i], 0);
  355. strParam := IntToStr(intParam);
  356. end;
  357. if strParam<>#32 then
  358. MsgButtons := MsgButtons+#32+strParam+',';
  359. end;
  360. if strParam=#32 then
  361. MsgButtons := strParam+',';
  362. end else
  363. for i := 1 to ButtonsStringGrid.RowCount-1 do begin
  364. if (ButtonsStringGrid.Cells[1, i] = EmptyStr)or
  365. (ButtonsStringGrid.Cells[0, i] = EmptyStr) then continue;
  366. MsgButtons := MsgButtons+#32+ButtonsStringGrid.Cells[1, i]+', '+
  367. QuotedStr(ButtonsStringGrid.Cells[0, i])+',';
  368. end;
  369. end;
  370. if MsgButtons<>EmptyStr then begin
  371. MsgButtons[1] := '[';
  372. MsgButtons[Length(MsgButtons)] := ']';
  373. end else
  374. MsgButtons:='[]';
  375. MsgCaption := QuotedStr(CaptionEdit.Text);
  376. HelpCtx := HelpContextSpinEdit.Text;
  377. MsgHelpKeyword := QuotedStr(HelpKeyWordEdit.Text);
  378. HelpFileName := QuotedStr(HelpFileNameEdit.Text);
  379. X := XSpinEdit.Text;
  380. Y := YSpinEdit.Text;
  381. Prompt := QuotedStr(PromptEdit.Text);
  382. MsgDefault := QuotedStr(DefaultEdit.Text);
  383. Value := ValueEdit.Text;//user must knows Value var in his source
  384. case ComposedMsgKind of
  385. cmkMsgDlgSimple: srcMessage := 'MessageDlg('+Msg+', '+DlgType+', '+MsgButtons+','+HelpCtx+')';
  386. cmkMsgDlgCaption: srcMessage := 'MessageDlg('+MsgCaption+', '+Msg+', '+DlgType+', '+
  387. MsgButtons+', '+HelpCtx+')';
  388. cmkMsgDlgCaptionHelpKeyWord: srcMessage := 'MessageDlg('+MsgCaption+', '+Msg+', '+DlgType+', '+
  389. MsgButtons+', '+MsgHelpKeyword+')';
  390. cmkMsgDlgPosSimple: srcMessage := 'MessageDlgPos('+Msg+', '+DlgType+', '+MsgButtons+', '+
  391. HelpCtx+', '+X+', '+Y+')';
  392. cmkMsgDlgPosHelpSimple: srcMessage := 'MessageDlgPosHelp('+Msg+', '+DlgType+', '+MsgButtons+', '+
  393. HelpCtx+', '+X+', '+Y+', '+HelpFileName+')';
  394. cmkQDlgHelpCtx: srcMessage := 'QuestionDlg('+MsgCaption+', '+Msg+', '+DlgType+', '+
  395. MsgButtons+', '+HelpCtx+')';
  396. cmkQDlgHelpKeyword: srcMessage := 'QuestionDlg('+MsgCaption+', '+Msg+', '+DlgType+', '+
  397. MsgButtons+', '+MsgHelpKeyword+')';
  398. cmkShowMsg: srcMessage := 'ShowMessage('+Msg+')';
  399. cmkShowMsgFmt: srcMessage := 'ShowMessageFmt('+Msg+', '+MsgButtons+')';
  400. cmkShowMsgPos: srcMessage := 'ShowMessagePos('+Msg+', '+X+', '+Y+')';
  401. cmkInpQMask: srcMessage := 'InputQuery('+MsgCaption+', '+Prompt+', '+
  402. BoolS[MaskInputCheckBox.Checked]+', '+Value+')';
  403. cmkInpQSimple: srcMessage := 'InputQuery('+MsgCaption+', '+Prompt+', '+Value+')';
  404. cmkInpBox: srcMessage := 'InputBox('+MsgCaption+', '+Prompt+', '+MsgDefault+')';
  405. cmkPasswBox: srcMessage := 'PasswordBox('+MsgCaption+', '+Prompt+')'
  406. end;
  407. if SourceWrapperGroupBox.Enabled then begin //no showmessages
  408. if (IfThenRadioButton.Checked)or(IfThenElseRadioButton.Checked) then begin
  409. srcMessage := 'if '+srcMessage+' = ';
  410. if SourceNoteBook.PageIndex <> idxPageString then
  411. srcMessage := srcMessage+IfResultComboBox.Text
  412. else
  413. srcMessage := srcMessage+QuotedStr(StringResultEdit.Text);
  414. srcMessage := srcMessage+' then';
  415. if BeginEndCheckBox.Checked then
  416. srcMessage := srcMessage+' begin '+LineEnding+'end';
  417. end;
  418. if IfThenElseRadioButton.Checked then begin
  419. srcMessage := srcMessage+LineEnding+'else';
  420. if BeginEndCheckBox.Checked then
  421. srcMessage := srcMessage+' begin '+LineEnding+'end';
  422. end;
  423. if CaseOfEndRadioButton.Checked then begin
  424. srcMessage := 'case '+srcMessage+' of'+LineEnding;
  425. for i := 0 to CaseResultCheckGroup.Items.Count-1 do begin
  426. if not CaseResultCheckGroup.Checked[i] then continue;
  427. if BeginEndCheckBox.Checked then
  428. srcMessage := srcMessage+CaseResultCheckGroup.Items[i]+
  429. ': begin'+LineEnding+'end;'+LineEnding
  430. else
  431. srcMessage := srcMessage+CaseResultCheckGroup.Items[i]+
  432. ': ;'+LineEnding;
  433. end;
  434. srcMessage := srcMessage+'end;'
  435. end;
  436. if CaseOfEndElseRadioButton.Checked then begin
  437. srcMessage := 'case '+srcMessage+' of'+LineEnding;
  438. for i := 0 to CaseResultCheckGroup.Items.Count-1 do begin
  439. if not CaseResultCheckGroup.Checked[i] then continue;
  440. if BeginEndCheckBox.Checked then
  441. srcMessage := srcMessage+CaseResultCheckGroup.Items[i]+
  442. ': begin'+LineEnding+'end;'+LineEnding
  443. else
  444. srcMessage := srcMessage+CaseResultCheckGroup.Items[i]+
  445. ': ;'+LineEnding;
  446. end;
  447. if BeginEndCheckBox.Checked then
  448. srcMessage := srcMessage+'else begin'+LineEnding+'end;'+LineEnding
  449. else
  450. srcMessage := srcMessage+'else'+LineEnding;
  451. srcMessage := srcMessage+'end;'
  452. end;
  453. end;
  454. end;
  455. procedure TFormMessagesComposer.GetParamsFmtExecute(Sender: TObject);
  456. const FormatParams = ['D', 'E', 'F', 'G', 'M', 'N', 'P', 'S', 'U', 'X'];
  457. var strtmp: string;
  458. ListParams: TStringList;
  459. indx: integer;
  460. chrtmp: Char;
  461. ComposedMsgKind: TComposedMsgKind;
  462. begin
  463. ComposedMsgKind := TComposedMsgKind(KindMessageComboBox.ItemIndex);
  464. if ComposedMsgKind<>cmkShowMsgFmt then exit;
  465. ButtonsStringGrid.Cells[0, 0] := 'Params (array of const)';
  466. ButtonsStringGrid.Cells[1, 0] := 'Values';
  467. ButtonsStringGrid.FixedCols := 1;
  468. Panel2.Visible := false;
  469. ListParams := TStringList.Create;
  470. strtmp := UpperCase(MsgMemo.Lines.Text);
  471. indx := pos('%', strtmp);
  472. while (indx>0)and(indx<Length(strtmp)) do begin
  473. chrtmp := strtmp[indx+1];
  474. if chrtmp in FormatParams then
  475. ListParams.Add('%'+chrtmp);
  476. Delete(strtmp, indx, 1);
  477. indx := pos('%',strtmp);
  478. end;
  479. if ListParams.Count>0 then begin
  480. ListParams.Insert(0,'Params (array of const)');
  481. ButtonsStringGrid.RowCount := ListParams.Count;
  482. if ButtonsStringGrid.Cols[0].Text<>ListParams.Text then
  483. ButtonsStringGrid.Cols[0] := ListParams;
  484. end;
  485. ListParams.Free;
  486. ButtonsStringGrid.AutoAdjustColumns;
  487. end;
  488. procedure TFormMessagesComposer.MessageSetupExecute(Sender: TObject);
  489. var indx: integer;
  490. ListResult: TStringList;
  491. ComposedMsgKind: TComposedMsgKind;
  492. begin
  493. ComposedMsgKind := TComposedMsgKind(KindMessageComboBox.ItemIndex);
  494. if ComposedMsgKind in [cmkMsgDlgSimple,cmkMsgDlgCaption,cmkMsgDlgCaptionHelpKeyWord,
  495. cmkMsgDlgPosSimple,cmkMsgDlgPosHelpSimple] then
  496. ButtonsNotebook.PageIndex := 0 // ButtonsCheckGroup
  497. else
  498. ButtonsNotebook.PageIndex := 1; // ButtonsPanel
  499. //Msg
  500. case ComposedMsgKind of
  501. cmkMsgDlgSimple,cmkMsgDlgCaption,cmkMsgDlgCaptionHelpKeyWord,
  502. cmkMsgDlgPosSimple,cmkMsgDlgPosHelpSimple,
  503. cmkQDlgHelpCtx,cmkQDlgHelpKeyword,cmkShowMsg,
  504. cmkShowMsgFmt,cmkShowMsgPos:
  505. begin
  506. MsgMemo.Color := clWindow;
  507. MsgMemo.Enabled := true;
  508. end;
  509. else begin
  510. MsgMemo.Color := clBtnFace;
  511. MsgMemo.Enabled := false;
  512. end;
  513. end;
  514. //Caption
  515. case ComposedMsgKind of
  516. cmkMsgDlgCaption,
  517. cmkMsgDlgCaptionHelpKeyWord,
  518. cmkQDlgHelpCtx,
  519. cmkQDlgHelpKeyword,
  520. cmkInpQMask,
  521. cmkInpQSimple,
  522. cmkInpBox,
  523. cmkPasswBox: begin
  524. CaptionEdit.Color := clWindow;
  525. CaptionEdit.Enabled := true;
  526. end;
  527. else begin
  528. CaptionEdit.Color := clBtnFace;
  529. CaptionEdit.Enabled := false;
  530. end;
  531. end;
  532. //DlgType;
  533. case ComposedMsgKind of
  534. cmkMsgDlgSimple,
  535. cmkMsgDlgCaption,
  536. cmkMsgDlgCaptionHelpKeyWord,
  537. cmkMsgDlgPosSimple,
  538. cmkMsgDlgPosHelpSimple,
  539. cmkQDlgHelpCtx,
  540. cmkQDlgHelpKeyword: begin
  541. DlgTypeComboBox.Color := clWindow;
  542. DlgTypeComboBox.Enabled := true;
  543. end;
  544. else begin
  545. DlgTypeComboBox.Color := clBtnFace;
  546. DlgTypeComboBox.Enabled := false;
  547. end;
  548. end;
  549. //HelpContext
  550. case ComposedMsgKind of
  551. cmkMsgDlgSimple,
  552. cmkMsgDlgCaption,
  553. cmkMsgDlgPosSimple,
  554. cmkMsgDlgPosHelpSimple,
  555. cmkQDlgHelpCtx: begin
  556. HelpContextSpinEdit.Color := clWindow;
  557. HelpContextSpinEdit.Enabled := true;
  558. end;
  559. else begin
  560. HelpContextSpinEdit.Color := clBtnFace;
  561. HelpContextSpinEdit.Enabled := false;
  562. end;
  563. end;
  564. //HelpKeyword
  565. case ComposedMsgKind of
  566. cmkMsgDlgCaptionHelpKeyWord,
  567. cmkQDlgHelpKeyword: begin
  568. HelpKeyWordEdit.Color := clWindow;
  569. HelpKeyWordEdit.Enabled := true;
  570. end;
  571. else begin
  572. HelpKeyWordEdit.Color := clBtnFace;
  573. HelpKeyWordEdit.Enabled := false;
  574. end;
  575. end;
  576. //Position X Y
  577. case ComposedMsgKind of
  578. cmkMsgDlgPosSimple,
  579. cmkMsgDlgPosHelpSimple,
  580. cmkShowMsgPos: begin
  581. XSpinEdit.Color := clWindow;
  582. XSpinEdit.Enabled := true;
  583. YSpinEdit.Color := clWindow;
  584. YSpinEdit.Enabled := true;
  585. end;
  586. else begin
  587. XSpinEdit.Color := clBtnFace;
  588. XSpinEdit.Enabled := false;
  589. YSpinEdit.Color := clBtnFace;
  590. YSpinEdit.Enabled := false;
  591. end;
  592. end;
  593. //HelpFileName
  594. case ComposedMsgKind of
  595. cmkMsgDlgPosHelpSimple: begin
  596. HelpFileNameEdit.Color := clWindow;
  597. HelpFileNameEdit.Enabled := true;
  598. end;
  599. else begin
  600. HelpFileNameEdit.Color := clBtnFace;
  601. HelpFileNameEdit.Enabled := false;
  602. end;
  603. end;
  604. //Params (array of const)
  605. case ComposedMsgKind of
  606. cmkShowMsgFmt: begin
  607. GetParamsFmt.Execute;
  608. end;
  609. else begin
  610. ButtonsStringGrid.Cells[0, 0] := SButtonsArrayOfConst;
  611. ButtonsStringGrid.Cells[1, 0] := SModalResult;
  612. ButtonsStringGrid.FixedCols := 0;
  613. Panel2.Visible := true;
  614. end;
  615. end;
  616. //Prompt
  617. case ComposedMsgKind of
  618. cmkInpQMask,
  619. cmkInpQSimple,
  620. cmkInpBox,
  621. cmkPasswBox: begin
  622. PromptEdit.Color := clWindow;
  623. PromptEdit.Enabled := true;
  624. end;
  625. else begin
  626. PromptEdit.Color := clBtnFace;
  627. PromptEdit.Enabled := false;
  628. end;
  629. end;
  630. //MaskInput
  631. case ComposedMsgKind of
  632. cmkInpQMask: begin
  633. MaskInputCheckBox.Enabled := true;
  634. end;
  635. else begin
  636. MaskInputCheckBox.Enabled := false;
  637. end;
  638. end;
  639. //Value
  640. case ComposedMsgKind of
  641. cmkInpQMask,
  642. cmkInpQSimple: begin
  643. ValueEdit.Color := clWindow;
  644. ValueEdit.Enabled := true;
  645. end;
  646. else begin
  647. ValueEdit.Color := clBtnFace;
  648. ValueEdit.Enabled := false;
  649. end;
  650. end;
  651. //Default
  652. case ComposedMsgKind of
  653. cmkInpBox: begin
  654. DefaultEdit.Color := clWindow;
  655. DefaultEdit.Enabled := true;
  656. end;
  657. else begin
  658. DefaultEdit.Color := clBtnFace;
  659. DefaultEdit.Enabled := false;
  660. end;
  661. end;
  662. ///// Results and Source Wrapper for message //////
  663. //InputBox(); PasswordBox();
  664. case ComposedMsgKind of
  665. cmkInpBox,
  666. cmkPasswBox: begin
  667. SourceNotebook.PageIndex := idxPageString;
  668. if CaseOfEndRadioButton.Checked then IfThenRadioButton.Checked := True;
  669. if CaseOfEndElseRadioButton.Checked then IfThenElseRadioButton.Checked := True;
  670. CaseOfEndRadioButton.Enabled := False;
  671. CaseOfEndElseRadioButton.Enabled := False;
  672. //StringResultEdit.Enabled := true;
  673. //StringResultEdit.Color := clWindow;
  674. //IfResultComboBox.Enabled := false;
  675. //IfResultComboBox.Color := clBtnFace;
  676. //CaseResultCheckGroup.Enabled := false;
  677. //CaseOfEndElseRadioButton.Enabled := false;
  678. //CaseOfEndRadioButton.Enabled := false;
  679. end;
  680. else begin
  681. CaseOfEndRadioButton.Enabled := True;
  682. CaseOfEndElseRadioButton.Enabled := True;
  683. if IfThenRadioButton.Checked or IfThenElseRadioButton.Checked then
  684. SourceNotebook.PageIndex := idxPageIf
  685. else
  686. SourceNotebook.PageIndex := idxPageCase;
  687. //StringResultEdit.Enabled := false;
  688. //StringResultEdit.Color := clBtnFace;
  689. //IfResultComboBox.Enabled := true;
  690. //IfResultComboBox.Color := clWindow;
  691. //CaseResultCheckGroup.Enabled := true;
  692. //CaseOfEndElseRadioButton.Enabled := true;
  693. //CaseOfEndRadioButton.Enabled := true;
  694. end;
  695. end;
  696. //ShowMessage(); ShowMessageFmt(); ShowMessagePos();
  697. case ComposedMsgKind of
  698. cmkShowMsg,
  699. cmkShowMsgFmt,
  700. cmkShowMsgPos: SourceWrapperGroupBox.Enabled := false;
  701. else
  702. SourceWrapperGroupBox.Enabled := true;
  703. end;
  704. //MessageDlg() Result
  705. case ComposedMsgKind of
  706. cmkMsgDlgSimple,
  707. cmkMsgDlgCaption,
  708. cmkMsgDlgCaptionHelpKeyWord,
  709. cmkMsgDlgPosSimple,
  710. cmkMsgDlgPosHelpSimple: begin
  711. ListResult := TStringList.Create;
  712. for indx := 0 to ButtonsCheckGroup.Items.Count-1 do
  713. if ButtonsCheckGroup.Checked[indx] then begin
  714. if ButtonsCheckGroup.Items[indx] = 'mbOK' then
  715. ListResult.Add(ModalResultStr[mrOK]);
  716. if ButtonsCheckGroup.Items[indx] = 'mbCancel' then
  717. ListResult.Add(ModalResultStr[mrCancel]);
  718. if ButtonsCheckGroup.Items[indx] = 'mbYes' then
  719. ListResult.Add(ModalResultStr[mrYes]);
  720. if ButtonsCheckGroup.Items[indx] = 'mbNo' then
  721. ListResult.Add(ModalResultStr[mrNo]);
  722. if ButtonsCheckGroup.Items[indx] = 'mbAbort' then
  723. ListResult.Add(ModalResultStr[mrAbort]);
  724. if ButtonsCheckGroup.Items[indx] = 'mbRetry' then
  725. ListResult.Add(ModalResultStr[mrRetry]);
  726. if ButtonsCheckGroup.Items[indx] = 'mbIgnore' then
  727. ListResult.Add(ModalResultStr[mrIgnore]);
  728. if ButtonsCheckGroup.Items[indx] = 'mbAll' then
  729. ListResult.Add(ModalResultStr[mrAll]);
  730. if ButtonsCheckGroup.Items[indx] = 'mbNoToAll' then
  731. ListResult.Add(ModalResultStr[mrNoToAll]);
  732. if ButtonsCheckGroup.Items[indx] = 'mbYesToAll' then
  733. ListResult.Add(ModalResultStr[mrYesToAll]);
  734. if (ButtonsCheckGroup.Items[indx] = 'mbClose')and
  735. (ListResult.IndexOf(ModalResultStr[mrCancel]) = -1) then
  736. ListResult.Add(ModalResultStr[mrCancel]);
  737. end;
  738. if ListResult.Text<>IfResultComboBox.Items.Text then begin
  739. IfResultComboBox.Items := ListResult;
  740. CaseResultCheckGroup.Items := ListResult;
  741. if ListResult.Count>0 then begin
  742. IfResultComboBox.ItemIndex := 0;
  743. CaseResultCheckGroup.Checked[0] := true;
  744. end;
  745. end;
  746. ListResult.Free;
  747. end;
  748. end;
  749. //QuestionDlg() Result
  750. case ComposedMsgKind of
  751. cmkQDlgHelpCtx,
  752. cmkQDlgHelpKeyword: begin
  753. ListResult := TStringList.Create;
  754. ListResult.Assign(ButtonsStringGrid.Cols[1]);
  755. ListResult.Delete(0);
  756. if ListResult.Text<>IfResultComboBox.Items.Text then begin
  757. IfResultComboBox.Items := ListResult;
  758. CaseResultCheckGroup.Items := ListResult;
  759. if ListResult.Count>0 then begin
  760. IfResultComboBox.ItemIndex := 0;
  761. CaseResultCheckGroup.Checked[0] := true;
  762. end;
  763. end;
  764. ListResult.Free;
  765. end;
  766. end;
  767. //InputQuery() Result
  768. case ComposedMsgKind of
  769. cmkInpQMask,
  770. cmkInpQSimple: if (CaseResultCheckGroup.Items.Count=0) or (CaseResultCheckGroup.Items[0]<>'false') then begin
  771. CaseResultCheckGroup.Items.Clear;
  772. CaseResultCheckGroup.Items.Add('false');
  773. CaseResultCheckGroup.Items.Add('true');
  774. IfResultComboBox.Items := CaseResultCheckGroup.Items;
  775. IfResultComboBox.ItemIndex := 0;
  776. CaseResultCheckGroup.Checked[0] := true;
  777. end;
  778. end;
  779. ButtonsStringGrid.AutoAdjustColumns;
  780. ButtonsPanel.Visible := not (ComposedMsgKind in [cmkShowMsg,cmkShowMsgPos,
  781. cmkInpQMask,cmkInpQSimple,cmkInpBox,cmkPasswBox]);
  782. end;
  783. procedure TFormMessagesComposer.MessagesInitExecute(Sender: TObject);
  784. begin
  785. XSpinEdit.MaxValue := Screen.Width;
  786. XLabel.Caption := 'X ('+IntToStr(Screen.Width)+')';
  787. YSpinEdit.MaxValue := Screen.Height;
  788. YLabel.Caption := 'Y ('+IntToStr(Screen.Height)+')';
  789. HelpContextSpinEdit.Width := 80;
  790. XSpinEdit.Width := 60;
  791. YSpinEdit.Width := 60;
  792. KindMessageComboBox.Clear;
  793. KindMessageCombobox.Items.AddStrings(ComposedMsgStrings);
  794. KindMessageComboBox.ItemIndex := 0;
  795. Caption := SMessageComposerCaption;
  796. CaptionLabel.Caption := SDlgCaption;
  797. DlgTypeLabel.Caption := SDlgType;
  798. MsgLabel.Caption := SMsgCaption;
  799. ButtonsCheckGroup.Caption := SButtonsTMsgDlgButtons;
  800. ButtonsStringGrid.Cells[0,0] := SButtonsArrayOfConst;
  801. ButtonsStringGrid.Cells[1,0] := SModalResult;
  802. BitBtn1.Caption := SAdd;
  803. BitBtn2.Caption := SDelete;
  804. PromptLabel.Caption := SPromptCaption;
  805. MaskInputCheckBox.Caption := SMaskInput;
  806. ValueLabel.Caption := SValueVar;
  807. DefaultValue.Caption := SDefault;
  808. SourceWrapperGroupBox.Caption := SSourceWrapper;
  809. KindMessageLabel.Caption := SKindofMessage;
  810. Label1.Caption := SIfResult;
  811. CaseResultCheckGroup.Caption := SCaseResult;
  812. TestButton.Caption:=rsTest;
  813. OkButton.Caption:=rsOk;
  814. CancelButton.Caption:=rsCancel;
  815. HelpContextLabel.Caption := SHelpContext;
  816. HelpKeyWordLabel.Caption := SHelpKeyword;
  817. HelpFileNameLabel.Caption := SHelpFilename;
  818. MessageSetup.Execute;
  819. end;
  820. procedure TFormMessagesComposer.SetIfOrCaseExecute(Sender: TObject);
  821. var
  822. ComposedMsgKind: TComposedMsgKind;
  823. begin
  824. ComposedMsgKind := TComposedMsgKind(KindMessageComboBox.ItemIndex);
  825. if (ComposedMsgKind in [cmkInpBox, cmkPasswBox]) then exit;
  826. if IfThenRadioButton.Checked or IfThenElseRadioButton.Checked then
  827. SourceNotebook.PageIndex := idxPageIf
  828. else
  829. SourceNotebook.PageIndex := idxPageCase;
  830. end;
  831. procedure TFormMessagesComposer.TestExecute(Sender: TObject);
  832. var Msg, MsgCaption, MsgHelpKeyword, HelpFileName, Prompt,
  833. MsgDefault, Value: string;
  834. DlgType: TMsgDlgType;
  835. MsgButtons: TMsgDlgButtons;
  836. HelpCtx: Longint;
  837. X, Y: integer;
  838. ComposedMsgKind: TComposedMsgKind;
  839. begin
  840. Msg := MsgMemo.Lines.Text;
  841. DlgType := TMsgDlgType(DlgTypeComboBox.ItemIndex);
  842. MsgButtons := [];
  843. if ButtonsCheckGroup.Checked[0] then
  844. MsgButtons := MsgButtons+[mbYes];
  845. if ButtonsCheckGroup.Checked[1] then
  846. MsgButtons := MsgButtons+[mbNo];
  847. if ButtonsCheckGroup.Checked[2] then
  848. MsgButtons := MsgButtons+[mbOK];
  849. if ButtonsCheckGroup.Checked[3] then
  850. MsgButtons := MsgButtons+[mbCancel];
  851. if ButtonsCheckGroup.Checked[4] then
  852. MsgButtons := MsgButtons+[mbAbort];
  853. if ButtonsCheckGroup.Checked[5] then
  854. MsgButtons := MsgButtons+[mbRetry];
  855. if ButtonsCheckGroup.Checked[6] then
  856. MsgButtons := MsgButtons+[mbIgnore];
  857. if ButtonsCheckGroup.Checked[7] then
  858. MsgButtons := MsgButtons+[mbAll];
  859. if ButtonsCheckGroup.Checked[8] then
  860. MsgButtons := MsgButtons+[mbNoToAll];
  861. if ButtonsCheckGroup.Checked[9] then
  862. MsgButtons := MsgButtons+[mbYesToAll];
  863. if ButtonsCheckGroup.Checked[10] then
  864. MsgButtons := MsgButtons+[mbHelp];
  865. if ButtonsCheckGroup.Checked[11] then
  866. MsgButtons := MsgButtons+[mbClose];
  867. MsgCaption := CaptionEdit.Text;
  868. HelpCtx := HelpContextSpinEdit.Value;
  869. HelpKeyword := HelpKeyWordEdit.Text;
  870. X := XSpinEdit.Value;
  871. Y := YSpinEdit.Value;
  872. Prompt := PromptEdit.Text;
  873. MsgDefault := DefaultEdit.Text;
  874. Value := ValueEdit.Text;
  875. HelpFileName:='';
  876. MsgHelpKeyword:='';
  877. ComposedMsgKind := TComposedMsgKind(KindMessageComboBox.ItemIndex);
  878. case ComposedMsgKind of
  879. cmkMsgDlgSimple: MessageDlg(Msg, DlgType, MsgButtons, HelpCtx);
  880. cmkMsgDlgCaption: MessageDlg(MsgCaption, Msg, DlgType, MsgButtons, HelpCtx);
  881. cmkMsgDlgCaptionHelpKeyWord: MessageDlg(MsgCaption, Msg, DlgType, MsgButtons, MsgHelpKeyword);
  882. cmkMsgDlgPosSimple: MessageDlgPos(Msg, DlgType, MsgButtons, HelpCtx, X, Y);
  883. cmkMsgDlgPosHelpSimple: MessageDlgPosHelp(Msg, DlgType, MsgButtons, HelpCtx, X, Y, HelpFileName);
  884. cmkQDlgHelpCtx: QuestionDlg(MsgCaption, Msg+' ('+SNotImplementedYet+')', DlgType, [mrYes, 'Yes', mrNo, 'No',
  885. mrCancel, 'Cancel'], HelpCtx);
  886. cmkQDlgHelpKeyword: QuestionDlg(MsgCaption, Msg+' ('+SNotImplementedYet+')', DlgType, [mrYes, 'Yes', mrNo, 'No',
  887. mrCancel, 'Cancel'], HelpKeyword);
  888. cmkShowMsg: ShowMessage(Msg);
  889. cmkShowMsgFmt: ShowMessageFmt(Msg+' ('+SNotImplementedYet+')', ['Yes','No','Cancel']);
  890. cmkShowMsgPos: ShowMessagePos(Msg, X, Y);
  891. cmkInpQMask: InputQuery(MsgCaption, Prompt, MaskInputCheckBox.Checked, Value);
  892. cmkInpQSimple: InputQuery(MsgCaption, Prompt, Value);
  893. cmkInpBox: InputBox(Caption, Prompt, MsgDefault);
  894. cmkPasswBox: PasswordBox(MsgCaption, Prompt)
  895. end;
  896. end;
  897. procedure TFormMessagesComposer.UpdateQuestioDlgResultExecute(Sender: TObject);
  898. var ListResult: TStringList;
  899. begin
  900. ListResult := TStringList.Create;
  901. ListResult.Assign(ButtonsStringGrid.Cols[1]);
  902. ListResult.Delete(0);
  903. if ListResult.Text<>IfResultComboBox.Items.Text then begin
  904. IfResultComboBox.Items := ListResult;
  905. CaseResultCheckGroup.Items := ListResult;
  906. if ListResult.Count>0 then begin
  907. IfResultComboBox.ItemIndex := 0;
  908. CaseResultCheckGroup.Checked[0] := true;
  909. end;
  910. end;
  911. ListResult.Free;
  912. end;
  913. { Registers a keyboard shortcut and menu item in Lazarus}
  914. procedure Register;
  915. var
  916. Key1,Key2: TIDEShortCut;
  917. Cat: TIDECommandCategory;
  918. begin
  919. Key1 := IDEShortCut(VK_M, [ssCtrl], VK_UNKNOWN, []);
  920. Key2 := IDEShortCut(VK_UNKNOWN, [], VK_UNKNOWN, []);
  921. Cat := IDECommandList.CreateCategory(Nil, cMessageComposer,
  922. SMessageComposerCaption,
  923. IDECmdScopeSrcEditOnly);
  924. CmdMessageComposer := RegisterIDECommand(Cat, cMessageComposer,
  925. SMessageComposerCaption,
  926. Key1, Key2,nil,
  927. @ExecuteMessagesComposer);
  928. RegisterIDEMenuCommand(itmSourceTools, cMessageComposer,
  929. SMessageComposerMenuCaption,
  930. nil, nil, CmdMessageComposer);
  931. end;
  932. end.