Objective Grid: How do I display a grid with a Record Beam in a dialog?

Article ID: 375
Last updated: 27 Apr, 2018
Article ID: 375
Last updated: 27 Apr, 2018
Revision: 3
Views: 2433
Posted: 24 Jan, 2001
by Meltreger B.
Updated: 27 Apr, 2018
by Meltreger B.

Problem

 


How do I display a grid with a Record Beam in a dialog?

 

 


Cause

 


 

 


Action

 


You can find the original code in the gxquery sample (sampdlg.cpp/.h).

First, you should place a user control in the dialog, with class name GXWND, so that you can subclass this control with the CGXRecordInfoWnd.

Example for dialog template:
 

IDD_DLGRECORDWND DIALOG DISCARDABLE 0, 0, 326, 206 
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION Dialog with ODBC grid
FONT 8, MS Sans Serif
BEGIN
GROUPBOX &Query Results,IDC_STATIC,5,7,312,176
DEFPUSHBUTTON &OK,IDOK,5,187,50,14,NOT WS_TABSTOP
PUSHBUTTON &Cancel,IDCANCEL,72,186,50,14
CONTROL User1,IDC_ODBCSAMPLEGRID,GXWND,WS_BORDER | WS_TABSTOP,12,20,299,158
END

Next, in your dialog class, you should declare objects for your CGXGridWnd-derived class and for the CGXRecordInfoWnd.
 

////////////////////////////////////////////////////////
// CrecordWndSampleDialog dialog
class CRecordWndSampleDialog : public Cdialog
{
// Construction
public:
CRecordWndSampleDialog(CWnd* pParent = NULL);
// Dialog Data
//{{AFX_DATA(CRecordWndSampleDialog)
enum { IDD = IDD_DLGRECORDWND };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
CGXGridWnd m_wndGrid;
CGXRecordInfoWnd m_infoWnd;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CrecordWndSampleDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CRecordWndSampleDialog)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
Finally, you should override OnInitDialog() and subclass the GXWND control:
////////////////////////////////////////////////////////
// CRecordWndSampleDialog message handlers
BOOL CRecordWndSampleDialog::OnInitDialog()
{
CDialog::OnInitDialog();

m_infoWnd.SubclassDlgItem(IDC_ODBCSAMPLEGRID, this);
m_wndGrid.Create(0, CRect(0,0,1,1), &m_infoWnd, IDC_ODBCSAMPLEGRID);
m_infoWnd.AttachWnd(&m_wndGrid);
m_wndGrid.Initialize();
m_wndGrid.SetFocus();

return TRUE;

}

Now, it should work.

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

Others in this category