Reversing text in TreeView nodes

  • Thread starter Thread starter Allen Anderson
  • Start date Start date
A

Allen Anderson

I haven't received an answer to my question of a few days ago regarding a
flipped treeview control posted in the dotnet.framework.windowsforms.control
newsgroup, so I thought I'd ask it again. Sorry about the cross-posting,
but I'm getting desperate as the drop-dead date, the 25th of this month, on
my project approaches.

I'm attempting to create a TreeView similar to the one on the right-hand
side of the BizTalk Mapper screen. I'm able to create a mirror image of a
normal TreeView with everything swapped left-for-right, kind of like looking
at the reflection of the tree in a mirror; unfortunately, that everything
also includes the text for each node. Is there a way of creating a bitmap of
each visible node and performing a
Bitmap.RotateFlip(RotateFlipType.RotateNoneFlipX) on it prior to performing
a Bitmap.RotateFlip(RotateFlipType.RotateNoneFlipX) on the bitmap of the
entire tree? Is there another way of accomplishing the same thing?

Any help would be greatly appreciated.
 
The only way you can do this is to custom draw the whole treeview. I assume
that you're capturing an image and then flipping that. This method will
never allow you to separate the text from the graphic and selectively flip
or move depending on positions in the bitmap.

Treeviews are common controls underneath. You should be able to use the
WM_NOTIFY based custom draw messages to draw the nodes in a right-to-left
cascade.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
Quick hack in VB.Net

Inherit from Treeview and add the following code:
\\\
Protected Overrides ReadOnly Property CreateParams() As CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
Const WS_EX_LAYOUTRTL As Integer = &H400000
Const WS_EX_NOINHERITLAYOUT As Integer = &H100000
If Me.Mirror Then
cp.ExStyle += WS_EX_LAYOUTRTL Or WS_EX_NOINHERITLAYOUT
End If
Return cp
End Get
End Property

Private m_Mirror As Boolean = False

<DefaultValue(False)> _
Public Property Mirror() As Boolean
Get
Return m_Mirror
End Get
Set(ByVal Value As Boolean)
If m_Mirror = Value Then Return
m_Mirror = Value
MyBase.UpdateStyles()
End Set
End Property
///
 
Mick and Bob,

Both of you guys are great! This is exactly what I needed!

Bob Powell said:
Learn something new every day....

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





"Mick Doherty"
 
That's the cleanest, most direct and most elegant solution I've EVER seen
for a problem this potentially complicated....
Wow!!
VBen.

"Mick Doherty"
 
If anyone is interested, I tried this solution.
It's great, since it does exactly that: Draw the nodes cascade in a right to
left cascade... There's just one problem: Wether you establish
"WS_EX_NOINHERITLAYOUT" or not, the images in the treeview are drawn
mirrored, and the text is drawn correctly (I tried establishing also
WS_EX_RTLREADING with the same results).
The solution is as simple as mirroring images before loading them into the
ImageList control, but if anyone has the correct solution for that
particular problem, I'd like to know about it (just curious)...
Regards,
VBen.

VBen said:
That's the cleanest, most direct and most elegant solution I've EVER seen
for a problem this potentially complicated....
Wow!!
VBen.

"Mick Doherty"
<EXCHANGE#[email protected].[mdaudi100#ntlworld.com]> escribió
en el mensaje news:#[email protected]...
Quick hack in VB.Net

Inherit from Treeview and add the following code:
\\\
Protected Overrides ReadOnly Property CreateParams() As CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
Const WS_EX_LAYOUTRTL As Integer = &H400000
Const WS_EX_NOINHERITLAYOUT As Integer = &H100000
If Me.Mirror Then
cp.ExStyle += WS_EX_LAYOUTRTL Or WS_EX_NOINHERITLAYOUT
End If
Return cp
End Get
End Property

Private m_Mirror As Boolean = False

<DefaultValue(False)> _
Public Property Mirror() As Boolean
Get
Return m_Mirror
End Get
Set(ByVal Value As Boolean)
If m_Mirror = Value Then Return
m_Mirror = Value
MyBase.UpdateStyles()
End Set
End Property
///
of
 
Back
Top