Classes I wrote for easy use of RAEdit, RAGrid, RAHexEd in C++,
including following 5 classes:

CommonWindow
RAControl (inherits CommonWindow)
RAEdit (inherits RAControl)
RAGrid (inherits RAControl)
RAHexEd (inherits RAControl)

more functions will be added to the classes with the going on of my project.
Posted on 2004-03-17 21:29:25 by optimus
Hi Optimus,

your code is really good, I like it.

ipadilla
Posted on 2004-03-18 10:30:51 by ipadilla
a modified RAGrid class, added some more functions.



class RAGRID:public RAControl
{
public:
HWND Create(HWND hwndParent,DWORD style);
void AddColumn (char *colName, long colWidth, long colType, long nTextMax, long Align);
void SetFont (TCHAR *FontName,long FontHeight, long FontBold);
void AddRow()
{SendMessage(hwnd, GM_ADDROW, 0, 0);}
void ResetColumn ()
{SendMessage(hwnd,GM_RESETCOLUMNS,0,0);}
void SetRowHeight(int height)
{SendMessage(hwnd,GM_SETROWHEIGHT,0,height);}
void SetColWidth(int col, int width)
{SendMessage(hwnd, GM_SETCOLWIDTH, col, width);}
void SetHDRHeight(int height)
{SendMessage(hwnd,GM_SETHDRHEIGHT,0,height);}
void SetCell (WORD col, WORD row, void *data)
{SendMessage(hwnd,GM_SETCELLDATA,MAKELONG(col,row),(LPARAM)data);}
int GetCurCol()
{return SendMessage(hwnd, GM_GETCURCOL, 0, 0);}
void SetCurCol(int col)
{SendMessage(hwnd, GM_SETCURCOL, col, 0);}
int GetCurRow()
{return SendMessage(hwnd, GM_GETCURROW, 0, 0);}
void SetCurRow(int Row)
{SendMessage(hwnd, GM_SETCURROW, Row, 0);}
int GetRowCount()
{return SendMessage(hwnd, GM_GETROWCOUNT, 0, 0);}
RAGRID() {hDll=LoadLibrary("RAGRID.DLL");}
~RAGRID() {FreeLibrary(hDll);}
private:

};

HWND RAGRID::Create(HWND hwndParent,DWORD style)
{
hwnd= CreateWindowEx(0x200, "RAGRID", 0, 0x50010000 | style, 0, 0, 0, 0, hwndParent, 0, (HINSTANCE)0x400000, 0);
SetFont(NULL,14,0);
this->hwndParent=hwndParent;
return hwnd;
}

void RAGRID::AddColumn (char *colName, long colWidth, long colType, long nTextMax, long Align)
{
COLUMN col;

col.colwt = colWidth;
col.szhdrtext = colName;
col.halign = Align;
col.calign = Align;
col.ctype = colType;
col.szformat = 0;
col.himl = 0;
col.hdrflag = 0;
if (!nTextMax)
col.ctextmax = 16;
else
col.ctextmax = nTextMax;

SendMessage(hwnd, GM_ADDCOL, 0, (LPARAM)&col);
}

void RAGRID::SetFont (TCHAR *FontName,long FontHeight, long FontBold)
{
LOGFONT LF;
HFONT hFont;
ZeroMemory(&LF,sizeof(LF));

LF.lfHeight=FontHeight;
LF.lfItalic = 0;

if (FontBold)
LF.lfWeight = 700;
else
LF.lfWeight = 400;
if (FontName)
lstrcpy(LF.lfFaceName,FontName);
else
lstrcpy(LF.lfFaceName,"Tahoma");

hFont = CreateFontIndirect(&LF);
SendMessage(hwnd, WM_SETFONT, (WPARAM)hFont, 0);
}
Posted on 2004-03-18 21:19:44 by optimus