Click here to Skip to main content
16,010,268 members
Home / Discussions / C#
   

C#

 
GeneralRe: A MDI in a MDI Pin
John Fisher12-Mar-04 7:53
John Fisher12-Mar-04 7:53 
GeneralRe: A MDI in a MDI Pin
sixefftee12-Mar-04 8:34
sixefftee12-Mar-04 8:34 
GeneralRe: A MDI in a MDI Pin
John Fisher12-Mar-04 11:26
John Fisher12-Mar-04 11:26 
QuestionCan you temporarily lock a directory? Pin
boozebomb112-Mar-04 2:42
boozebomb112-Mar-04 2:42 
AnswerRe: Can you temporarily lock a directory? Pin
Heath Stewart12-Mar-04 3:56
protectorHeath Stewart12-Mar-04 3:56 
GeneralRe: Can you temporarily lock a directory? Pin
boozebomb112-Mar-04 4:13
boozebomb112-Mar-04 4:13 
GeneralRe: Can you temporarily lock a directory? Pin
Heath Stewart12-Mar-04 4:23
protectorHeath Stewart12-Mar-04 4:23 
GeneralCustom borders Pin
Mathew Hall12-Mar-04 2:24
Mathew Hall12-Mar-04 2:24 
Hi there. I'm working on a custom control where each side can have a different border thickness. I found this code while googling which allows me to modify the controls non-client area so I can draw my borders:

[StructLayout(LayoutKind.Sequential)]
private struct RECT
{
   public int Left;
   public int Top;
   public int Right;
   public int Bottom;
}

enum WM_MESSAGE
{
   WM_NCCALCSIZE = 131,
   WM_NCPAINT = 133,
   WM_NCHITTEST = 132,
   WM_NCLBUTTONDOWN = 161,
}

[StructLayout(LayoutKind.Sequential)]
struct NCCALCSIZE_PARAMS
{
   public RECT rgrc0, rgrc1, rgrc2;
   public IntPtr lppos;
}

[DllImport("User32.dll")]
private extern static IntPtr GetWindowDC( IntPtr hWnd );

[DllImport("User32.dll")]
private extern static int ReleaseDC( IntPtr hWnd, IntPtr hDC );

private Rectangle _rcButton = Rectangle.Empty;

protected override void WndProc(ref Message m)
{
   switch (m.Msg)
   {
      case (int)WM_MESSAGE.WM_NCCALCSIZE :
         if (m.WParam == IntPtr.Zero)
         {
             // shrink the client area
             NCCALCSIZE_PARAMS csp;
             csp = (NCCALCSIZE_PARAMS)Marshal.PtrToStructure(m.LParam, typeof(NCCALCSIZE_PARAMS));
             csp.rgrc0.Left += 1;
             csp.rgrc0.Top += 5;
             csp.rgrc0.Right -= 1;
             csp.rgrc0.Bottom -= 1;
             Marshal.StructureToPtr( csp, m.LParam, false );
         }
         break;

      case (int)WM_MESSAGE.WM_NCPAINT :
      {
         // draw the borders in the non client area
         IntPtr hDC = GetWindowDC(m.HWnd);
         Graphics g = Graphics.FromHdc(hDC);
         g.FillRectangle(SystemBrushes.Highlight, 0, 0, this.Width, 5); // top
         g.FillRectangle(SystemBrushes.Highlight, 0, 0, 1, this.Height); // left
         g.FillRectangle(SystemBrushes.Highlight, this.Width-1, 0, 1, this.Height); // right
         g.FillRectangle(SystemBrushes.Highlight, 0, this.Height-1, this.Width, 1); // bottom
         ReleaseDC( m.HWnd, hDC );
         break;
      }
   }

   base.WndProc(ref m);
}
This works fine until the control is resized - it's client area gets reset. Any ideas on how to fix this?

"I think I speak on behalf of everyone here when I say huh?" - Buffy
GeneralRe: Custom borders Pin
John Fisher12-Mar-04 3:32
John Fisher12-Mar-04 3:32 
GeneralRe: Custom borders Pin
Mathew Hall13-Mar-04 2:09
Mathew Hall13-Mar-04 2:09 
GeneralRe: Custom borders Pin
John Fisher13-Mar-04 4:11
John Fisher13-Mar-04 4:11 
GeneralCatching a message Pin
T i T i12-Mar-04 1:06
T i T i12-Mar-04 1:06 
GeneralRe: Catching a message Pin
Mike Dimmick12-Mar-04 2:16
Mike Dimmick12-Mar-04 2:16 
GeneralRe: Catching a message Pin
Wraith212-Mar-04 2:27
Wraith212-Mar-04 2:27 
GeneralRe: Catching a message Pin
Heath Stewart12-Mar-04 3:41
protectorHeath Stewart12-Mar-04 3:41 
GeneralEventhandler + parallelport input Pin
NicklasRing11-Mar-04 23:01
NicklasRing11-Mar-04 23:01 
GeneralRe: Eventhandler + parallelport input Pin
John Fisher12-Mar-04 2:17
John Fisher12-Mar-04 2:17 
GeneralNeed Help with Transparency! Pin
Agent 8611-Mar-04 17:36
Agent 8611-Mar-04 17:36 
QuestionHow to know if there is a child control under a certain point ? Pin
Andres Coder11-Mar-04 17:06
Andres Coder11-Mar-04 17:06 
AnswerRe: How to know if there is a child control under a certain point ? Pin
OmegaSupreme12-Mar-04 2:06
OmegaSupreme12-Mar-04 2:06 
AnswerRe: How to know if there is a child control under a certain point ? Pin
John Fisher12-Mar-04 2:08
John Fisher12-Mar-04 2:08 
Generalc# opengl *.obj Pin
pertiu11-Mar-04 7:07
pertiu11-Mar-04 7:07 
GeneralRe: c# opengl *.obj Pin
Judah Gabriel Himango11-Mar-04 16:39
sponsorJudah Gabriel Himango11-Mar-04 16:39 
GeneralRe: c# opengl *.obj Pin
Heath Stewart12-Mar-04 3:32
protectorHeath Stewart12-Mar-04 3:32 
GeneralOOP - Multiple Inheritance Pin
MrEyes11-Mar-04 7:07
MrEyes11-Mar-04 7:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.