Click here to Skip to main content
16,005,241 members
Home / Discussions / C#
   

C#

 
GeneralRe: Aeru IRC is looking for developpers and artist Pin
jtmtv183-Mar-03 19:17
jtmtv183-Mar-03 19:17 
GeneralRe: Aeru IRC is looking for developpers and artist Pin
Shock The Dark Mage5-Mar-03 15:47
Shock The Dark Mage5-Mar-03 15:47 
GeneralFlattening The TreeView... Pin
LokiSD2-Mar-03 10:26
LokiSD2-Mar-03 10:26 
GeneralRe: Flattening The TreeView... Pin
LokiSD3-Mar-03 7:42
LokiSD3-Mar-03 7:42 
GeneralRe: Flattening The TreeView... Pin
Furty4-Mar-03 1:49
Furty4-Mar-03 1:49 
GeneralRe: Flattening The TreeView... Pin
LokiSD5-Mar-03 6:51
LokiSD5-Mar-03 6:51 
GeneralRe: Flattening The TreeView... Pin
Furty5-Mar-03 12:06
Furty5-Mar-03 12:06 
GeneralRe: Flattening The TreeView... Pin
Furty5-Mar-03 13:23
Furty5-Mar-03 13:23 
Here's how to user-paint the border of the TreeView control:

1) Create a class that inherits from System.Windows.Forms.TreeView

2) Add the follwing using directive:

using System.Runtime.InteropServices;

3) In the class body, add the following user32.dll wrapper method:

[DllImport("user32.dll", CharSet=CharSet.Auto)]<br />
    private static extern IntPtr GetWindowDC(IntPtr hWnd);

4) Add the follwing WndProc override method:

protected override void WndProc(ref System.Windows.Forms.Message m)<br />
    {<br />
        if( m.Msg == 0x0085 /* WM_NCPAINT */ )<br />
            PaintBorder();<br />
        else<br />
            base.WndProc(ref m);<br />
    }


5) Add the PaintBorder method:
<br />
	private void PaintBorder()<br />
		{<br />
			Graphics g = Graphics.FromHdc(GetWindowDC(this.Handle));<br />
			// do not use the ClientRectangle for painting the border<br />
			// instead, create the rectangle from the Width and Height properties<br />
			Rectangle r = new Rectangle(0, 0, Width, Height);<br />
			<br />
			// Paint your border as required<br />
			// ..<br />
			<br />
			// Dispose the graphics object and any brushes created<br />
			g.Dispose();<br />
		}<br />
That's it! Note that every control has it's own unique methods for border painting. This particular method will work only for some of the controls,
others will require the WM_NCPAINT to be handled by WndProc before you go painting border, causing a double-paint. Other controls require you to
create the Graphics object from the actual parent form rather than the control itself.

On final note, ensure the border style is 3D, not Single or none.

Hope this helps!
GeneralSnapshot Pin
Calamitous2-Mar-03 3:39
Calamitous2-Mar-03 3:39 
GeneralRe: Snapshot Pin
Jon Newman2-Mar-03 4:57
Jon Newman2-Mar-03 4:57 
GeneralProblem with Windows Installer Pin
Sassan Komeili Zadeh2-Mar-03 3:03
Sassan Komeili Zadeh2-Mar-03 3:03 
GeneralRe: Problem with Windows Installer Pin
Jon Newman2-Mar-03 4:27
Jon Newman2-Mar-03 4:27 
GeneralRe: Problem with Windows Installer Pin
Sassan Komeili Zadeh3-Mar-03 20:22
Sassan Komeili Zadeh3-Mar-03 20:22 
GeneralRe: Problem with Windows Installer Pin
Paul Riley2-Mar-03 5:15
Paul Riley2-Mar-03 5:15 
GeneralRe: Problem with Windows Installer Pin
Sassan Komeili Zadeh3-Mar-03 20:27
Sassan Komeili Zadeh3-Mar-03 20:27 
GeneralRe: Problem with Windows Installer Pin
Paul Riley4-Mar-03 3:44
Paul Riley4-Mar-03 3:44 
Generalexpose delegate in property grid Pin
Roger Alsing2-Mar-03 0:12
Roger Alsing2-Mar-03 0:12 
GeneralRe: expose delegate in property grid Pin
leppie2-Mar-03 1:49
leppie2-Mar-03 1:49 
GeneralRe: expose delegate in property grid Pin
Roger Alsing2-Mar-03 4:07
Roger Alsing2-Mar-03 4:07 
GeneralRe: expose delegate in property grid Pin
leppie2-Mar-03 11:37
leppie2-Mar-03 11:37 
GeneralRe: expose delegate in property grid Pin
leppie2-Mar-03 1:54
leppie2-Mar-03 1:54 
GeneralIPAddress range Pin
Mr BallyDaHob1-Mar-03 4:42
Mr BallyDaHob1-Mar-03 4:42 
GeneralRe: IPAddress range Pin
leppie1-Mar-03 6:27
leppie1-Mar-03 6:27 
Generalputting an img... Pin
sacoskun1-Mar-03 1:47
sacoskun1-Mar-03 1:47 
GeneralRe: putting an img... Pin
leppie1-Mar-03 6:17
leppie1-Mar-03 6:17 

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.