2.2.6.17.108 GridControl::SetIcon
Description
Sets icon with selected effect to given cell in fixed row
Syntax
bool SetIcon(int nRow, int nCol, HINSTANCE hInst, int nIconNum, int nNormalResID, int nSelectResID = 0, const vector<string>* pvstrToolTip = NULL, BOOL bSmall = TRUE, int nNormalOverlayResID = 0, int nSelectOverlayResID = 0)
Parameters
- nRow
- [input] 0-offset row index
- nCol
- [input] 0-offset column index
- hInst
- [input] Module handle
- nIconNum
- [input] icon number
- nNormalResID
- [input] normal state resource ID
- nSelectResID
- [input] select state resource ID
- bSmall
- [input] true to use small size icon
- pvstrToolTip
- [input] tool tips
- nNormalOverlayResID
- [input] resource to overlay over the icon of normal state
- nSelectOverlayResID
- [input] resource to overlay over the icon of select state
Return
true on successful or false on failure
Examples
The examples in this section will use an existing grid dialog resource DLL that gets installed with Origin C's Developer Kit. The DLL can be found in this zip file, under \Dialog Builder\GridDLG sub-folder.
#include <..\Originlab\DialogEx.h>
#include "GridDLGRes.h"// resource DLL header
#include <ocGDI.h>
class GridCtrlDLG : public ResizeDialog
{
public:
GridCtrlDLG() : ResizeDialog(IDD_GRID_DLG, "GridDLG")
{
}
int DoModal(HWND hParent = NULL)
{
InitMsgMap();
int nRet = ResizeDialog::DoModal(hParent);
return nRet;
}
protected:
///----------------- Message Map ----------------
EVENTS_BEGIN
ON_INIT(OnInitDialog)
ON_SIZE(OnDlgResize)
ON_GETMINMAXINFO(OnMinMaxInfo)
ON_GRID_ICON_CLICK(IDC_GRID, OnLabelIconClick)
ON_GRID_MOUSE_MOVE(IDC_GRID, OnMouseMove)//for tooltips
EVENTS_END
///----------------------------------------------
BOOL OnInitDialog()
{
ResizeDialog::OnInitDialog(0, "Grid Dialog");
//initialize grid control
m_GridCtrl.Init(IDC_GRID, *this);
m_GridCtrl.SetupRowsCols(1, 0, 4, 2);
m_GridCtrl.SetExplorerBar(flexBoldColLabel);
vector<string> vstrToolTip = {"Edit"};
HMODULE hModule = okutil_load_dll("ODlg8");
for(int ii = 0; ii < m_GridCtrl.GetNumCols(); ii++)
{
m_GridCtrl.SetIcon(0, ii, hModule, 1, IDI_SETTING_NORMAL, IDI_SETTING_SELECT, &vstrToolTip);
}
//move grid control to top left
RECT rrList;
rrList.top = rrList.left = GetControlGap();
m_GridCtrl.MoveWindow(rrList);
SetInitReady();
return TRUE;
}
BOOL OnDlgResize(int nType, int cx, int cy)
{
if(!IsInitReady())
return TRUE;
uint nButtonIDs[] = {IDOK, 0};
ArrangeMainItemAndControls(nButtonIDs, IDC_GRID, NULL, false);
return TRUE;
}
void OnLabelIconClick(Control ctrl, int nRow, int nCol, int nIndex)
{
printf("nRow=%d, nCol=%d, nIndex=%d\n", nRow, nCol, nIndex);
}
//for tooltips
void OnMouseMove(Control cntrl, short nButton, short nShift, float X, float Y)
{
m_GridCtrl.UpdateTooltipText();
}
private:
GridControl m_GridCtrl;
};
bool OpenGridDLG()
{
GridCtrlDLG myDlg;
myDlg.DoModal( GetWindow() );
return true;
}
Remark
See Also
- GridControl::SetCellIcon
- GridControl::SetColDotButtonIcon
Header to Included
GridControl.h
|