Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for richtextmessagebox.cs

(view source code of richtextmessagebox.cs as plain text)

  1. using System;
  2. using System.Drawing;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Text.RegularExpressions;
  6. using System.Timers;
  7. using System.Windows.Forms;
  8.  
  9.  
  10. namespace RobvanderWoude
  11. {
  12. 	class RichTextMessageBox
  13. 	{
  14. 		static readonly string progver = "1.03";
  15.  
  16.  
  17. 		#region Global Default Values
  18.  
  19. 		static readonly int defaultbuttonheight = 25;
  20. 		static readonly int defaultbuttonwidth = 100;
  21. 		static readonly string defaultfontfamily = "Sans-Serif";
  22. 		static readonly float defaultfontsize = 12;
  23. 		static readonly FontStyle defaultfontstyle = FontStyle.Regular;
  24. 		static readonly Color defaulttextcolor = Color.Black;
  25. 		static readonly string defaulttitle = string.Format( "RichTextMessageBox,  Version {0}", progver );
  26. 		static readonly int defaultwindowheight = 480;
  27. 		static readonly int defaultwindowwidth = 640;
  28. 		static readonly int screenheight = Screen.PrimaryScreen.Bounds.Height;
  29. 		static readonly int screenwidth = Screen.PrimaryScreen.Bounds.Width;
  30.  
  31. 		#endregion Global Default Values
  32.  
  33.  
  34. 		#region Global Variables
  35.  
  36. 		static Form rtmbform;
  37. 		static RichTextBox rtmbox;
  38. 		static string button1text = "OK";
  39. 		static string button2text = string.Empty;
  40. 		static string button3text = string.Empty;
  41. 		static string buttonclickedtext = "Cancel";
  42. 		static int buttonclickednumber = -1;
  43. 		static int buttoncount = 1;
  44. 		static int buttonheight = defaultbuttonheight;
  45. 		static int buttonwidth = defaultbuttonwidth;
  46. 		static int defaultbutton = -1;
  47. 		static string message = string.Empty;
  48. 		static string title = string.Empty;
  49. 		static double timeout = 0;
  50. 		static bool timeoutelapsed = false;
  51. 		static System.Timers.Timer timer;
  52. 		static int windowheight = defaultwindowheight;
  53. 		static int windowwidth = defaultwindowwidth;
  54.  
  55. 		#endregion Global Variables
  56.  
  57.  
  58. 		[STAThread]
  59. 		static int Main( string[] args )
  60. 		{
  61. 			#region Initial Values
  62.  
  63. 			int windowx = -1;
  64. 			int windowy = -1;
  65. 			string fontfamily = defaultfontfamily;
  66. 			float fontsize = defaultfontsize;
  67. 			FontStyle fontstyle = defaultfontstyle;
  68. 			bool literal = false;
  69. 			bool showhelp = false;
  70. 			bool showintaskbar = false;
  71. 			Color textcolor = defaulttextcolor;
  72. 			bool topmost = false;
  73.  
  74. 			#endregion Initial Values
  75.  
  76.  
  77. 			#region Parse Command Line
  78.  
  79. 			if ( args.Length == 0 || args.Contains( "/?" ) )
  80. 			{
  81. 				showhelp = true;
  82. 			}
  83.  
  84. 			foreach ( string arg in args )
  85. 			{
  86. 				if ( arg.Length > 2 && ( arg[0] == '/' || arg[0] == '-' ) )
  87. 				{
  88. 					if ( arg.IndexOf( ':' ) > 1 )
  89. 					{
  90. 						string key = arg.ToUpper( ).Substring( 1, arg.IndexOf( ':' ) - 1 );
  91. 						string val = arg.Substring( arg.IndexOf( ':' ) + 1 );
  92. 						switch ( key )
  93. 						{
  94. 							case "B1": // /B1:"text for button 1"
  95. 								button1text = val;
  96. 								break;
  97. 							case "B2": // /B2:"text for button 2"
  98. 								button2text = val;
  99. 								buttoncount = 2;
  100. 								break;
  101. 							case "B3": // /B3:"text for button 3"
  102. 								button3text = val;
  103. 								buttoncount = 3;
  104. 								break;
  105. 							case "BH": // /BH:button_height
  106. 								if ( !int.TryParse( val, out buttonheight ) )
  107. 								{
  108. 									showhelp = true;
  109. 								}
  110. 								break;
  111. 							case "BW": // /BW:button_width
  112. 								if ( !int.TryParse( val, out buttonwidth ) )
  113. 								{
  114. 									showhelp = true;
  115. 								}
  116. 								break;
  117. 							case "C": // /C"text_color"
  118. 								try
  119. 								{
  120. 									textcolor = Color.FromName( val ); // if FromName does not recognize the value of val as color it will return black
  121. 								}
  122. 								catch ( Exception )
  123. 								{
  124. 									showhelp = true;
  125. 								}
  126. 								break;
  127. 							case "DB": // /DB:default_button (1 is always valid, 2 or 3 only if there are that many buttons)
  128. 								if ( !int.TryParse( val, out defaultbutton ) )
  129. 								{
  130. 									if ( val.ToUpper( ) == button1text.ToUpper( ) )
  131. 									{
  132. 										defaultbutton = 1;
  133. 									}
  134. 									else if ( val.ToUpper( ) == button2text.ToUpper( ) )
  135. 									{
  136. 										defaultbutton = 2;
  137. 									}
  138. 									else if ( val.ToUpper( ) == button3text.ToUpper( ) )
  139. 									{
  140. 										defaultbutton = 3;
  141. 									}
  142. 									else
  143. 									{
  144. 										showhelp = true;
  145. 									}
  146. 								}
  147. 								break;
  148. 							case "FONT":
  149. 								fontfamily = val;
  150. 								try
  151. 								{
  152. 									FontFamily testfont = new FontFamily( fontfamily );
  153. 								}
  154. 								catch
  155. 								{
  156. 									showhelp = true;
  157. 								}
  158. 								break;
  159. 							case "FS": // /FS:font_size
  160. 								if ( !float.TryParse( val, out fontsize ) )
  161. 								{
  162. 									showhelp = true;
  163. 								}
  164. 								break;
  165. 							case "T": // /T:timeout_seconds
  166. 								if ( !double.TryParse( val, out timeout ) )
  167. 								{
  168. 									showhelp = true;
  169. 								}
  170. 								timeout *= 1000; // specified in seconds, timer requires milliseconds
  171. 								break;
  172. 							case "WH": // /WH:window_height
  173. 								if ( !int.TryParse( val, out windowheight ) )
  174. 								{
  175. 									showhelp = true;
  176. 								}
  177. 								break;
  178. 							case "WW": // /WW:window_width
  179. 								if ( !int.TryParse( val, out windowwidth ) )
  180. 								{
  181. 									showhelp = true;
  182. 								}
  183. 								break;
  184. 							case "X": // /X:X_coordinate of upper left window corner
  185. 								if ( !int.TryParse( val, out windowx ) )
  186. 								{
  187. 									showhelp = true;
  188. 								}
  189. 								break;
  190. 							case "Y": // /Y:Y_coordinate of upper left window corner
  191. 								if ( !int.TryParse( val, out windowy ) )
  192. 								{
  193. 									showhelp = true;
  194. 								}
  195. 								break;
  196. 						}
  197. 					}
  198. 					else
  199. 					{
  200. 						switch ( arg.ToUpper( ).Substring( 1 ) )
  201. 						{
  202. 							case "ALWAYSONTOP":
  203. 							case "MODAL":
  204. 							case "TOPMOST":
  205. 								topmost = true;
  206. 								break;
  207. 							case "BOLD":
  208. 								fontstyle |= FontStyle.Bold;
  209. 								break;
  210. 							case "ITALIC":
  211. 							case "ITALICS":
  212. 								fontstyle |= FontStyle.Italic;
  213. 								break;
  214. 							case "LITERAL":
  215. 								literal = true;
  216. 								break;
  217. 							case "SHOWINTASKBAR":
  218. 							case "TASKBAR":
  219. 								showintaskbar = true;
  220. 								break;
  221. 							case "STRIKE":
  222. 							case "STRIKEOUT":
  223. 								fontstyle |= FontStyle.Strikeout;
  224. 								break;
  225. 							case "UNDERLINE":
  226. 							case "UNDERLINED":
  227. 								fontstyle |= FontStyle.Underline;
  228. 								break;
  229. 							default:
  230. 								showhelp = true;
  231. 								break;
  232. 						}
  233. 					}
  234. 				}
  235. 				else
  236. 				{
  237. 					if ( string.IsNullOrWhiteSpace( message ) )
  238. 					{
  239. 						message = arg; // the message to be displayed in the dialog
  240. 					}
  241. 					else if ( string.IsNullOrWhiteSpace( title ) )
  242. 					{
  243. 						title = arg; // the title of the dialog window
  244. 					}
  245. 					else
  246. 					{
  247. 						showhelp = true;
  248. 					}
  249. 				}
  250. 			}
  251.  
  252. 			#endregion Parse Command Line
  253.  
  254.  
  255. 			#region Validate Command Line Settings
  256.  
  257. 			if ( !literal && !string.IsNullOrWhiteSpace( message ) )
  258. 			{
  259. 				message = UnEscapeString( message );
  260. 			}
  261.  
  262. 			// Check mandatory button text, and if default button number is valid
  263. 			if ( string.IsNullOrWhiteSpace( message ) )
  264. 			{
  265. 				showhelp = true;
  266. 			}
  267.  
  268. 			if ( string.IsNullOrWhiteSpace( title ) )
  269. 			{
  270. 				title = defaulttitle;
  271. 			}
  272.  
  273. 			if ( string.IsNullOrWhiteSpace( button1text ) )
  274. 			{
  275. 				showhelp = true;
  276. 			}
  277.  
  278. 			if ( string.IsNullOrWhiteSpace( button2text ) && defaultbutton > 1 )
  279. 			{
  280. 				showhelp = true;
  281. 			}
  282.  
  283. 			if ( string.IsNullOrWhiteSpace( button3text ) && defaultbutton > 2 )
  284. 			{
  285. 				showhelp = true;
  286. 			}
  287.  
  288. 			if ( showhelp )
  289. 			{
  290. 				ShowHelp( );
  291. 				// Restore defaults before showing help in GUI
  292. 				button1text = "OK";
  293. 				button2text = string.Empty;
  294. 				button3text = string.Empty;
  295. 				buttonheight = defaultbuttonheight;
  296. 				buttonwidth = defaultbuttonwidth;
  297. 				fontfamily = "Courier New";
  298. 				fontsize = 10; // slightly smaller font to fit in the help text
  299. 				fontstyle = defaultfontstyle;
  300. 				textcolor = defaulttextcolor;
  301. 				title = defaulttitle;
  302. 				windowheight = defaultwindowheight;
  303. 				windowwidth = defaultwindowwidth;
  304. 				windowx = Convert.ToInt32( ( screenwidth - defaultwindowwidth ) / 2 );
  305. 				windowy = Convert.ToInt32( ( screenheight - defaultwindowheight ) / 2 );
  306. 			}
  307. 			else
  308. 			{
  309. 				windowheight = Math.Min( windowheight, screenheight );
  310. 				windowwidth = Math.Min( windowwidth, screenwidth );
  311. 				if ( windowx == -1 )
  312. 				{
  313. 					windowx = Convert.ToInt32( ( screenwidth - windowwidth ) / 2 );
  314. 				}
  315. 				if ( windowy == -1 )
  316. 				{
  317. 					windowy = Convert.ToInt32( ( screenheight - windowheight ) / 2 );
  318. 				}
  319. 				windowx = Math.Min( windowx, screenwidth - windowwidth );
  320. 				windowy = Math.Min( windowy, screenheight - windowheight );
  321. 			}
  322.  
  323. 			#endregion Validate Command Line Settings
  324.  
  325.  
  326. 			#region Prepare Dialog Form
  327.  
  328. 			// The dialog form itself
  329. 			rtmbform = new Form
  330. 			{
  331. 				Text = title,
  332. 				ClientSize = new Size( windowwidth, windowheight ),
  333. 				Location = new Point( windowx, windowy ),
  334. 				MaximizeBox = false,
  335. 				SizeGripStyle = SizeGripStyle.Hide,
  336. 				ShowInTaskbar = showintaskbar,
  337. 				StartPosition = FormStartPosition.Manual,
  338. 				TopMost = topmost,
  339. 				WindowState = FormWindowState.Normal
  340. 			};
  341. 			rtmbform.BringToFront( );
  342.  
  343. 			// The rich text box
  344. 			rtmbox = new RichTextBox
  345. 			{
  346. 				Text = message,
  347. 				Height = ( windowheight - buttonheight - 30 ),
  348. 				Width = ( windowwidth - 20 ),
  349. 				Font = new Font( fontfamily, fontsize, fontstyle ),
  350. 				ForeColor = textcolor,
  351. 				Location = new Point( 10, 10 ),
  352. 				ReadOnly = true
  353. 			};
  354. 			rtmbform.Controls.Add( rtmbox );
  355.  
  356. 			// Button 1
  357. 			Button button1 = new Button
  358. 			{
  359. 				Text = button1text,
  360. 				Height = buttonheight,
  361. 				Width = buttonwidth,
  362. 				Location = ButtonLocation( 1 )
  363. 			};
  364. 			button1.Click += Button1_Click;
  365. 			rtmbform.Controls.Add( button1 );
  366. 			if ( defaultbutton == 1 )
  367. 			{
  368. 				rtmbform.AcceptButton = button1;
  369. 				button1.Focus( );
  370. 			}
  371.  
  372. 			// Optional button 2
  373. 			if ( !string.IsNullOrWhiteSpace( button2text ) )
  374. 			{
  375. 				Button button2 = new Button
  376. 				{
  377. 					Text = button2text,
  378. 					Height = buttonheight,
  379. 					Width = buttonwidth,
  380. 					Location = ButtonLocation( 2 )
  381. 				};
  382. 				button2.Click += Button2_Click;
  383. 				rtmbform.Controls.Add( button2 );
  384. 				if ( defaultbutton == 2 )
  385. 				{
  386. 					rtmbform.AcceptButton = button2;
  387. 					button2.Focus( );
  388. 				}
  389.  
  390. 				// Optional button 3, only if button 2 is also specified
  391. 				if ( !string.IsNullOrWhiteSpace( button3text ) )
  392. 				{
  393. 					Button button3 = new Button
  394. 					{
  395. 						Text = button3text,
  396. 						Height = buttonheight,
  397. 						Width = buttonwidth,
  398. 						Location = ButtonLocation( 3 )
  399. 					};
  400. 					button3.Click += Button3_Click;
  401. 					rtmbform.Controls.Add( button3 );
  402. 					if ( defaultbutton == 3 )
  403. 					{
  404. 						rtmbform.AcceptButton = button3;
  405. 						button3.Focus( );
  406. 					}
  407. 				}
  408. 			}
  409.  
  410. 			#endregion Prepare Dialog Form
  411.  
  412.  
  413. 			// Optional timer for timeout feature
  414. 			if ( timeout > 0 )
  415. 			{
  416. 				timer = new System.Timers.Timer( );
  417. 				timer.Elapsed += new ElapsedEventHandler( Timer_Elapsed );
  418. 				timer.Interval = timeout;
  419. 				timer.Start( );
  420. 			}
  421.  
  422. 			// Show dialog window
  423. 			rtmbform.ShowDialog( );
  424.  
  425. 			// Interpret the result to be returned
  426. 			if ( timeoutelapsed )
  427. 			{
  428. 				buttonclickednumber = defaultbutton;
  429. 				switch ( defaultbutton )
  430. 				{
  431. 					case 1:
  432. 						buttonclickedtext = button1text;
  433. 						break;
  434. 					case 2:
  435. 						buttonclickedtext = button2text;
  436. 						break;
  437. 					case 3:
  438. 						buttonclickedtext = button3text;
  439. 						break;
  440. 					default:
  441. 						buttonclickedtext = "Timeout";
  442. 						buttonclickednumber = 4;
  443. 						break;
  444. 				}
  445. 			}
  446.  
  447. 			if ( showhelp )
  448. 			{
  449. 				return -1;
  450. 			}
  451. 			else
  452. 			{
  453. 				Console.WriteLine( buttonclickedtext );
  454. 				return buttonclickednumber;
  455. 			}
  456. 		}
  457.  
  458.  
  459. 		private static void Button1_Click( object sender, EventArgs e )
  460. 		{
  461. 			buttonclickedtext = button1text;
  462. 			buttonclickednumber = 1;
  463. 			rtmbform.Close( );
  464. 		}
  465.  
  466.  
  467. 		private static void Button2_Click( object sender, EventArgs e )
  468. 		{
  469. 			buttonclickedtext = button2text;
  470. 			buttonclickednumber = 2;
  471. 			rtmbform.Close( );
  472. 		}
  473.  
  474.  
  475. 		private static void Button3_Click( object sender, EventArgs e )
  476. 		{
  477. 			buttonclickedtext = button3text;
  478. 			buttonclickednumber = 3;
  479. 			rtmbform.Close( );
  480. 		}
  481.  
  482. 		public static void Timer_Elapsed( object sender, System.EventArgs e )
  483. 		{
  484. 			timeoutelapsed = true;
  485. 			FormClose( );
  486. 		}
  487.  
  488.  
  489. 		private static void FormClose()
  490. 		{
  491. 			if ( rtmbform.InvokeRequired )
  492. 			{
  493. 				FormCloseCallback fccb = new FormCloseCallback( FormClose );
  494. 				rtmbform.Invoke( fccb );
  495. 			}
  496. 			else
  497. 			{
  498. 				rtmbform.Close( );
  499. 			}
  500. 		}
  501.  
  502.  
  503. 		delegate void FormCloseCallback( );
  504.  
  505.  
  506. 		private static Point ButtonLocation( int button )
  507. 		{
  508. 			Point location = new Point( );
  509. 			switch ( buttoncount )
  510. 			{
  511. 				case 1:
  512. 					location.X = ( windowwidth - buttonwidth ) / 2; // center
  513. 					break;
  514. 				case 2:
  515. 					if ( button == 1 )
  516. 					{
  517. 						location.X = windowwidth / 2 - buttonwidth - 10; // left
  518. 					}
  519. 					else
  520. 					{
  521. 						location.X = windowwidth / 2 + buttonwidth + 10; // right
  522. 					}
  523. 					break;
  524. 				case 3:
  525. 					if ( button == 1 )
  526. 					{
  527. 						location.X = ( windowwidth - buttonwidth ) / 2 - buttonwidth - 10; // left
  528. 					}
  529. 					else if ( button == 2 )
  530. 					{
  531. 						location.X = ( windowwidth - buttonwidth ) / 2; // center
  532. 					}
  533. 					else
  534. 					{
  535. 						location.X = ( windowwidth - buttonwidth ) / 2 + buttonwidth + 10; // right
  536. 					}
  537. 					break;
  538. 			}
  539. 			location.Y = windowheight - buttonheight - 10;
  540. 			return location;
  541. 		}
  542.  
  543.  
  544. 		static string UnEscapeString( string message )
  545. 		{
  546. 			// Unescaping tabs, linefeeds and quotes
  547. 			message = message.Replace( "\\n", "\n" );
  548. 			message = message.Replace( "\\r", "\r" );
  549. 			message = message.Replace( "\\t", "\t" );
  550. 			message = message.Replace( "\\007", "\t" );
  551. 			message = message.Replace( "\\012", "\n" );
  552. 			message = message.Replace( "\\015", "\r" );
  553. 			message = message.Replace( "\\042", "\"" );
  554. 			message = message.Replace( "\\047", "'" );
  555. 			// Unescaping Unicode, technique by "dtb" on StackOverflow.com: http://stackoverflow.com/a/8558748
  556. 			message = Regex.Replace( message, @"\\[Uu]([0-9A-Fa-f]{4})", m => char.ToString( (char) ushort.Parse( m.Groups[1].Value, NumberStyles.AllowHexSpecifier ) ) );
  557. 			return message;
  558. 		}
  559.  
  560.  
  561. 		static void ShowHelp( )
  562. 		{
  563. 			/*
  564. 			RichTextMessageBox,  Version 1.00
  565. 			Show a fully customizable message dialog and return which button is clicked
  566.  
  567. 			Usage:    RichTextMessageBox.exe  message  [ title ]  [ options ]
  568.  
  569. 			          message       is the text to be displayed in the dialog
  570. 			          title         is the dialog's window title
  571. 									(default: program name and version)
  572.  
  573. 			Options:  /AlwaysOnTop  Modal window, always on top
  574. 			          /B1:"caption" Caption for button 1 (default: OK)
  575. 			          /B2:"caption" Caption for button 2 (default: empty)
  576. 			          /B3:"caption" Caption for button 3 (default: empty)
  577. 			          /BH:height    Button height (default: 25)
  578. 			          /Bold         Bold text for message
  579. 			          /BW:width     Button width (default: 100)
  580. 			          /C:color      Text color for dialog (default: Black)
  581. 			          /DB:default   Default button (default: 1; values 2 or 3 are
  582. 			                        valid only if there are that many buttons)
  583. 			          /Font:name    Font family name (default: Sans-Serif)
  584. 			          /FS:fontsize  Font size (default: 12)
  585. 			          /Italic       Italic text for message
  586. 			          /Literal      Treat message as literal, do not interpret special
  587. 			                        characters \n, \012, \t, \007 or unicode \u****
  588. 			                        (default: interpret special characters and unicode)
  589. 			          /Strike       Strikeout text
  590. 			          /T:seconds    Timeout in seconds (default: no timeout)
  591. 			          /Taskbar      Show in taskbar
  592. 			          /Underline    Underline text
  593. 			          /WH:height    Window height (default: 480)
  594. 			          /WW:width     Window width (default: 640)
  595. 			          /X:x          X-coordinate of upper left window corner
  596. 			          /Y:y          Y-coordinate of upper left window corner
  597. 			                        (default: center window on screen)
  598.  
  599. 			Notes:    The caption of the button that is clicked will be sent to the
  600. 			          console, the number of the button is returned as "errorlevel".
  601. 			          In case of errors, the "errorlevel" will be -1, if a timeout
  602. 			          elapsed and no default button was specified, the "errorlevel"
  603. 			          will be 4, and the text "Timeout" is sent to the console.
  604. 			          If an invalid text color is specified, it will be ignored.
  605.  
  606. 			Written by Rob van der Woude
  607. 			https://www.robvanderwoude.com/
  608. 			*/
  609.  
  610. 			message = string.Format( "RichTextMessageBox,  Version {0}\n", progver );
  611. 			message += "Show a fully customizable message dialog and return which button is clicked\n\n";
  612. 			message += "Usage:    RichTextMessageBox.exe  message  [ title ]  [ options ]\n\n";
  613. 			message += "          message       is the text to be displayed in the dialog\n";
  614. 			message += "          title         is the dialog's window title\n";
  615. 			message += "                        (default: program name and version)\n\n";
  616. 			message += "Options:  /AlwaysOnTop  Modal window, always on top\n";
  617. 			message += "          /B1:\"caption\" Caption for button 1 (default: OK)\n";
  618. 			message += "          /B2:\"caption\" Caption for button 2 (default: empty)\n";
  619. 			message += "          /B3:\"caption\" Caption for button 3 (default: empty)\n";
  620. 			message += string.Format( "          /BH:height    Button height (default: {0})\n", defaultbuttonheight );
  621. 			message += "          /Bold         Bold text for message\n";
  622. 			message += string.Format( "          /BW:width     Button width (default: {0})\n", defaultbuttonwidth );
  623. 			message += "          /C:color      Text color for dialog (default: Black)\n";
  624. 			message += "          /DB:default   Default button (default: 1; values 2 or 3 are\n";
  625. 			message += "                        valid only if there are that many buttons)\n";
  626. 			message += string.Format( "          /Font:name    Font family name (default: {0})\n", defaultfontfamily );
  627. 			message += string.Format( "          /FS:fontsize  Font size (default: {0})\n", defaultfontsize );
  628. 			message += "          /Italic       Italic text for message\n";
  629. 			message += "          /Literal      Treat message as literal, do not interpret special\n";
  630. 			message += "                        characters \\n, \\012, \\t, \\007 or unicode \\u****\n";
  631. 			message += "                        (default: interpret special chars and unicode)\n";
  632. 			message += "          /Strike       Strikeout text\n";
  633. 			message += "          /T:seconds    Timeout in seconds (default: no timeout)\n";
  634. 			message += "          /Taskbar      Show in taskbar\n";
  635. 			message += "          /Underline    Underline text\n";
  636. 			message += string.Format( "          /WH:height    Window height (default: {0})\n", defaultwindowheight );
  637. 			message += string.Format( "          /WW:width     Window width (default: {0})\n", defaultwindowwidth );
  638. 			message += "          /X:x          X-coordinate of upper left window corner\n";
  639. 			message += "          /Y:y          Y-coordinate of upper left window corner\n";
  640. 			message += "                        (default: center window on screen)\n\n";
  641. 			message += "Notes:    The caption of the button that is clicked will be sent to the\n";
  642. 			message += "          console, the number of the button is returned as \"errorlevel\".\n";
  643. 			message += "          In case of errors, the \"errorlevel\" will be -1, if a timeout\n";
  644. 			message += "          elapsed and no default button was specified, the \"errorlevel\"\n";
  645. 			message += "          will be 4, and the text \"Timeout\" is sent to the console.\n";
  646. 			message += "          If an invalid text color is specified, it will be ignored.\n\n";
  647. 			message += "Written by Rob van der Woude\n";
  648. 			message += "https://www.robvanderwoude.com/";
  649.  
  650. 			Console.Error.WriteLine( message );
  651. 		}
  652. 	}
  653. }
  654.  

page last modified: 2024-04-16; loaded in 0.0319 seconds