473,385 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Non Client Area

How do you access the non-client area of a control for painting or resizing
the client area.

Thanks any help would do.
Nov 17 '05 #1
3 6673

Patrick Blackman wrote:
How do you access the non-client area of a control for painting or resizing
the client area.

Thanks any help would do.
You handle the WM_NCPAINT message in your windows processing handler.From a previous post from a microsoftie:


protected override void WndProc(ref Message msg)
{
// Call the base paint FIRST.
base.WndProc(ref msg);
const int WM_NCPAINT = 0x85;
if (msg.Msg == WM_NCPAINT)
{
// Do your painting here.
}

}

matt

Nov 17 '05 #2
Thanks for the info, what I want to do is to access the non client area of a richtextbox so I can paint line numbers at the side, therefore I need to reduce the client rectangle/area, any ideas on this.

I was trying this bit of code but got errors memory:

[DllImport("kernel32", CharSet = CharSet.Auto)]

internal static extern void CopyMemory (WINDOWPOS pDst , IntPtr pSrc , int ByteLen);

[DllImport("kernel32", CharSet = CharSet.Auto)]

internal static extern void CopyMemory(NCCALCSIZE_PARAMS pDst, IntPtr pSrc, int ByteLen);
[DllImport("kernel32", CharSet = CharSet.Auto)]

internal static extern void CopyMemory(IntPtr pSrc, NCCALCSIZE_PARAMS pDst, int ByteLen);

[StructLayout(LayoutKind.Sequential)]

internal class NCCALCSIZE_PARAMS

{

[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]

public RECT[] rgxRects;

public IntPtr lppos ;

public NCCALCSIZE_PARAMS()

{

}

}

[StructLayout(LayoutKind.Sequential)]

internal class WINDOWPOS

{

public IntPtr hwnd;

public IntPtr hWndInsertAfter;

public int x;

public int y;

public int cx;

public int cy;

public int flags;

public WINDOWPOS() { }

}
//WinProc override
protected override void WndProc(ref Message m)

{

case WM_NCCALCSIZE :

NCCALCSIZE_PARAMS aNCCS = new NCCALCSIZE_PARAMS();

Marshal.PtrToStructure(m.LParam, aNCCS);

WINDOWPOS aWinPos = new WINDOWPOS();

// Get the non-client calc size rectangle and window position

CopyMemory( aNCCS, m.LParam, Marshal.SizeOf(aNCCS));

//CopyMemory( aWinPos, aNCCS.lppos, Marshal.SizeOf(aWinPos));

//Populate the non-client rectangle UDT information

aNCCS.rgxRects[0].Left =aWinPos.x;

aNCCS.rgxRects[0].Top = aWinPos.y;

aNCCS.rgxRects[0].Right =75;// aWinPos.x + aWinPos.cx;

aNCCS.rgxRects[0].Bottom = 75;// aWinPos.y + aWinPos.cy;
//Make an adjustment for our line numbers

aNCCS.rgxRects[0].Left = aNCCS.rgxRects[0].Left + 75;

//Duplicate these values in the other rectangle

aNCCS.rgxRects[1] = aNCCS.rgxRects[0];

//copy it back to the lParam pointer address so the process uses the information.

CopyMemory(m.LParam, aNCCS, Marshal.SizeOf(aNCCS));

base.WndProc(ref m);

}

"Matt" <ma********@sprynet.com> wrote in message news:11**********************@g49g2000cwa.googlegr oups.com...

Patrick Blackman wrote:
How do you access the non-client area of a control for painting or resizing
the client area.

Thanks any help would do.


You handle the WM_NCPAINT message in your windows processing handler.
From a previous post from a microsoftie:


protected override void WndProc(ref Message msg)
{
// Call the base paint FIRST.
base.WndProc(ref msg);
const int WM_NCPAINT = 0x85;
if (msg.Msg == WM_NCPAINT)
{
// Do your painting here.
}

}

matt

Nov 17 '05 #3

Patrick Blackman wrote:
Thanks for the info, what I want to do is to access the non client area of a richtextbox so I can paint line numbers at the side, therefore I need to reduce the client rectangle/area, any ideas on this.


NcCalcSize is the message to catch. What error did you get and what
line?

Matt

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: subash | last post by:
Hi All how to create controls in non-client area of forms or usercontrol.Can any one help in getting information on this or solution for this. regards subash
0
by: Ken Seier | last post by:
Hello, I'm trying to create a fairly standard custom container control by using the ScrollableControlDesigner attribute. My control has a title bar at the top, and I would like to exclude the...
0
by: Harry_Crow | last post by:
I'm painting in the Non Client area of the control. I'm facing some flicker problem. Is it possible to achive Double buffer painting in Non Client area. The SetStyle with...
10
by: Woody Splawn | last post by:
I have been developing a ClientServer application on one machine at my office but the time has come to transfer it to the customer. The customer is running a Windows 2000 local area network. I...
3
by: ljlevend | last post by:
I know that Invalidate allows you to invalidate only part of the client area and Refresh allows you to force the entire client area to update right now, but is there any way to force part of the...
0
by: helldiversafe-news | last post by:
Hi all, I will use a apache soap service with an .net c# client and have a problem with an complex array: <?xml version='1.0' encoding='UTF-8'?> <SOAP-ENV:Envelope...
3
by: TheSteph | last post by:
Hi, I've made a CustomPanel derived from the Panel class. How can I set my own size of the "client area" of that CustomPanel ? ("client area" = Size of the rectangle in which one can drop...
3
by: Harry_Crow | last post by:
I wanted to change the Non client area height. This was not possible in the existing Form TitleBar. So I set the FormBorderStyle= None and I calculated and introduced the Non Client area myself. So...
2
by: steve | last post by:
I have a configuration file where I save the size of the client area when my application last run. I would like to be able to set the size of the form's client area at start up to this value but if...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.