- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to use CVF 6.1 (though I also have v6.6 that I haven't installed yet) to set the checkbox state on a treeview control. The SDK gives the example in C below. I can duplicate this in Fortran except for the line where tvItem.state = INDEXTOSTATEIMAGEMASK... But when I do that, the fortran compiler says INDEXTOSTATEIMAGEMASK is undefined (though I call "use dfwin" and "use Comctl32"). Any ideas would be appreciated.
Larry Scheier
SEI Associates
BOOL TreeView_SetCheckState(HWND hwndTreeView, HTREEITEM hItem, BOOL fCheck)
{
TVITEM tvItem;
tvItem.mask = TVIF_HANDLE | TVIF_STATE;
tvItem.hItem = hItem;
tvItem.stateMask = TVIS_STATEIMAGEMASK;
/*
Since state images are one-based, 1 in this macro turns the check off, and
2 turns it on.
*/
tvItem.state = INDEXTOSTATEIMAGEMASK((fCheck ? 2 : 1));
return TreeView_SetItem(hwndTreeView, &tvItem);
}
Larry Scheier
SEI Associates
BOOL TreeView_SetCheckState(HWND hwndTreeView, HTREEITEM hItem, BOOL fCheck)
{
TVITEM tvItem;
tvItem.mask = TVIF_HANDLE | TVIF_STATE;
tvItem.hItem = hItem;
tvItem.stateMask = TVIS_STATEIMAGEMASK;
/*
Since state images are one-based, 1 in this macro turns the check off, and
2 turns it on.
*/
tvItem.state = INDEXTOSTATEIMAGEMASK((fCheck ? 2 : 1));
return TreeView_SetItem(hwndTreeView, &tvItem);
}
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
INDEXTOSTATEIMAGEMASK is just a C macro. Since Fortran does not support macros, Compaq has turned these "pseudo-APIs" into functions and assembled them in DFWIN.lib (with interfaces in DFWIN). However, not all are translated, and this one is not even supported in 6.6B.
MSDN says that:
The INDEXTOSTATEIMAGEMASK macro is defined as follows:
#define INDEXTOSTATEIMAGEMASK(i) ((i) << 12)
which is matched with ISHL(i,12) in Fortran.
Jugoslav
MSDN says that:
The INDEXTOSTATEIMAGEMASK macro is defined as follows:
#define INDEXTOSTATEIMAGEMASK(i) ((i) << 12)
which is matched with ISHL(i,12) in Fortran.
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, Jugoslav. That was exactly the hint I needed. For anyone interested how to set a treeview checkbox state, here is the code:
SUBROUTINE TreeView_SetCheckState(TVitem, hItem, fCheck)
USE Comctl32
INTEGER*4 hItem !handle to treeview item
INTEGER*4 fCheck !1=turn checkbox off; 2= turn checkbox on
TYPE (T_TVITEM) TVitem !Treeview item structure
!* Validate item properties to be returned
tvItem.mask = IOR(TVIF_TEXT, IOR(TVIF_HANDLE , TVIF_STATE))
!* Pass handle of selected tree item
tvItem.hItem = hItem
!* Set stateMask flag
tvItem.stateMask = TVIS_STATEIMAGEMASK
!* Since state images are one-based, 1 in this macro turns the check off,
!* and 2 turns it on.
tvItem.state = ISHL(fCheck,12)
END SUBROUTINE
SUBROUTINE TreeView_SetCheckState(TVitem, hItem, fCheck)
USE Comctl32
INTEGER*4 hItem !handle to treeview item
INTEGER*4 fCheck !1=turn checkbox off; 2= turn checkbox on
TYPE (T_TVITEM) TVitem !Treeview item structure
!* Validate item properties to be returned
tvItem.mask = IOR(TVIF_TEXT, IOR(TVIF_HANDLE , TVIF_STATE))
!* Pass handle of selected tree item
tvItem.hItem = hItem
!* Set stateMask flag
tvItem.stateMask = TVIS_STATEIMAGEMASK
!* Since state images are one-based, 1 in this macro turns the check off,
!* and 2 turns it on.
tvItem.state = ISHL(fCheck,12)
END SUBROUTINE
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page