Click here to Skip to main content
15,908,015 members
Home / Discussions / C#
   

C#

 
QuestionReduce the container zone of a panel. Pin
galinace16-Dec-05 8:36
galinace16-Dec-05 8:36 
AnswerRe: Reduce the container zone of a panel. Pin
TheGreatAndPowerfulOz16-Dec-05 11:32
TheGreatAndPowerfulOz16-Dec-05 11:32 
AnswerRe: Reduce the container zone of a panel. Pin
Curtis Schlak.16-Dec-05 11:41
Curtis Schlak.16-Dec-05 11:41 
GeneralRe: Reduce the container zone of a panel. Pin
galinace16-Dec-05 22:38
galinace16-Dec-05 22:38 
GeneralRe: Reduce the container zone of a panel. Pin
Curtis Schlak.17-Dec-05 4:22
Curtis Schlak.17-Dec-05 4:22 
GeneralRe: Reduce the container zone of a panel. Pin
galinace17-Dec-05 4:59
galinace17-Dec-05 4:59 
GeneralRe: Reduce the container zone of a panel. Pin
Curtis Schlak.28-Dec-05 9:55
Curtis Schlak.28-Dec-05 9:55 
GeneralRe: Reduce the container zone of a panel. Pin
galinace18-Dec-05 6:25
galinace18-Dec-05 6:25 
Hi,

I sent the same post on the MSDN's forum and received an other way of doing what we both wanted. I didn't try it for the moment but wanted to keep you informed.

You can follow this URL : http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=172709&SiteID=1[^] to see the entire conversation but this is the answer of Jelle van der Beek.

"The zone in which components cannot be dropped is called the non-client area. There is no support in the .NET framework for the non-client area, but you can still control it by overriding the WM_NC* messages. Here is a piece of sample code that will set the non-client border to 10 pixels wide."
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Runtime.InteropServices;
namespace Foo
{
    public class SomeControl : Control
    {
        public SomeControl()
        {
            SetStyle( ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer | 
                      ControlStyles.AllPaintingInWmPaint, true );
        }

        protected override void WndProc( ref Message m )
        {
            switch( m.Msg )
            {
                case 0x0083: // WM_NCCALCSIZE
                    if( m.WParam == IntPtr.Zero ){
                        RecalcNonClientArea( m.LParam );
                    }
                    else 
                        if( m.WParam == new IntPtr(1) ){
                            RecalcNonClientArea( m.LParam );
                        }
                    break;
                case 0x0085: // WM_NCPAINT
                    IntPtr hDC = WinApi.GetWindowDC( m.HWnd );
                    if( hDC != IntPtr.Zero ){
                        using( Graphics maing = Graphics.FromHdc(hDC) ){
                              //
                              // PAINT HERE
                              //
                        }
                        WinApi.ReleaseDC( m.HWnd, hDC );
                    }
                    m.Result = IntPtr.Zero;
                    break;
            }
            base.WndProc( ref m );
        }
        private void RecalcNonClientArea( IntPtr lParam )
        {
            WinApi.NCCALCSIZE_PARAMS csp;
            csp = (WinApi.NCCALCSIZE_PARAMS)Marshal.PtrToStructure(
                lParam,
                typeof( WinApi.NCCALCSIZE_PARAMS ) );
            csp.rgrc0.Top += 10;
            csp.rgrc0.Bottom -= 10;
            csp.rgrc0.Left += 10;
            csp.rgrc0.Right -= 10;
            Marshal.StructureToPtr( csp, lParam, false );
        }
    }
}

I hope that will help you...

All the best.
GeneralRe: Reduce the container zone of a panel. Pin
Curtis Schlak.19-Dec-05 18:07
Curtis Schlak.19-Dec-05 18:07 
QuestionReflection code: C# and VB.Net equivalents in .NET 1.1 Pin
pankazmittal16-Dec-05 6:58
pankazmittal16-Dec-05 6:58 
AnswerRe: Reflection code: C# and VB.Net equivalents in .NET 1.1 Pin
Nish Nishant16-Dec-05 7:35
sitebuilderNish Nishant16-Dec-05 7:35 
GeneralRe: Reflection code: C# and VB.Net equivalents in .NET 1.1 Pin
pankazmittal16-Dec-05 7:49
pankazmittal16-Dec-05 7:49 
GeneralRe: Reflection code: C# and VB.Net equivalents in .NET 1.1 Pin
Nish Nishant16-Dec-05 9:52
sitebuilderNish Nishant16-Dec-05 9:52 
GeneralRe: Reflection code: C# and VB.Net equivalents in .NET 1.1 Pin
Nish Nishant16-Dec-05 9:53
sitebuilderNish Nishant16-Dec-05 9:53 
AnswerRe: Reflection code: C# and VB.Net equivalents in .NET 1.1 Pin
Nish Nishant16-Dec-05 9:57
sitebuilderNish Nishant16-Dec-05 9:57 
GeneralRe: Reflection code: C# and VB.Net equivalents in .NET 1.1 Pin
pankazmittal16-Dec-05 9:59
pankazmittal16-Dec-05 9:59 
GeneralRe: Reflection code: C# and VB.Net equivalents in .NET 1.1 Pin
Nish Nishant16-Dec-05 10:02
sitebuilderNish Nishant16-Dec-05 10:02 
GeneralRe: Reflection code: C# and VB.Net equivalents in .NET 1.1 Pin
pankazmittal16-Dec-05 10:03
pankazmittal16-Dec-05 10:03 
Questionpreview and print a PrintDocument in VB6 Pin
IsaacB16-Dec-05 6:55
IsaacB16-Dec-05 6:55 
QuestionHUH ?? Pin
IceWater4216-Dec-05 6:36
IceWater4216-Dec-05 6:36 
AnswerRe: HUH ?? Pin
Dave Kreskowiak16-Dec-05 6:55
mveDave Kreskowiak16-Dec-05 6:55 
GeneralRe: HUH ?? Pin
IceWater4218-Dec-05 5:42
IceWater4218-Dec-05 5:42 
GeneralRe: HUH ?? Pin
Dave Kreskowiak18-Dec-05 7:09
mveDave Kreskowiak18-Dec-05 7:09 
AnswerRe: HUH ?? Pin
Judah Gabriel Himango16-Dec-05 7:04
sponsorJudah Gabriel Himango16-Dec-05 7:04 
QuestionHow do I launch an App as a child window Pin
NeedToCode16-Dec-05 6:23
NeedToCode16-Dec-05 6:23 

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.