Advertisement
fortsoft

TabControlEx

Jan 8th, 2023 (edited)
967
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.37 KB | Source Code | 0 0
  1. /**
  2.  * This is open-source software licensed under the terms of the MIT License.
  3.  *
  4.  * Copyright (c) 2023 Petr Červinka - FortSoft <[email protected]>
  5.  * Copyright (c) 2011 Mike Zhang - MSDN Community Support
  6.  * Copyright (c) 2011 Cody Gray
  7.  *
  8.  * Permission is hereby granted, free of charge, to any person obtaining a copy
  9.  * of this software and associated documentation files (the "Software"), to deal
  10.  * in the Software without restriction, including without limitation the rights
  11.  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12.  * copies of the Software, and to permit persons to whom the Software is
  13.  * furnished to do so, subject to the following conditions:
  14.  *
  15.  * The above copyright notice and this permission notice shall be included in all
  16.  * copies or substantial portions of the Software.
  17.  *
  18.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19.  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20.  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21.  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22.  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23.  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  24.  * SOFTWARE.
  25.  **
  26.  * Version 1.0.0.0
  27.  */
  28.  
  29. using System;
  30. using System.Windows.Forms;
  31.  
  32. namespace FortSoft.Controls {
  33.  
  34.     /// <summary>
  35.     /// Implements custom TabControl without tabs and border. Note that this will
  36.     /// not work properly for tab headers positioned on the sides or the bottom.
  37.     /// But not only does that just look weird, you won't be able to see the tabs
  38.     /// at run-time anyway. Just put them on the top where they belong.
  39.     /// </summary>
  40.     public class TabControlEx : TabControl {
  41.  
  42.         /// <summary>
  43.         /// Constant value found in the Windows.h header file.
  44.         /// </summary>
  45.         private const int TCM_ADJUSTRECT = 0x1328;
  46.  
  47.         /// <summary>
  48.         /// A callback function that processes messages sent to a window.
  49.         /// </summary>
  50.         protected override void WndProc(ref Message message) {
  51.             if (message.Msg == TCM_ADJUSTRECT && !DesignMode) {
  52.                 message.Result = (IntPtr)1;
  53.                 return;
  54.             }
  55.             base.WndProc(ref message);
  56.         }
  57.     }
  58. }
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement