Visualizing/Manipulating Nodes in a Linked List?

This is a discussion on Visualizing/Manipulating Nodes in a Linked List? within the Windows Programming forums, part of the Platform Specific Boards category; I am trying to design a Win32/C program that maintains a bi-directional linked list, individual nodes of which can be ...

Visualizing/Manipulating Nodes in a Linked List?

I am trying to design a Win32/C program that maintains a bi-directional linked list, individual nodes of which can be modified, inserted, deleted, etc. by a visual interface. I have created small bitmap images representing different node "types."

I think would be fairly straightforward to write a paint procedure that cycles through the linked list to paint bitmaps corresponding to the different node types. The problem is, I don't see how they could be selected/acted upon unless the nodes are "objectified" in some way. (Maybe mouse clicks could be correlated to the bitmap dumps appearing in the client window, but that sounds like a lot of programming overhead.)

Reading ahead into Petzold, I don't quite see how I will accomplish this. I'm guessing that each node could be a button control. The problem I see is that (1) the buttons would be printed on the main window (frame), not a dialog box, and (2) there is no standard button I'm aware of that would incorporate my bitmap. Petzold mentions user-defined controls. Perhaps I could create a custom button composed of the bitmap, but that sounds complicated.

Am I making sense? I'm trying to get a realistic idea of how to actually implement this as I read through Petzold. And yes, I am an absolute Win32 newbie. Ideas or directions would be appreciated!

When doing things like this I custom draw the image and record the rectange/region that can be clicked. (ie as you draw the image for a node, with FillRect() or BitBlt()etc, record the position as part of the node).

When the user clicks on the screen (and you get a mouse button down msg) test each node's rectangle/region to see if contains the location clicked (look at PtInRect() ).

Make sure you use the same coord system, screen or client.

IIRC you have to convert the mouse click from screen to client coords with ScreenToClient() (or store the rectangle/region in screen coords after drawing it in client).

[screen coords have the top left of the monitor's screen as 0,0 while client coords have the top left of the window's client area as 0,0]

WM_PAINT should be a single BitBlt() from your buffer (or memory DC) to the DC in the PAINTSTRUCT (from BeginPaint()) and only the rect in the PAINTSTUCT should be redrawn (not the whole client area).

All drawing should be done in response to other msgs and then the screen updated with an InvalidateRect() and UpdateWindow() call (as UpdateWindow() bypasses the OS msg queue and posts the paint msg directly to the window's callback).