MessageDlg.cpp 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include <Consts.hpp>
  5. #include <GUITools.h>
  6. #include <Common.h>
  7. #include <VCLCommon.h>
  8. #include <CoreMain.h>
  9. #include <WinInterface.h>
  10. #include <Tools.h>
  11. #include <TextsWin.h>
  12. #include <TextsCore.h>
  13. #include <Vcl.Imaging.pngimage.hpp>
  14. #include <StrUtils.hpp>
  15. #include <PasTools.hpp>
  16. #include <Math.hpp>
  17. #include <vssym32.h>
  18. //---------------------------------------------------------------------------
  19. #pragma package(smart_init)
  20. //---------------------------------------------------------------------------
  21. class TMessageButton : public TButton
  22. {
  23. public:
  24. __fastcall TMessageButton(TComponent * Owner);
  25. protected:
  26. virtual void __fastcall Dispatch(void * Message);
  27. private:
  28. void __fastcall WMGetDlgCode(TWMGetDlgCode & Message);
  29. };
  30. //---------------------------------------------------------------------------
  31. __fastcall TMessageButton::TMessageButton(TComponent * Owner) :
  32. TButton(Owner)
  33. {
  34. }
  35. //---------------------------------------------------------------------------
  36. void __fastcall TMessageButton::Dispatch(void * Message)
  37. {
  38. TMessage * M = reinterpret_cast<TMessage*>(Message);
  39. if (M->Msg == WM_GETDLGCODE)
  40. {
  41. WMGetDlgCode(*((TWMGetDlgCode *)Message));
  42. }
  43. else
  44. {
  45. TButton::Dispatch(Message);
  46. }
  47. }
  48. //---------------------------------------------------------------------------
  49. void __fastcall TMessageButton::WMGetDlgCode(TWMGetDlgCode & Message)
  50. {
  51. TButton::Dispatch(&Message);
  52. // WORKAROUND
  53. // Windows default handler returns DLGC_WANTARROWS for split buttons,
  54. // what prevent left/right keys from being used for focusing next/previous buttons/controls.
  55. // Overrwide that. Though note that we need to pass the up/down keys back to button
  56. // to allow drop down, see TMessageForm::CMDialogKey
  57. Message.Result = Message.Result & ~DLGC_WANTARROWS;
  58. }
  59. //---------------------------------------------------------------------------
  60. class TMessageForm : public TForm
  61. {
  62. public:
  63. static TForm * __fastcall Create(const UnicodeString & Msg, TStrings * MoreMessages,
  64. TMsgDlgType DlgType, unsigned int Answers,
  65. const TQueryButtonAlias * Aliases, unsigned int AliasesCount,
  66. unsigned int TimeoutAnswer, TButton ** TimeoutButton, const UnicodeString & ImageName,
  67. const UnicodeString & NeverAskAgainCaption);
  68. virtual int __fastcall ShowModal();
  69. protected:
  70. __fastcall TMessageForm(TComponent * AOwner);
  71. virtual __fastcall ~TMessageForm();
  72. DYNAMIC void __fastcall KeyDown(Word & Key, TShiftState Shift);
  73. DYNAMIC void __fastcall KeyUp(Word & Key, TShiftState Shift);
  74. UnicodeString __fastcall GetFormText();
  75. UnicodeString __fastcall GetReportText();
  76. UnicodeString __fastcall NormalizeNewLines(UnicodeString Text);
  77. virtual void __fastcall CreateParams(TCreateParams & Params);
  78. DYNAMIC void __fastcall DoShow();
  79. virtual void __fastcall Dispatch(void * Message);
  80. void __fastcall MenuItemClick(TObject * Sender);
  81. void __fastcall ButtonDropDownClick(TObject * Sender);
  82. void __fastcall UpdateForShiftStateTimer(TObject * Sender);
  83. DYNAMIC void __fastcall SetZOrder(bool TopMost);
  84. private:
  85. typedef std::map<unsigned int, TButton *> TAnswerButtons;
  86. UnicodeString MessageText;
  87. TMemo * MessageMemo;
  88. TShiftState FShiftState;
  89. TTimer * FUpdateForShiftStateTimer;
  90. TForm * FDummyForm;
  91. bool FShowNoActivate;
  92. void __fastcall HelpButtonClick(TObject * Sender);
  93. void __fastcall ReportButtonClick(TObject * Sender);
  94. void __fastcall CMDialogKey(TWMKeyDown & Message);
  95. void __fastcall CMShowingChanged(TMessage & Message);
  96. void __fastcall UpdateForShiftState();
  97. TButton * __fastcall CreateButton(
  98. UnicodeString Name, UnicodeString Caption, unsigned int Answer,
  99. TNotifyEvent OnClick, bool IsTimeoutButton,
  100. int GroupWith, TShiftState GrouppedShiftState,
  101. TAnswerButtons & AnswerButtons, bool HasMoreMessages, int & ButtonWidth);
  102. bool __fastcall ApplicationHook(TMessage & Message);
  103. };
  104. //---------------------------------------------------------------------------
  105. __fastcall TMessageForm::TMessageForm(TComponent * AOwner) : TForm(AOwner, 0)
  106. {
  107. FShowNoActivate = false;
  108. MessageMemo = NULL;
  109. FUpdateForShiftStateTimer = NULL;
  110. Position = poOwnerFormCenter;
  111. UseSystemSettingsPre(this);
  112. FDummyForm = new TForm(this);
  113. UseSystemSettings(FDummyForm);
  114. }
  115. //---------------------------------------------------------------------------
  116. __fastcall TMessageForm::~TMessageForm()
  117. {
  118. SAFE_DESTROY(FDummyForm);
  119. SAFE_DESTROY(FUpdateForShiftStateTimer);
  120. }
  121. //---------------------------------------------------------------------------
  122. void __fastcall TMessageForm::HelpButtonClick(TObject * /*Sender*/)
  123. {
  124. if (HelpKeyword != HELP_NONE)
  125. {
  126. FormHelp(this);
  127. }
  128. else
  129. {
  130. MessageWithNoHelp(GetReportText());
  131. }
  132. }
  133. //---------------------------------------------------------------------------
  134. void __fastcall TMessageForm::ReportButtonClick(TObject * /*Sender*/)
  135. {
  136. UnicodeString Url =
  137. FMTLOAD(ERROR_REPORT_URL,
  138. (EncodeUrlString(GetReportText()), Configuration->ProductVersion,
  139. IntToHex(__int64(GUIConfiguration->Locale), 4)));
  140. OpenBrowser(Url);
  141. }
  142. //---------------------------------------------------------------------------
  143. void __fastcall TMessageForm::UpdateForShiftState()
  144. {
  145. TShiftState ShiftState =
  146. KeyboardStateToShiftState() *
  147. (TShiftState() << ssShift << ssCtrl << ssAlt);
  148. if (FShiftState != ShiftState)
  149. {
  150. FShiftState = ShiftState;
  151. for (int ComponentIndex = 0; ComponentIndex < ComponentCount - 1; ComponentIndex++)
  152. {
  153. TButton * Button = dynamic_cast<TButton*>(Components[ComponentIndex]);
  154. if ((Button != NULL) && (Button->DropDownMenu != NULL))
  155. {
  156. TMenuItem * MenuItems = Button->DropDownMenu->Items;
  157. for (int ItemIndex = 0; ItemIndex < MenuItems->Count; ItemIndex++)
  158. {
  159. TMenuItem * Item = MenuItems->Items[ItemIndex];
  160. TShiftState GrouppedShiftState(Item->Tag >> 16);
  161. if (Item->Enabled &&
  162. ((ShiftState.Empty() && Item->Default) ||
  163. (!ShiftState.Empty() && (ShiftState == GrouppedShiftState))))
  164. {
  165. int From = 1;
  166. Button->Caption = CopyToChars(Item->Caption, From, L"\t", false);
  167. Button->ModalResult = Item->Tag & 0xFFFF;
  168. assert(Button->OnClick == NULL);
  169. assert(Item->OnClick == MenuItemClick);
  170. break;
  171. }
  172. }
  173. }
  174. }
  175. }
  176. }
  177. //---------------------------------------------------------------------------
  178. void __fastcall TMessageForm::KeyUp(Word & Key, TShiftState Shift)
  179. {
  180. UpdateForShiftState();
  181. TForm::KeyUp(Key, Shift);
  182. }
  183. //---------------------------------------------------------------------------
  184. void __fastcall TMessageForm::KeyDown(Word & Key, TShiftState Shift)
  185. {
  186. if (Shift.Contains(ssCtrl) && (Key == L'C'))
  187. {
  188. TInstantOperationVisualizer Visualizer;
  189. CopyToClipboard(GetFormText());
  190. }
  191. else
  192. {
  193. if (!Shift.Contains(ssCtrl))
  194. {
  195. for (int ComponentIndex = 0; ComponentIndex < ComponentCount - 1; ComponentIndex++)
  196. {
  197. TButton * Button = dynamic_cast<TButton*>(Components[ComponentIndex]);
  198. if ((Button != NULL) && (Button->DropDownMenu != NULL))
  199. {
  200. TMenuItem * MenuItems = Button->DropDownMenu->Items;
  201. for (int ItemIndex = 0; ItemIndex < MenuItems->Count; ItemIndex++)
  202. {
  203. TMenuItem * Item = MenuItems->Items[ItemIndex];
  204. if (IsAccel(Key, MenuItems->Items[ItemIndex]->Caption))
  205. {
  206. Item->OnClick(Item);
  207. Key = 0;
  208. break;
  209. }
  210. }
  211. }
  212. if (Key == 0)
  213. {
  214. break;
  215. }
  216. }
  217. }
  218. UpdateForShiftState();
  219. TForm::KeyDown(Key, Shift);
  220. }
  221. }
  222. //---------------------------------------------------------------------------
  223. UnicodeString __fastcall TMessageForm::NormalizeNewLines(UnicodeString Text)
  224. {
  225. Text = ReplaceStr(Text, L"\r", L"");
  226. Text = ReplaceStr(Text, L"\n", L"\r\n");
  227. return Text;
  228. }
  229. //---------------------------------------------------------------------------
  230. UnicodeString __fastcall TMessageForm::GetFormText()
  231. {
  232. UnicodeString DividerLine, ButtonCaptions;
  233. DividerLine = UnicodeString::StringOfChar(L'-', 27) + sLineBreak;
  234. for (int i = 0; i < ComponentCount - 1; i++)
  235. {
  236. if (dynamic_cast<TButton*>(Components[i]) != NULL)
  237. {
  238. ButtonCaptions += dynamic_cast<TButton*>(Components[i])->Caption +
  239. UnicodeString::StringOfChar(L' ', 3);
  240. }
  241. }
  242. ButtonCaptions = ReplaceStr(ButtonCaptions, L"&", L"");
  243. UnicodeString MoreMessages;
  244. if (MessageMemo != NULL)
  245. {
  246. MoreMessages = MessageMemo->Text + DividerLine;
  247. }
  248. UnicodeString MessageCaption = NormalizeNewLines(MessageText);
  249. UnicodeString Result = FORMAT(L"%s%s%s%s%s%s%s%s%s%s%s", (DividerLine, Caption, sLineBreak,
  250. DividerLine, MessageCaption, sLineBreak, DividerLine, MoreMessages,
  251. ButtonCaptions, sLineBreak, DividerLine));
  252. return Result;
  253. }
  254. //---------------------------------------------------------------------------
  255. UnicodeString __fastcall TMessageForm::GetReportText()
  256. {
  257. UnicodeString Text = MessageText;
  258. if (MessageMemo != NULL)
  259. {
  260. Text += L"\n" + MessageMemo->Text;
  261. }
  262. Text = NormalizeNewLines(Text);
  263. UnicodeString ReportErrorText = NormalizeNewLines(FMTLOAD(REPORT_ERROR, (L"")));
  264. Text = ReplaceStr(Text, ReportErrorText, L"");
  265. Text = Trim(Text);
  266. return Text;
  267. }
  268. //---------------------------------------------------------------------------
  269. void __fastcall TMessageForm::CMDialogKey(TWMKeyDown & Message)
  270. {
  271. // this gets used in WinInterface.cpp SetTimeoutEvents
  272. if (OnKeyDown != NULL)
  273. {
  274. OnKeyDown(this, Message.CharCode, KeyDataToShiftState(Message.KeyData));
  275. }
  276. if (Message.CharCode == VK_MENU)
  277. {
  278. bool AnyButtonWithGrouppedCommandsWithShiftState = false;
  279. for (int ComponentIndex = 0; ComponentIndex < ComponentCount - 1; ComponentIndex++)
  280. {
  281. TButton * Button = dynamic_cast<TButton*>(Components[ComponentIndex]);
  282. if ((Button != NULL) && (Button->DropDownMenu != NULL))
  283. {
  284. // we should check if there are any commands with shift state,
  285. // but it's bit overkill
  286. AnyButtonWithGrouppedCommandsWithShiftState = true;
  287. break;
  288. }
  289. }
  290. // this is to make Alt only alter button meaning (if there is any
  291. // alternable button) and not popup system menu
  292. if (AnyButtonWithGrouppedCommandsWithShiftState)
  293. {
  294. Message.Result = 1;
  295. UpdateForShiftState();
  296. }
  297. else
  298. {
  299. TForm::Dispatch(&Message);
  300. }
  301. }
  302. else if ((Message.CharCode == VK_UP) || (Message.CharCode == VK_DOWN))
  303. {
  304. // WORKAROUND
  305. // noop to make up/down be passed back to button to allow drop down,
  306. // see TMessageButton::WMGetDlgCode
  307. }
  308. else
  309. {
  310. TForm::Dispatch(&Message);
  311. }
  312. }
  313. //---------------------------------------------------------------------------
  314. int __fastcall TMessageForm::ShowModal()
  315. {
  316. if (IsApplicationMinimized())
  317. {
  318. FShowNoActivate = true;
  319. }
  320. int Result = TForm::ShowModal();
  321. Application->UnhookMainWindow(ApplicationHook);
  322. return Result;
  323. }
  324. //---------------------------------------------------------------------------
  325. void __fastcall TMessageForm::SetZOrder(bool TopMost)
  326. {
  327. // WORKAROUND: If application is minimized,
  328. // swallow call to BringToFront() from TForm::ShowModal()
  329. if (FShowNoActivate && TopMost)
  330. {
  331. // noop
  332. }
  333. else
  334. {
  335. TForm::SetZOrder(TopMost);
  336. }
  337. }
  338. //---------------------------------------------------------------------------
  339. bool __fastcall TMessageForm::ApplicationHook(TMessage & Message)
  340. {
  341. bool Result = false;
  342. // If application is restored, message box is not activated, do it manually.
  343. // We cannot do this from TApplication::OnActivate because
  344. // TApplication.WndProc resets focus to the last active window afterwards.
  345. // So we override CM_ACTIVATE implementation here completelly.
  346. if ((Message.Msg == CM_ACTIVATE) && FShowNoActivate)
  347. {
  348. ::SetFocus(Handle);
  349. // VCLCOPY
  350. if (Application->OnActivate != NULL)
  351. {
  352. Application->OnActivate(Application);
  353. }
  354. Result = true;
  355. }
  356. return Result;
  357. }
  358. //---------------------------------------------------------------------------
  359. void __fastcall TMessageForm::CMShowingChanged(TMessage & Message)
  360. {
  361. if (Showing && FShowNoActivate)
  362. {
  363. // With is same as SendToBack, except for added SWP_NOACTIVATE (VCLCOPY)
  364. SetWindowPos(WindowHandle, HWND_BOTTOM, 0, 0, 0, 0,
  365. SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
  366. // This replaces TCustomForm::CMShowingChanged()
  367. // which calls ShowWindow(Handle, SW_SHOWNORMAL).
  368. ShowWindow(Handle, SW_SHOWNOACTIVATE);
  369. // - so we have to call DoShow explicitly.
  370. DoShow();
  371. // - also we skip applying TForm::Position (VCLCOPY)
  372. if (ALWAYS_TRUE(Position == poOwnerFormCenter))
  373. {
  374. TCustomForm * CenterForm = Application->MainForm;
  375. TCustomForm * OwnerForm = dynamic_cast<TCustomForm *>(Owner);
  376. if (OwnerForm != NULL)
  377. {
  378. CenterForm = OwnerForm;
  379. }
  380. int X, Y;
  381. if ((CenterForm != NULL) && (CenterForm != this))
  382. {
  383. TRect Bounds = CenterForm->BoundsRect;
  384. X = ((Bounds.Width() - Width) / 2) + CenterForm->Left;
  385. Y = ((Bounds.Height() - Height) / 2) + CenterForm->Top;
  386. }
  387. else
  388. {
  389. X = (Screen->Width - Width) / 2;
  390. Y = (Screen->Height - Height) / 2;
  391. }
  392. if (X < Screen->DesktopLeft)
  393. {
  394. X = Screen->DesktopLeft;
  395. }
  396. if (Y < Screen->DesktopTop)
  397. {
  398. Y = Screen->DesktopTop;
  399. }
  400. SetBounds(X, Y, Width, Height);
  401. // We cannot call SetWindowToMonitor().
  402. // We cannot set FPosition = poDesigned, so worlarea-checking code
  403. // in DoFormWindowProc is not triggered
  404. }
  405. // wait for application to be activate to activate ourself
  406. Application->HookMainWindow(ApplicationHook);
  407. }
  408. else
  409. {
  410. TForm::Dispatch(&Message);
  411. }
  412. }
  413. //---------------------------------------------------------------------------
  414. void __fastcall TMessageForm::Dispatch(void * Message)
  415. {
  416. TMessage * M = reinterpret_cast<TMessage*>(Message);
  417. if (M->Msg == CM_DIALOGKEY)
  418. {
  419. CMDialogKey(*((TWMKeyDown *)Message));
  420. }
  421. else if (M->Msg == CM_SHOWINGCHANGED)
  422. {
  423. CMShowingChanged(*M);
  424. }
  425. else
  426. {
  427. TForm::Dispatch(Message);
  428. }
  429. }
  430. //---------------------------------------------------------------------------
  431. void __fastcall TMessageForm::CreateParams(TCreateParams & Params)
  432. {
  433. TForm::CreateParams(Params);
  434. if ((Screen != NULL) && (Screen->ActiveForm != NULL) &&
  435. Screen->ActiveForm->HandleAllocated())
  436. {
  437. Params.WndParent = Screen->ActiveForm->Handle;
  438. }
  439. }
  440. //---------------------------------------------------------------------------
  441. void __fastcall TMessageForm::DoShow()
  442. {
  443. UseSystemSettingsPost(this);
  444. TForm::DoShow();
  445. }
  446. //---------------------------------------------------------------------------
  447. void __fastcall TMessageForm::MenuItemClick(TObject * Sender)
  448. {
  449. TMenuItem * Item = NOT_NULL(dynamic_cast<TMenuItem *>(Sender));
  450. ModalResult = (Item->Tag & 0xFFFF);
  451. }
  452. //---------------------------------------------------------------------------
  453. void __fastcall TMessageForm::UpdateForShiftStateTimer(TObject * /*Sender*/)
  454. {
  455. // this is needed to reflect shift state, even when we do not have a keyboard
  456. // focus, what happens when drop down menu is popped up
  457. UpdateForShiftState();
  458. }
  459. //---------------------------------------------------------------------------
  460. void __fastcall TMessageForm::ButtonDropDownClick(TObject * /*Sender*/)
  461. {
  462. // as optimization, do not waste time running timer, unless
  463. // user pops up drop down menu. we do not have a way to stop timer, once
  464. // it closes, but functionaly is does not matter
  465. if (FUpdateForShiftStateTimer == NULL)
  466. {
  467. FUpdateForShiftStateTimer = new TTimer(this);
  468. FUpdateForShiftStateTimer->Interval = 50;
  469. FUpdateForShiftStateTimer->OnTimer = UpdateForShiftStateTimer;
  470. }
  471. }
  472. //---------------------------------------------------------------------------
  473. const ResourceString * Captions[] = { &_SMsgDlgWarning, &_SMsgDlgError, &_SMsgDlgInformation,
  474. &_SMsgDlgConfirm, NULL };
  475. const wchar_t * IconIDs[] = { IDI_EXCLAMATION, IDI_HAND, IDI_ASTERISK,
  476. IDI_QUESTION, NULL };
  477. const int mcHorzMargin = 10;
  478. const int mcVertMargin = 13;
  479. const int mcHorzSpacing = 12;
  480. const int mcButtonVertMargin = 7;
  481. const int mcButtonSpacing = 5;
  482. // includes mcVertMargin
  483. const int mcMoreMessageHeight = 86;
  484. // approximately what Windows Vista task dialogs use,
  485. // actually they probably has fixed width
  486. const int mcMaxDialogWidth = 340;
  487. const int mcMinDialogWidth = 310;
  488. const int mcMinDialogwithMoreMessagesWidth = 400;
  489. //---------------------------------------------------------------------------
  490. static UnicodeString __fastcall GetKeyNameStr(int Key)
  491. {
  492. wchar_t Buf[MAX_PATH];
  493. LONG VirtualKey = MapVirtualKey(Key, MAPVK_VK_TO_VSC);
  494. VirtualKey <<= 16;
  495. if (GetKeyNameText(VirtualKey, Buf, LENOF(Buf)) > 0)
  496. {
  497. NULL_TERMINATE(Buf);
  498. }
  499. else
  500. {
  501. Buf[0] = L'\0';
  502. }
  503. return Buf;
  504. }
  505. //---------------------------------------------------------------------------
  506. TButton * __fastcall TMessageForm::CreateButton(
  507. UnicodeString Name, UnicodeString Caption, unsigned int Answer,
  508. TNotifyEvent OnClick, bool IsTimeoutButton,
  509. int GroupWith, TShiftState GrouppedShiftState,
  510. TAnswerButtons & AnswerButtons, bool HasMoreMessages, int & ButtonWidth)
  511. {
  512. UnicodeString MeasureCaption = Caption;
  513. if (IsTimeoutButton)
  514. {
  515. MeasureCaption = FMTLOAD(TIMEOUT_BUTTON, (MeasureCaption, 99));
  516. }
  517. TRect TextRect;
  518. DrawText(Canvas->Handle,
  519. UnicodeString(MeasureCaption).c_str(), -1,
  520. &TextRect, DT_CALCRECT | DT_LEFT | DT_SINGLELINE |
  521. DrawTextBiDiModeFlagsReadingOnly());
  522. int CurButtonWidth = TextRect.Right - TextRect.Left + ScaleByTextHeightRunTime(this, 16);
  523. TButton * Button = NULL;
  524. if (SupportsSplitButton() &&
  525. (GroupWith >= 0) &&
  526. ALWAYS_TRUE(AnswerButtons.find(GroupWith) != AnswerButtons.end()))
  527. {
  528. TButton * GroupWithButton = AnswerButtons[GroupWith];
  529. if (GroupWithButton->DropDownMenu == NULL)
  530. {
  531. GroupWithButton->Style = TCustomButton::bsSplitButton;
  532. GroupWithButton->DropDownMenu = new TPopupMenu(this);
  533. // cannot handle subitems with shift state,
  534. // if the button has its own handler
  535. // (though it may not be the case still here)
  536. assert(GroupWithButton->OnClick == NULL);
  537. TMenuItem * Item = new TMenuItem(GroupWithButton->DropDownMenu);
  538. GroupWithButton->DropDownMenu->Items->Add(Item);
  539. GroupWithButton->OnDropDownClick = ButtonDropDownClick;
  540. Item->Caption = GroupWithButton->Caption;
  541. Item->OnClick = MenuItemClick;
  542. assert(GroupWithButton->ModalResult <= 0xFFFF);
  543. Item->Tag = GroupWithButton->ModalResult;
  544. Item->Default = true;
  545. }
  546. TMenuItem * Item = new TMenuItem(GroupWithButton->DropDownMenu);
  547. GroupWithButton->DropDownMenu->Items->Add(Item);
  548. // See ShortCutToText in Vcl.Menus.pas
  549. if (GrouppedShiftState == (TShiftState() << ssAlt))
  550. {
  551. Caption = Caption + L"\t" + GetKeyNameStr(VK_MENU);
  552. }
  553. else if (GrouppedShiftState == (TShiftState() << ssCtrl))
  554. {
  555. Caption = Caption + L"\t" + GetKeyNameStr(VK_CONTROL);
  556. }
  557. else if (GrouppedShiftState == (TShiftState() << ssShift))
  558. {
  559. Caption = Caption + L"\t" + GetKeyNameStr(VK_SHIFT);
  560. }
  561. else
  562. {
  563. // do not support combined shift states yet
  564. assert(GrouppedShiftState == TShiftState());
  565. }
  566. Item->Caption = Caption;
  567. if (OnClick != NULL)
  568. {
  569. Item->OnClick = OnClick;
  570. }
  571. else
  572. {
  573. Item->OnClick = MenuItemClick;
  574. assert((Answer <= 0xFFFF) && (GrouppedShiftState.ToInt() <= 0xFFFF));
  575. Item->Tag = Answer + (GrouppedShiftState.ToInt() << 16);
  576. }
  577. // Hard-coded drop down button width (do not know how to ask for system width).
  578. // Also we do not update the max button width for the default groupped
  579. // button caption. We just blindly hope that captions of advanced commands
  580. // are always longer than the caption of simple default command
  581. CurButtonWidth += ScaleByTextHeightRunTime(this, 15);
  582. }
  583. else
  584. {
  585. Button = new TMessageButton(this);
  586. Button->Name = Name;
  587. Button->Parent = this;
  588. Button->Caption = Caption;
  589. // Scale buttons using regular font, so that they are as large as buttons
  590. // on other dialogs (note that they are still higher than Windows Task dialog
  591. // buttons)
  592. Button->Height = ScaleByTextHeightRunTime(FDummyForm, Button->Height);
  593. Button->Width = ScaleByTextHeightRunTime(FDummyForm, Button->Width);
  594. if (OnClick != NULL)
  595. {
  596. Button->OnClick = OnClick;
  597. }
  598. else
  599. {
  600. Button->ModalResult = Answer;
  601. }
  602. if (HasMoreMessages)
  603. {
  604. Button->Anchors = TAnchors() << akBottom << akLeft;
  605. }
  606. // never shrink buttons below their default width
  607. if (Button->Width > CurButtonWidth)
  608. {
  609. CurButtonWidth = Button->Width;
  610. }
  611. }
  612. if (CurButtonWidth > ButtonWidth)
  613. {
  614. ButtonWidth = CurButtonWidth;
  615. }
  616. return Button;
  617. }
  618. //---------------------------------------------------------------------------
  619. void __fastcall AnswerNameAndCaption(
  620. unsigned int Answer, UnicodeString & Name, UnicodeString & Caption)
  621. {
  622. switch (Answer)
  623. {
  624. case qaYes:
  625. Caption = LoadStr(_SMsgDlgYes.Identifier);
  626. Name = L"Yes";
  627. break;
  628. case qaNo:
  629. Caption = LoadStr(_SMsgDlgNo.Identifier);
  630. Name = L"No";
  631. break;
  632. case qaOK:
  633. Caption = LoadStr(_SMsgDlgOK.Identifier);
  634. Name = L"OK";
  635. break;
  636. case qaCancel:
  637. Caption = LoadStr(_SMsgDlgCancel.Identifier);
  638. Name = L"Cancel";
  639. break;
  640. case qaAbort:
  641. Caption = LoadStr(_SMsgDlgAbort.Identifier);
  642. Name = L"Abort";
  643. break;
  644. case qaRetry:
  645. Caption = LoadStr(_SMsgDlgRetry.Identifier);
  646. Name = L"Retry";
  647. break;
  648. case qaIgnore:
  649. Caption = LoadStr(_SMsgDlgIgnore.Identifier);
  650. Name = L"Ignore";
  651. break;
  652. // Own variant to avoid accelerator conflict with "Abort" button.
  653. // Note that as of now, ALL_BUTTON is never actually used,
  654. // because qaAll is always aliased
  655. case qaAll:
  656. Caption = LoadStr(ALL_BUTTON);
  657. Name = L"All";
  658. break;
  659. case qaNoToAll:
  660. Caption = LoadStr(_SMsgDlgNoToAll.Identifier);
  661. Name = L"NoToAll";
  662. break;
  663. // Own variant to avoid accelerator conflict with "Abort" button.
  664. case qaYesToAll:
  665. Caption = LoadStr(YES_TO_ALL_BUTTON);
  666. Name = L"YesToAll";
  667. break;
  668. case qaHelp:
  669. Caption = LoadStr(_SMsgDlgHelp.Identifier);
  670. Name = L"Help";
  671. break;
  672. case qaSkip:
  673. Caption = LoadStr(SKIP_BUTTON);
  674. Name = L"Skip";
  675. break;
  676. case qaReport:
  677. Caption = LoadStr(REPORT_BUTTON);
  678. Name = L"Report";
  679. break;
  680. default:
  681. FAIL;
  682. throw Exception(L"Undefined answer");
  683. }
  684. }
  685. //---------------------------------------------------------------------------
  686. static int __fastcall CalculateWidthOnCanvas(UnicodeString Text, void * Arg)
  687. {
  688. TCanvas * Canvas = static_cast<TCanvas *>(Arg);
  689. return Canvas->TextWidth(Text);
  690. }
  691. //---------------------------------------------------------------------------
  692. TForm * __fastcall TMessageForm::Create(const UnicodeString & Msg,
  693. TStrings * MoreMessages, TMsgDlgType DlgType, unsigned int Answers,
  694. const TQueryButtonAlias * Aliases, unsigned int AliasesCount,
  695. unsigned int TimeoutAnswer, TButton ** TimeoutButton, const UnicodeString & ImageName,
  696. const UnicodeString & NeverAskAgainCaption)
  697. {
  698. unsigned int DefaultAnswer;
  699. if (FLAGSET(Answers, qaOK))
  700. {
  701. DefaultAnswer = qaOK;
  702. }
  703. else if (FLAGSET(Answers, qaYes))
  704. {
  705. DefaultAnswer = qaYes;
  706. }
  707. else
  708. {
  709. DefaultAnswer = qaRetry;
  710. }
  711. unsigned int CancelAnswer = ::CancelAnswer(Answers);
  712. if (TimeoutButton != NULL)
  713. {
  714. *TimeoutButton = NULL;
  715. }
  716. TColor MainInstructionColor = Graphics::clNone;
  717. HFONT MainInstructionFont = 0;
  718. HFONT InstructionFont = 0;
  719. HTHEME Theme = OpenThemeData(0, L"TEXTSTYLE");
  720. if (Theme != NULL)
  721. {
  722. LOGFONT AFont;
  723. COLORREF AColor;
  724. memset(&AFont, 0, sizeof(AFont));
  725. if (GetThemeFont(Theme, NULL, TEXT_MAININSTRUCTION, 0, TMT_FONT, &AFont) == S_OK)
  726. {
  727. MainInstructionFont = CreateFontIndirect(&AFont);
  728. }
  729. if (GetThemeColor(Theme, TEXT_MAININSTRUCTION, 0, TMT_TEXTCOLOR, &AColor) == S_OK)
  730. {
  731. MainInstructionColor = (TColor)AColor;
  732. }
  733. memset(&AFont, 0, sizeof(AFont));
  734. if (GetThemeFont(Theme, NULL, TEXT_INSTRUCTION, 0, TMT_FONT, &AFont) == S_OK)
  735. {
  736. InstructionFont = CreateFontIndirect(&AFont);
  737. }
  738. CloseThemeData(Theme);
  739. }
  740. TMessageForm * Result = SafeFormCreate<TMessageForm>();
  741. if (InstructionFont != 0)
  742. {
  743. Result->Font->Handle = InstructionFont;
  744. }
  745. else
  746. {
  747. Result->Font->Assign(Screen->MessageFont);
  748. }
  749. Configuration->Usage->Set(L"ThemeMessageFontSize", Result->Font->Size);
  750. // make sure we consider sizes of the monitor,
  751. // that is set in DoFormWindowProc(CM_SHOWINGCHANGED) later.
  752. Forms::TMonitor * Monitor = FormMonitor(Result);
  753. Result->BiDiMode = Application->BiDiMode;
  754. Result->BorderStyle = bsDialog;
  755. Result->Canvas->Font = Result->Font;
  756. Result->KeyPreview = true;
  757. int HorzMargin = ScaleByTextHeightRunTime(Result, mcHorzMargin);
  758. int VertMargin = ScaleByTextHeightRunTime(Result, mcVertMargin);
  759. int HorzSpacing = ScaleByTextHeightRunTime(Result, mcHorzSpacing);
  760. int ButtonVertMargin = ScaleByTextHeightRunTime(Result, mcButtonVertMargin);
  761. int ButtonWidth = -1;
  762. int ButtonHeight = -1;
  763. std::vector<TButton *> ButtonControls;
  764. TAnswerButtons AnswerButtons;
  765. for (unsigned int Answer = qaFirst; Answer <= qaLast; Answer = Answer << 1)
  766. {
  767. if (FLAGSET(Answers, Answer))
  768. {
  769. assert(Answer != mrCancel);
  770. UnicodeString Caption;
  771. UnicodeString Name;
  772. AnswerNameAndCaption(Answer, Name, Caption);
  773. TNotifyEvent OnClick = NULL;
  774. int GroupWith = -1;
  775. TShiftState GrouppedShiftState;
  776. if (Aliases != NULL)
  777. {
  778. for (unsigned int i = 0; i < AliasesCount; i++)
  779. {
  780. if (Answer == Aliases[i].Button)
  781. {
  782. if (!Aliases[i].Alias.IsEmpty())
  783. {
  784. Caption = Aliases[i].Alias;
  785. }
  786. OnClick = Aliases[i].OnClick;
  787. GroupWith = Aliases[i].GroupWith;
  788. GrouppedShiftState = Aliases[i].GrouppedShiftState;
  789. assert((OnClick == NULL) || (GrouppedShiftState == TShiftState()));
  790. break;
  791. }
  792. }
  793. }
  794. // we hope that all grouped-with buttons are for answer with greater
  795. // value that the answer to be grouped with
  796. if (GroupWith >= 0)
  797. {
  798. if (ALWAYS_FALSE(GroupWith >= static_cast<int>(Answer)) ||
  799. ALWAYS_FALSE(Answer == TimeoutAnswer) &&
  800. ALWAYS_FALSE(Answer == DefaultAnswer) &&
  801. ALWAYS_FALSE(Answer == CancelAnswer))
  802. {
  803. GroupWith = -1;
  804. }
  805. }
  806. bool IsTimeoutButton = (TimeoutButton != NULL) && (Answer == TimeoutAnswer);
  807. if (Answer == qaHelp)
  808. {
  809. assert(OnClick == NULL);
  810. OnClick = Result->HelpButtonClick;
  811. }
  812. if (Answer == qaReport)
  813. {
  814. assert(OnClick == NULL);
  815. OnClick = Result->ReportButtonClick;
  816. }
  817. TButton * Button = Result->CreateButton(
  818. Name, Caption, Answer,
  819. OnClick, IsTimeoutButton, GroupWith, GrouppedShiftState,
  820. AnswerButtons, (MoreMessages != NULL), ButtonWidth);
  821. if (Button != NULL)
  822. {
  823. ButtonControls.push_back(Button);
  824. Button->Default = (Answer == DefaultAnswer);
  825. Button->Cancel = (Answer == CancelAnswer);
  826. if (ButtonHeight < 0)
  827. {
  828. ButtonHeight = Button->Height;
  829. }
  830. assert(ButtonHeight == Button->Height);
  831. AnswerButtons.insert(TAnswerButtons::value_type(Answer, Button));
  832. if (IsTimeoutButton)
  833. {
  834. *TimeoutButton = Button;
  835. }
  836. }
  837. }
  838. }
  839. int NeverAskAgainWidth = 0;
  840. if (!NeverAskAgainCaption.IsEmpty())
  841. {
  842. NeverAskAgainWidth =
  843. ScaleByTextHeightRunTime(Result, 16) + // checkbox
  844. Result->Canvas->TextWidth(NeverAskAgainCaption) +
  845. ScaleByTextHeightRunTime(Result, 16); // margin
  846. }
  847. int ButtonSpacing = ScaleByTextHeightRunTime(Result, mcButtonSpacing);
  848. int ButtonGroupWidth = NeverAskAgainWidth;
  849. if (!ButtonControls.empty())
  850. {
  851. ButtonGroupWidth += ButtonWidth * ButtonControls.size() +
  852. ButtonSpacing * (ButtonControls.size() - 1);
  853. }
  854. int IconWidth = 0;
  855. const wchar_t * IconID = IconIDs[DlgType];
  856. bool HasIcon = (IconID != NULL) || !ImageName.IsEmpty();
  857. if (HasIcon)
  858. {
  859. IconWidth = 32 + HorzSpacing;
  860. }
  861. assert((ButtonHeight > 0) && (ButtonWidth > 0));
  862. int MaxTextWidth = ScaleByTextHeightRunTime(Result, mcMaxDialogWidth);
  863. // if the dialog would be wide anyway (overwrite confirmation on Windows XP),
  864. // to fit the buttons, do not restrict the text
  865. if (MaxTextWidth < ButtonGroupWidth - IconWidth)
  866. {
  867. MaxTextWidth = ButtonGroupWidth - IconWidth;
  868. }
  869. TPanel * Panel = new TPanel(Result);
  870. Panel->Name = L"Panel";
  871. Panel->Parent = Result;
  872. Panel->Color = clWindow;
  873. Panel->ParentBackground = false;
  874. Panel->Anchors = TAnchors() << akLeft << akRight << akTop;
  875. Panel->BevelOuter = bvNone;
  876. Panel->BevelKind = bkNone;
  877. Panel->Caption = L"";
  878. UnicodeString BodyMsg = Msg;
  879. UnicodeString MainMsg;
  880. if (ExtractMainInstructions(BodyMsg, MainMsg))
  881. {
  882. Result->MessageText = MainMsg + BodyMsg;
  883. BodyMsg = BodyMsg.TrimLeft();
  884. }
  885. else
  886. {
  887. Result->MessageText = BodyMsg;
  888. }
  889. ApplyTabs(Result->MessageText, L' ', NULL, NULL);
  890. // Windows XP (not sure about Vista) does not support Hair space.
  891. // For Windows XP, we still keep the existing hack by using hard-coded spaces
  892. // in resource string
  893. if (CheckWin32Version(6, 1))
  894. {
  895. // Have to be padding with spaces (the smallest space defined, hair space = 1px),
  896. // as tabs actually do not tab, just expand to 8 spaces.
  897. // Otherwise we would have to do custom drawing
  898. // (using GetTabbedTextExtent and TabbedTextOut)
  899. const wchar_t HairSpace = L'\x200A';
  900. ApplyTabs(BodyMsg, HairSpace, CalculateWidthOnCanvas, Result->Canvas);
  901. }
  902. assert(MainMsg.Pos(L"\t") == 0);
  903. int IconTextWidth = -1;
  904. int IconTextHeight = 0;
  905. int ALeft = IconWidth + HorzMargin;
  906. for (int MessageIndex = 0; MessageIndex <= 1; MessageIndex++)
  907. {
  908. UnicodeString LabelMsg;
  909. UnicodeString LabelName;
  910. TColor LabelColor = Graphics::clNone;
  911. HFONT LabelFont = 0;
  912. switch (MessageIndex)
  913. {
  914. case 0:
  915. LabelMsg = MainMsg;
  916. LabelName = L"MainMessage";
  917. LabelColor = MainInstructionColor;
  918. LabelFont = MainInstructionFont;
  919. break;
  920. case 1:
  921. LabelMsg = BodyMsg;
  922. LabelName = L"Message";
  923. break;
  924. default:
  925. FAIL;
  926. break;
  927. }
  928. if (!LabelMsg.IsEmpty())
  929. {
  930. TLabel * Message = new TLabel(Panel);
  931. Message->Name = LabelName;
  932. Message->Parent = Panel;
  933. Message->WordWrap = true;
  934. Message->Caption = LabelMsg;
  935. Message->BiDiMode = Result->BiDiMode;
  936. // added to show & as & for messages containing !& pattern of custom commands
  937. // (suppose that we actually never want to use & as accel in message text)
  938. Message->ShowAccelChar = false;
  939. if (LabelFont != 0)
  940. {
  941. Message->Font->Handle = LabelFont;
  942. if (ALWAYS_TRUE(LabelFont == MainInstructionFont))
  943. {
  944. Configuration->Usage->Set(L"ThemeMainInstructionFontSize", Message->Font->Size);
  945. }
  946. }
  947. if (LabelColor != Graphics::clNone)
  948. {
  949. Message->Font->Color = LabelColor;
  950. }
  951. TRect TextRect;
  952. SetRect(&TextRect, 0, 0, MaxTextWidth, 0);
  953. DrawText(Message->Canvas->Handle, LabelMsg.c_str(), LabelMsg.Length() + 1, &TextRect,
  954. DT_EXPANDTABS | DT_CALCRECT | DT_WORDBREAK | DT_NOPREFIX |
  955. Result->DrawTextBiDiModeFlagsReadingOnly());
  956. int MaxWidth = Monitor->Width - HorzMargin * 2 - IconWidth - 30;
  957. if (TextRect.right > MaxWidth)
  958. {
  959. // this will truncate the text, we should implement something smarter eventually
  960. TextRect.right = MaxWidth;
  961. }
  962. IconTextWidth = Max(IconTextWidth, IconWidth + TextRect.Right);
  963. if (IconTextHeight > 0)
  964. {
  965. IconTextHeight += VertMargin;
  966. }
  967. Message->SetBounds(ALeft, VertMargin + IconTextHeight, TextRect.Right, TextRect.Bottom);
  968. IconTextHeight += TextRect.Bottom;
  969. }
  970. }
  971. assert((IconTextWidth > 0) && (IconTextHeight > 0));
  972. if (HasIcon && (IconTextHeight < 32))
  973. {
  974. IconTextHeight = 32;
  975. }
  976. int MoreMessageHeight = (MoreMessages != NULL ?
  977. ScaleByTextHeightRunTime(Result, mcMoreMessageHeight) : 0);
  978. Panel->SetBounds(0, 0, Result->ClientWidth, VertMargin + IconTextHeight + VertMargin + MoreMessageHeight);
  979. if (MoreMessages != NULL)
  980. {
  981. TMemo * MessageMemo = new TMemo(Panel);
  982. MessageMemo->Name = L"MessageMemo";
  983. MessageMemo->Parent = Panel;
  984. MessageMemo->ReadOnly = true;
  985. MessageMemo->WantReturns = False;
  986. MessageMemo->ScrollBars = ssVertical;
  987. MessageMemo->Anchors = TAnchors() << akLeft << akRight << akTop;
  988. MessageMemo->Lines->Text = MoreMessages->Text;
  989. Result->MessageMemo = MessageMemo;
  990. }
  991. int MinClientWidth =
  992. ScaleByTextHeightRunTime(Result,
  993. (MoreMessages != NULL) ? mcMinDialogwithMoreMessagesWidth : mcMinDialogWidth);
  994. int AClientWidth =
  995. Max(
  996. (IconTextWidth > ButtonGroupWidth ? IconTextWidth : ButtonGroupWidth) +
  997. HorzMargin * 2,
  998. MinClientWidth);
  999. Result->ClientWidth = AClientWidth;
  1000. Result->ClientHeight =
  1001. Panel->Height + ButtonVertMargin + ButtonHeight + ButtonVertMargin;
  1002. Result->Left = (Monitor->Width / 2) - (Result->Width / 2);
  1003. Result->Top = (Monitor->Height / 2) - (Result->Height / 2);
  1004. if (DlgType != mtCustom)
  1005. {
  1006. Result->Caption = LoadResourceString(Captions[DlgType]);
  1007. }
  1008. else
  1009. {
  1010. Result->Caption = Application->Title;
  1011. }
  1012. if ((IconID != NULL) || !ImageName.IsEmpty())
  1013. {
  1014. TImage * Image = new TImage(Panel);
  1015. Image->Name = L"Image";
  1016. Image->Parent = Panel;
  1017. if (!ImageName.IsEmpty())
  1018. {
  1019. LoadResourceImage(Image, ImageName);
  1020. }
  1021. else
  1022. {
  1023. Image->Picture->Icon->Handle = LoadIcon(0, IconID);
  1024. }
  1025. Image->SetBounds(HorzMargin, VertMargin, 32, 32);
  1026. }
  1027. if (Result->MessageMemo != NULL)
  1028. {
  1029. Result->MessageMemo->SetBounds(
  1030. ALeft,
  1031. Panel->Height - MoreMessageHeight,
  1032. Result->ClientWidth - ALeft - HorzMargin,
  1033. MoreMessageHeight - VertMargin);
  1034. }
  1035. int ButtonTop = Panel->Height + ButtonVertMargin;
  1036. int X = Result->ClientWidth - ButtonGroupWidth + NeverAskAgainWidth - HorzMargin;
  1037. for (unsigned int i = 0; i < ButtonControls.size(); i++)
  1038. {
  1039. ButtonControls[i]->SetBounds(
  1040. X, ButtonTop, ButtonWidth, ButtonControls[i]->Height);
  1041. X += ButtonWidth + ButtonSpacing;
  1042. }
  1043. if (!NeverAskAgainCaption.IsEmpty() &&
  1044. !ButtonControls.empty())
  1045. {
  1046. TCheckBox * NeverAskAgainCheck = new TCheckBox(Result);
  1047. NeverAskAgainCheck->Name = L"NeverAskAgainCheck";
  1048. NeverAskAgainCheck->Parent = Result;
  1049. NeverAskAgainCheck->Caption = NeverAskAgainCaption;
  1050. NeverAskAgainCheck->Anchors = TAnchors() << akBottom << akLeft;
  1051. TButton * FirstButton = ButtonControls[0];
  1052. int NeverAskAgainHeight = ScaleByTextHeightRunTime(Result, NeverAskAgainCheck->Height);
  1053. int NeverAskAgainTop = FirstButton->Top + ((FirstButton->Height - NeverAskAgainHeight) / 2);
  1054. int NeverAskAgainLeft = HorzMargin;
  1055. NeverAskAgainCheck->SetBounds(
  1056. NeverAskAgainLeft, NeverAskAgainTop, NeverAskAgainWidth, NeverAskAgainHeight);
  1057. }
  1058. return Result;
  1059. }
  1060. //---------------------------------------------------------------------------
  1061. TForm * __fastcall CreateMoreMessageDialog(const UnicodeString & Msg,
  1062. TStrings * MoreMessages, TMsgDlgType DlgType, unsigned int Answers,
  1063. const TQueryButtonAlias * Aliases, unsigned int AliasesCount,
  1064. unsigned int TimeoutAnswer, TButton ** TimeoutButton, const UnicodeString & ImageName,
  1065. const UnicodeString & NeverAskAgainCaption)
  1066. {
  1067. return TMessageForm::Create(Msg, MoreMessages, DlgType, Answers,
  1068. Aliases, AliasesCount, TimeoutAnswer, TimeoutButton, ImageName,
  1069. NeverAskAgainCaption);
  1070. }