Objective Grid: Adding What's this? context-sensitive help to grid elements

Article ID: 471
Last updated: 25 Apr, 2018
Article ID: 471
Last updated: 25 Apr, 2018
Revision: 3
Views: 1519
Posted: 24 Jan, 2001
by Meltreger B.
Updated: 25 Apr, 2018
by Meltreger B.

Problem

 


Can I have What's this? type context-sensitive help on a per cell basis?

 

 


Cause

 


 

 


Action

 


You can register an user attribute in the grid (let's say IDS_UA_HELPID) and assign this help ID to cells, rows, or columns. For example,
 

SetStyleRange(CGXRange().SetCols(1), CGXStyle().SetUserAttribute(IDS_UA_HELP, szhelpId));

To implement the What's this functionality, you have to process the WM_HELPHITTEST function which is described in MFC Technote 28.

To do this:

  1. Include afxpriv.h
  2. Add declaration

  3.  
    afx_msg LRESULT OnHelpHitTest(WPARAM wParam, LPARAM lParam);
  4. Add to message map

  5.  
    ON_MESSAGE(WM_HELPHITTEST, OnHelpHitTest)
  6. Implementation of this method

  7.  
    LRESULT COGLView::OnHelpHitTest(WPARAM, LPARAM lParam)
    {
    CPoint ptTest(LOWORD(lParam), HIWORD(lParam));

    ASSERT_VALID(this);

    ROWCOL nRow = CalcClientRowFromPt(ptTest);
    ROWCOL nCol = CalcClientColFromPt(ptTest);
    LRESULT nID = 0;

    if (nRow != GX_INVALID && nCol != GX_INVALID)
    {

    TRACE(OnHelpHitTest: nRow %lu, nCol %lu , GetRow(nRow), GetCol(nCol));

    CGXStyle style;
    ComposeStyleRowCol(GetRow(nRow), GetCol(nCol), &style);

    nID = atol(style.GetUserAttribute(IDS_UA_HELP));

    }

    return nID;

    }

This article was:   Helpful | Not helpful
Report an issue
Article ID: 471
Last updated: 25 Apr, 2018
Revision: 3
Views: 1519
Posted: 24 Jan, 2001 by Meltreger B.
Updated: 25 Apr, 2018 by Meltreger B.

Others in this category