Objective Grid: Using a grid in applications written in plain C

Article ID: 428
Last updated: 27 Apr, 2018
Article ID: 428
Last updated: 27 Apr, 2018
Revision: 3
Views: 2500
Posted: 12 Jan, 2001
by Meltreger B.
Updated: 27 Apr, 2018
by Meltreger B.

Problem

 


Is it possible to integrate Objective Grid into applications written in plain C?  That means the grid has to do all its initialization itself because we cannot call any C++ methods.

 

 


Cause

 


 

 


Action

 


Yes, that's possible. You can implement a User DLL and derive a class from CGXGridWnd and put the initialization code into the OnCreate() message handler. By registering the grid window class through the DECLARE_REGISTER() / IMPLEMENT_REGISTER() macros, you can use it just like any other MS Windows control with the MS SDK CreateWindow() method.
 

// Declaration for CSampleGridWnd class
class CSampleGridWnd : public CGXGridWnd
{
DECLARE_REGISTER()
public:
// Generated message map functions

//{{AFX_MSG(CSample4GridWnd)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
//}}AFX_MSG

DECLARE_MESSAGE_MAP()

};

////////////////////////////////////////////////////////////////////
// Implemenation of CSampleGridWnd class

IMPLEMENT_REGISTER(CSampleGridWnd, CS_DBLCLKS|CS_GLOBALCLASS, 0, 0, 0);

BEGIN_MESSAGE_MAP(CSampleGridWnd, CGXGridWnd)

//{{AFX_MSG_MAP(CSampleGridWnd)
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

int CSampleGridWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{

if (CGXGridWnd::OnCreate(lpCreateStruct) == -1)
return -1;
Initialize();

SetRowCount(256);
SetColCount(52);

return 0;

}

// Now, you can create instances by embedding CsampleGridWnd
// as user control with the class name CSampleGridWnd in
// your dialog template or by creating it with SDK method
// CreateWindow.

// Example:
BOOL CMySampleDialog::OnInitDialog()
{

CDialog::OnInitDialog();

// IDC_GRIDWND is a static frame in the dialog template
CWnd* pGridFrame = GetDlgItem(IDC_GRIDWND);

if (pGridFrame)
{

// Retrieve the size of the frame 
// and convert the coordinates to
// use the dialog coordinates (from 
// screen coordinates).
CRect rect;
pGridFrame->GetWindowRect( &rect );
ScreenToClient(&rect);

DWORD dwFlags = WS_TABSTOP | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_VISIBLE;

#if _MFC_VER >= 0x0400 && _GX_VER >= 0x0110
// draw grid with sunken borders
dwFlags |= WS_EX_CLIENTEDGE;
#endif
// Create the window with SDK method
::CreateWindow(_T(CSample4GridWnd), NULL, dwFlags | WS_CHILD, rect.left, rect.top, rect.Width(), rect.Height(), GetSafeHwnd(), NULL, AfxGetInstanceHandle(), NULL);

return FALSE;

}

return TRUE;

}

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

Others in this category