fork download
  1. using System;
  2.  
  3. using System.Collections.Generic;
  4.  
  5. using System.Linq;
  6.  
  7. using System.Text;
  8.  
  9. using System.ComponentModel;
  10.  
  11. using System.Windows.Forms;
  12.  
  13. using System.Drawing;
  14.  
  15.  
  16.  
  17. namespace WindowsFormsApplication2
  18.  
  19. {
  20.  
  21. [DesignerCategory("Default")]
  22.  
  23. class TextBoxEx : TextBox
  24.  
  25. {
  26.  
  27. public TextBoxEx()
  28.  
  29. {
  30.  
  31. Watermark = "";
  32.  
  33. }
  34.  
  35.  
  36.  
  37. public string Watermark { get; set; }
  38.  
  39.  
  40.  
  41. private bool ShowsWatermark
  42.  
  43. {
  44.  
  45. get { return !DesignMode && !Focused && Text == ""; }
  46.  
  47. }
  48.  
  49.  
  50.  
  51. private Color WatermarkColor
  52.  
  53. {
  54.  
  55. get { return SystemColors.GrayText; }
  56.  
  57. }
  58.  
  59.  
  60.  
  61. protected override void WndProc(ref Message m)
  62.  
  63. {
  64.  
  65. base.WndProc(ref m);
  66.  
  67.  
  68.  
  69. const int WM_PAINT = 0x000f;
  70.  
  71. switch (m.Msg)
  72.  
  73. {
  74.  
  75. case WM_PAINT:
  76.  
  77. if (ShowsWatermark)
  78.  
  79. {
  80.  
  81. PrintWatermark();
  82.  
  83. }
  84.  
  85. break;
  86.  
  87. }
  88.  
  89. }
  90.  
  91.  
  92.  
  93. private void PrintWatermark()
  94.  
  95. {
  96.  
  97. using (var g = CreateGraphics())
  98.  
  99. {
  100.  
  101. //using (var br = new SolidBrush(BackColor))
  102.  
  103. //{
  104.  
  105. // g.FillRectangle(br, this.ClientRectangle);
  106.  
  107. //}
  108.  
  109.  
  110.  
  111. using (var br = new SolidBrush(WatermarkColor))
  112.  
  113. {
  114.  
  115. var sf = new StringFormat();
  116.  
  117. g.DrawString(Watermark, Font, br, ClientRectangle, sf);
  118.  
  119. }
  120.  
  121. }
  122.  
  123. }
  124.  
  125. }
  126.  
  127. }
  128.  
  129.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(11,14): error CS0234: The type or namespace name `Windows' does not exist in the namespace `System'. Are you missing an assembly reference?
prog.cs(61,45): error CS0246: The type or namespace name `Message' could not be found. Are you missing a using directive or an assembly reference?
Compilation failed: 2 error(s), 0 warnings
stdout
Standard output is empty