ScrollPanel.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System.ComponentModel;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. namespace SmartCoalApplication.SystemLayer
  5. {
  6. public class ScrollPanel : Panel
  7. {
  8. private bool ignoreSetFocus = false;
  9. public bool IgnoreSetFocus
  10. {
  11. get
  12. {
  13. return ignoreSetFocus;
  14. }
  15. set
  16. {
  17. ignoreSetFocus = value;
  18. }
  19. }
  20. [Browsable(false)]
  21. public Point ScrollPosition
  22. {
  23. get
  24. {
  25. return new Point(-AutoScrollPosition.X, -AutoScrollPosition.Y);
  26. }
  27. set
  28. {
  29. AutoScrollPosition = value;
  30. }
  31. }
  32. protected override void WndProc(ref Message m)
  33. {
  34. switch (m.Msg)
  35. {
  36. case NativeConstants.WM_SETFOCUS:
  37. if (IgnoreSetFocus)
  38. {
  39. return;
  40. }
  41. else
  42. {
  43. goto default;
  44. }
  45. default:
  46. base.WndProc(ref m);
  47. break;
  48. }
  49. }
  50. }
  51. }