Re: Drawing lines in a CListCtrl
- From: "AliR" <AliR@xxxxxxxxxxxxx>
- Date: Thu, 2 Mar 2006 15:16:26 -0600
I would simply use a CWnd or CStatic as the container. You will run into the
same drawing problem with a CEdit.
As far as the items go, unless you need the functionality of a Button, I
would use a CWnd or CStatic, but a CButton should also be fine.
As far as drag and drop goes. That can be a little tricky. Typically drag
and drop is done using OLE (CDataSource, and CDropTarget), so what you will
have to do is detect the dragging in your item's class (CWnd or CButton...)
create the CDataSource and set its drag icon to be the same as the picture
of the item begin dragged. You will also have to implement a CDropTarget
somewhere, either in each item, or at the parent level (the container
class), to get the drops.
With all that said, I would probably not do any of that. I would use a CWnd
as the container window.
Then I would create a class for the items, the class would look something
like this
class CListItem
{
public:
void Draw(CDC *pDC);
BOOL HitTest(const CPoint &Pt);
private:
CRect m_Rect;
CBitmap m_Image;
.... any other info that is needed.
}
and use a CList or a link list to keep track of all the items that the
container owns, and draw them.
For drag and drop, handle the WM_LBUTTONDOWN, WM_LBUTTONUP, and
WM_MOUSEMOVE. And do the drag and drop by detecting which item they clicked
on and dragged, and when the let the mouse button up, which object (if any)
the dropped it on.
I hope this helps.
AliR.
"TPFGuru" <TPFGuru@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:9E620E31-8F82-4DF3-B6B0-B6AEB5C0EB36@xxxxxxxxxxxxxxxx
Thanks. I figured as much. I can see the lines after the WM_PAINT, butthe
items aren't drawn.shooting
What do you recommend I use? Maybe a big edit control, where I create and
place buttons with Icons to behave like the CListCtrl items? I am
for the kind of display that Maya 7 does for the HyperGraph, which seemsto
use buttons to represent the items, and you can drag a button onto anotherto
set the relationship. Could I detect when one button is dragged overanother
easily?change it
Thanks!
"AliR" wrote:
.... Trying to draw to
the window with DC commands may not be possible. I could always
hasto
a basic window and just draw it all manually.
That's probably your best option. I know that customizing CListCtrl and
CTreeCtrl is almost next to impossible. The problem is that Microsoft
whatevernot left any room for customization of these controls. Chances are
drawyou draw on the DC during the paint message will get wiped out by some
interal drawing of the control (like scrolling...)
AliR.
"TPFGuru" <TPFGuru@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:CBBB98F6-0BE9-40B3-9FAB-326BA73B30D5@xxxxxxxxxxxxxxxx
Thanks. Everything I have seen so far involves changing the LVxxxproperty
of a control item or doing a CListCtrl.Set.... command. Trying to
change itto
the window with DC commands may not be possible. I could always
doingto
a basic window and just draw it all manually.
Thanks.
"Tom Serface" wrote:
I've never tried to do this, but if I were to try, I'd try either
allin
DrawItem().it OnPaint() or making it an owner drawn control and do it in
lines?
Tom Archer's recent article might be interesting to you as well:
http://www.microsoft.com/indonesia/msdn/customdraw.aspx
Tom
"TPFGuru" <TPFGuru@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:A52FEB6F-4BBF-4576-AD28-337AF76C1580@xxxxxxxxxxxxxxxx
So, no one knows where I stick two drawing instructions:
MoveToEx(dc, Pos1.x, Pos1.y, NULL);
LineTo(dc, Pos2.x, Pos2.y);
for a CListCtrl so that it will correctly draw the items and the
structure of
"TPFGuru" wrote:
Hi, I am using a CListCtrl in LVS_ICON mode to create a tree
my
icons (which are the bones of a skinned mesh). I have the icons
anddrawing
OK, but would like to draw a red line to link a parent to a child
cannota
blue
line to link siblings.
I have tried various ways of getting the lines to draw, but
get
lines, Ithe
control to draw both the items and lines at the same time. If I
over-ride
the WM_PAINT message in my CListCtrl derived class and draw the
called bycannot see the items.
If instead I write a separate routine to draw the lines that is
control'sthe dialog class, it draws the items but not the lines.
How can I have the control draw both?
I have also tried using UpdateWindow() and Update(nItem) in the
OnPaint function without success.
Thanks!
.
- Follow-Ups:
- Re: Drawing lines in a CListCtrl
- From: TPFGuru
- Re: Drawing lines in a CListCtrl
- References:
- Re: Drawing lines in a CListCtrl
- From: Tom Serface
- Re: Drawing lines in a CListCtrl
- From: AliR
- Re: Drawing lines in a CListCtrl
- From: TPFGuru
- Re: Drawing lines in a CListCtrl
- Prev by Date: Re: Drawing lines in a CListCtrl
- Next by Date: Re: DDE error
- Previous by thread: Re: Drawing lines in a CListCtrl
- Next by thread: Re: Drawing lines in a CListCtrl
- Index(es):
Relevant Pages
|