George
George

Reputation: 70

Custom controls, winapi

Can somebody tell me, is it realistic to make progressbar as a part of treeView control in the winapi? I made a GUI with GTK, and using a progressbar as element of a cell works well, as in this image.

enter image description here

I have no experience with developing custom controls, so I'd like to know, is it realistic to be able to do something like I did with GTK with the winapi, or would it be a waste of time?

Upvotes: 3

Views: 342

Answers (1)

andlabs
andlabs

Reputation: 11578

If you want to show a progress bar in a non-tree-like data table, you don't have to resort to custom controls. The typical solution is to use a standard Windows API List View control in Report mode, which provides the tabular view GtkTreeView provides, using "owner draw" for the column that provides the progress information. How to do this is very well documented, but it involves listening for a WM_NOTIFY from the list view in its parent window's window procedure, looking for a NM_CUSTOMDRAW notification. The NM_CUSTOMDRAW notification comes with everything you need to draw individual cells or even entire rows of the list view. Simply determine that this is the column you want to draw, draw it, and let the system draw everything else.

If you are, however, going to use a tree, and not just a flat table, then you will have more work to do. GtkTreeView lets you have multicolumn trees, but the Windows API stock controls only let you either have multicolumn tables (List View) or single-column trees (Tree View). There are packages like mCtrl that give you a multicolumn tree control for you if that's what you want, and they will work similarly to the List View control, so you would also use the custom draw method above.

(You can imagine a List View as a GtkTreeView of GtkTreeViewColumns that have a GtkCellArea with at most one GtkCellRenderPixbuf and at most one GtkCellRendererText in them, and the first column can also have at most one GtkCellRendererToggle. Likewise, you can imagine a Tree View as a GtkTreeView with only one GtkTreeViewColumn and invisible column headers, that has at most one GtkCellArea with at most one GtkCellRendererToggle, GtkCellRendererImage, and GtkCellRendererText each.)

I'm not familiar with any pre-built custom control that already exists that imitates the cell-renderer system that GtkTreeView uses. The List View and Tree View controls did not do this due to a combination of lack of necessity and added complexity for the cases these controls were written for (Explorer). (I have been working on one of my own, but I've been busy so I don't know when it will be done.)

Upvotes: 4

Related Questions