October 31, 2025, 05:06:05 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


SD DataGrid

Started by ckoehn, January 28, 2010, 08:10:37 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ckoehn

Has anybody used "SD Data Grid"?  Below is the program I tried and it doesn't generate any errors, but neither does it load.  I probably missed something.  I generated a library file and have an include file with the declarations and types.


$INCLUDE "windows.inc"
$INCLUDE "SdDataGrid.inc"

CONST File_Exit=1
CONST Proj_Bills=2
CONST Proj_Payroll=3
CONST Proj_Income=4
CONST Proj_Reports_941=5
CONST Proj_Reports_BalanceSheet=6

DEF w1:WINDOW
DEF sysBackColor,hGrid:UINT
DEF SD_Drive:String
DEF iGrid,IDGRID,hDCw1:INT
DEF cols[7]:ColInfoInt

IF OPENWINDOW(w1,0,0,640,480,@MINBOX|@MAXBOX|@SIZE|@MAXIMIZED,0,"Grid Test",&main)=0
MESSAGEBOX Null,"Window failed to create","Grid Test"
END
ENDIF
BEGINMENU w1
MENUTITLE "File"
MENUITEM "E&xit",0,File_Exit
MENUTITLE "&Project"
MENUITEM "&Bills",0,Proj_Bills
MENUITEM "&Payroll",0,Proj_Payroll
SEPARATOR
MENUITEM "&Income",0,Proj_Income
SEPARATOR
BEGINPOPUP "&Reports..."
MENUITEM "&941",0,Proj_Reports_941
MENUITEM "&Balance Sheet",0,Proj_Reports_BalanceSheet
ENDPOPUP
ENDMENU

hdcw1= GETHDC(w1)

sysBackColor=_GetSysColor(15)

SETFONT w1,"Times New Roman",11,2

hGrid=CreateGrid(hdcw1, iGrid, GRIDSTYLE_SUNKEN , IDGRID, 30, 30, 640, 480)
DimCols(hGrid,7)
'col 1
cols[0].ColName="Date":cols[0].ColWidth=50:cols[0].fldSize=12:cols[0].Alignment=HDF_LEFT:cols[0].DataType=SD_CHAR:cols[0].ColForeClr=0:cols[0].ColBackClr=sysBackColor
cols[1].ColName="Check":cols[1].ColWidth=50:cols[1].fldSize=12:cols[1].Alignment=HDF_LEFT:cols[1].DataType=SD_CHAR:cols[1].ColForeClr=0:cols[1].ColBackClr=sysBackColor
cols[2].ColName="Description":cols[2].ColWidth=200:cols[2].fldSize=50:cols[2].Alignment=HDF_LEFT:cols[2].DataType=SD_CHAR:cols[2].ColForeClr=0:cols[2].ColBackClr=sysBackColor
cols[3].ColName="Memo":cols[3].ColWidth=200:cols[3].fldSize=50:cols[3].Alignment=HDF_LEFT:cols[3].DataType=SD_CHAR:cols[3].ColForeClr=0:cols[3].ColBackClr=sysBackColor
cols[4].ColName="Debit":cols[4].ColWidth=50:cols[4].fldSize=12:cols[4].Alignment=HDF_LEFT:cols[4].DataType=SD_CHAR:cols[4].ColForeClr=0:cols[4].ColBackClr=sysBackColor
cols[5].ColName="Credit":cols[5].ColWidth=50:cols[5].fldSize=12:cols[5].Alignment=HDF_LEFT:cols[5].DataType=SD_CHAR:cols[5].ColForeClr=0:cols[5].ColBackClr=sysBackColor
cols[6].ColName="Total":cols[6].ColWidth=100:cols[6].fldSize=12:cols[6].Alignment=HDF_LEFT:cols[6].DataType=SD_CHAR:cols[6].ColForeClr=0:cols[6].ColBackClr=sysBackColor

DefineField(hGrid,1,FIELD_EDITBOX,cols[0])
DefineField(hGrid,2,FIELD_EDITBOX,cols[1])
DefineField(hGrid,3,FIELD_EDITBOX,cols[2])
DefineField(hGrid,4,FIELD_EDITBOX,cols[3])
DefineField(hGrid,5,FIELD_EDITBOX,cols[4])
DefineField(hGrid,6,FIELD_EDITBOX,cols[5])
DefineField(hGrid,7,FIELD_EDITBOX,cols[6])

run=1
WAITUNTIL run=0

FinishEditing(hGrid)
FreeGrid(hGrid)

CLOSEWINDOW w1
END

SUB main
SELECT @MESSAGE
CASE @IDCREATE
CENTERWINDOW w1
CASE @IDCLOSEWINDOW
run=0
CASE @IDSIZE
CASE @IDMENUPICK
SELECT @MENUNUM
CASE File_Exit
run=0
CASE Proj_Bills

CASE Proj_Payroll

CASE Proj_Income

CASE Proj_Reports_941

CASE Proj_Reports_BalanceSheet
ENDSELECT
ENDSELECT
ENDSUB

billhsln

Could you share the "SdDataGrid.inc" file.  I can't compile the program with out it.

Thanks,
Bill
When all else fails, get a bigger hammer.

billhsln

January 28, 2010, 11:04:38 PM #2 Last Edit: January 28, 2010, 11:13:16 PM by billhsln
If I understand this right.  ColName should be defined as a Pointer.

So, you would have code like:

'col 1
CName0 = "Date"
cols[0].ColName=&CName0
cols[0].ColWidth=50
cols[0].fldSize=12
cols[0].Alignment=HDF_LEFT
cols[0].DataType=SD_CHAR
cols[0].ColForeClr=0
cols[0].ColBackClr=sysBackColor

CName1 = "Check"
cols[1].ColName=&CName1


etc....

I believe this because, if I understand C syntax correctly:

typedef struct _COL_INFO
{
  CHAR*  ColName;
  INT  ColWidth;
  INT  FldSize;
  INT  Alignment;
  INT  DataType;
  INT  Precision;
  BOOL  Nullable;
  COLORREF  ColForeClr;
  COLORREF  ColBackClr;
  BOOL  MultiLine;
  BOOL  ReadOnly;
  CHAR*  FontName;
  INT  PointSize;
  INT  Bold;
  INT  Italic;
  INT  Underline;
} COL_INFO;


CHAR* means that you have an address pointing to a string or Character array in C.

Also, assuming this is written in C, your declares would need:

DECLARE CDECL EXTERN CreateGrid(...),xxx

or something in that form.  At least from what I understand.

Still would like a copy of the inc file.

Hope this helps,
Bill
When all else fails, get a bigger hammer.

A-One


I tried SD DataGrid a long time ago.

I found the inc. at coding monkey.


type ColInfoint
def ColName as pointer
def colWidth as int
def fldSize as int
def Alignment as int
def DataType as int
def Precision as int
def Nullable as int
def ColForeClr as uint
def ColBackClr as uint
def MultiLine as int
def ReadOnly as int
def FontName as pointer
def PointSize as int
def Bold as int
def Italic as int
def Underline as int
endtype

type GridAttrint
def GridFont as uint
def HeaderFont as uint
def ShowLines as int
def GridBackClr as uint
def GridLineClr as uint
def SelForeClr as uint
def SelBackClr as uint
def CurCellOutlineClr as uint
def ShowRowNumbers as int
Endtype

Declare Import, CanUndeleteRow(hGrid as uint),int
Declare Import, CanUndoField(hGrid as uint),int
Declare Import, CanUndoRow(hGrid as uint),int
Declare Import, ClearCells(hGrid as uint),int
Declare Import, ClearColLabels(hGrid as uint),int
Declare Import, ClearGrid(hGrid as uint),int
Declare Import, CreateCell(hGrid as uint, row as int, col as int, txt as pointer), int
Declare Import, CreateGrid(hParent as int, hInstance as int,BorderStyle as int, IDGRID as int, _
left as int, top as int, width as int, height as int),uint
Declare Import, DefineField(hGrid as uint, Column as int, FieldControlType as int, _
colInfo as ColInfoInt),int
Declare Import, DimCols(hGrid as uint, colCount as int)
Declare Import, DimRows(hGrid as uint, rowCount as int),int
Declare Import, FreeGrid(hGrid as uint),int
Declare Import, GetCell(hGrid as uint, CellType as int, row as int, col as int, _
colInfo as ColInfoInt),int
Declare Import, GetColCount(hGrid as uint),int
Declare Import, GetColWidth(hGrid as uint, col as int),int
Declare Import, GetFldSize(hGrid as uint, col as int),int
Declare Import, GetRecordDelimited(hGrid as uint, recnumber as int, _
eolChars as pointer, delim as pointer, QuoteStrings as int),int
Declare Import, GetRecordRAF(hGrid as uint, row as int),int
Declare Import, GetRowCount(hGrid as uint),int
Declare Import, GetRowHeight(hGrid as uint),int
Declare Import, GotoCell(hGrid as uint, row as int, col as int),int
Declare Import, GridDataChanged(hGrid as uint),int
Declare Import, GridFind(hGrid as uint, SearchString as pointer, byField as int, _
findNxt as int, matchOption as int),int
Declare Import, GridGetFocus(hActiveGrid as int)
Declare Import, GridReadOnly(hGrid as uint, mode as int),int
Declare Import, InsertColLabel(hGrid as uint, colWidth as int,  pHdrTxt as pointer, _
idx as int, frmt as int),int
Declare Import, MakeFont(FontName as pointer, PintSize as int, Bold as int, _
Italic as int, Underline as int, StrikeThru as int, hFont as uint)
Declare Import, OnEntryStyle(EntryStyle as int),int
Declare Import, PutRecordDelimited(hGrid as uint, row as int, rec as pointer, _
eolChars as pointer, delim as pointer),int
Declare Import, PutRecordRAF(hGrid as uint, row as int, rec as pointer),int
Declare Import, RowModified(hGrid as uint, row as int),int
Declare Import, SetCellText(hGrid as uint, rw as int, col as int, txt as pointer)
Declare Import, SetGridAttr(hGrid as uint, gridAttr as struct),int
Declare Import, SetRowHeight(hGrid as uint, height as int), int
Declare Import, SetUndoBuffer(hGrid as uint),void
Declare Import, ShowLineNumbers(hGrid as uint, nShow as int),int
Declare Import, UndeleteRow(hGrid as uint),int
Declare Import, UndoField(hGrid as uint),int
Declare Import, UndoRow(hGrid as uint),int
Declare Import, CanDeleteRow(hGrid as uint),int
Declare Import, DeleteGridRow(hGrid as uint),int
Declare Import, GetFirstVisRow(hGrid as uint),int
Declare Import, GetFirstVisCol(hGrid as uint),int
Declare Import, GetCurrentRow(hGrid as uint),int
Declare Import, GetCurrentCol(hGrid as uint),int
Declare Import, ViewGrid(hGrid as uint, mode as int),int
Declare Import, LockField(hGrid as uint, colIdx as int, bReadOnly as int),int
Declare Import, FinishEditing(hGrid as uint),int
Declare Import, SetModify(hGrid as uint, bModified as int),int

/*
COLOR.BLACK = 1
ROW.DATA.CHANGED = 1
ROW.NEW.RECORD = 2
ROW.DATA.DELETED = 3
READONLY = 1
CELL.TEXT = 0
EDIT.TEXT = 1
NOSELECT = 0
SELECTALL = 1
FIELD.EDITBOX = 0
GRIDSTYLE.BORDERLESS = 0
GRIDSTYLE.BORDER = 1
GRIDSTYLE.SUNKEN = 2
MATCH.WHOLE = 0
MATCH.PART = 1
MATCH.STARTOF = 2
SD.CHAR = 1
HDF.LEFT = 0
HDF.RIGHT = 1
HDF.CENTER = 2
*/

ckoehn

Bill, I used the .inc file A-One has shown.  Will try your suggestion. Thanks

ckoehn

Bill,  I did include the constants a few other things it looks like.

ckoehn

There is a problem in the way that I am calling CreateGrid.  It isn't getting initialized.  What am I doing wrong?

I found out you also have to CreateCell, but that is after the grid is initialized.

billhsln

Still have not loaded this, but this statement looks wrong to me:

hGrid=CreateGrid(hdcw1, iGrid, GRIDSTYLE_SUNKEN , IDGRID, 30, 30, 640, 480)

1) hdcw1 is w1.hWnd.  hGrid=CreateGrid(w1.hWnd, iGrid, GRIDSTYLE_SUNKEN , IDGRID, 30, 30, 640, 480)
2) iGrid has no value, not sure where or how it should be defined, but it probably should be.
3) IDGRID must have a value > 0, you need this for Sub MAIN processing.

Like I said, I have not yet loaded this into EBasic, but that line needs some values defined or redefined.

Bill
When all else fails, get a bigger hammer.

ckoehn

Bill,

You are right.  I finally got it to load with the below code.

Thanks for your help.

$INCLUDE "windows.inc"
$INCLUDE "SdDataGrid.inc"

CONST File_Exit=1
CONST Proj_Bills=2
CONST Proj_Payroll=3
CONST Proj_Income=4
CONST Proj_Reports_941=5
CONST Proj_Reports_BalanceSheet=6
CONST IDGRID=7

DEF w1:WINDOW
DEF sysBackColor,hGrid:UINT
DEF SD_Drive,ColName0,ColName1,ColName2,ColName3,ColName4,ColName5,ColName6:String
DEF hDCw1,nRows,nCols:INT
DEF cols[7]:ColInfoInt

IF OPENWINDOW(w1,0,0,640,480,@MINBOX|@MAXBOX|@SIZE|@MAXIMIZED,0,"Grid Test",&main)=0
MESSAGEBOX Null,"Window failed to create","Grid Test"
END
ENDIF
BEGINMENU w1
MENUTITLE "File"
MENUITEM "E&xit",0,File_Exit
MENUTITLE "&Project"
MENUITEM "&Bills",0,Proj_Bills
MENUITEM "&Payroll",0,Proj_Payroll
SEPARATOR
MENUITEM "&Income",0,Proj_Income
SEPARATOR
BEGINPOPUP "&Reports..."
MENUITEM "&941",0,Proj_Reports_941
MENUITEM "&Balance Sheet",0,Proj_Reports_BalanceSheet
ENDPOPUP
ENDMENU

sysBackColor=_GetSysColor(15)

SETFONT w1,"Times New Roman",11,2

hGrid=CreateGrid(w1.hwnd, 1, GRIDSTYLE_SUNKEN , IDGRID, 30, 30, 640, 480)

IF hGrid>0
DimCols(hGrid,7)
'col 1
cols[0].ColName="Date":cols[0].ColWidth=75:cols[0].fldSize=12:cols[0].Alignment=HDF_LEFT:cols[0].DataType=SD_CHAR:cols[0].ColForeClr=0:cols[0].ColBackClr=sysBackColor
cols[1].ColName="Check":cols[1].ColWidth=75:cols[1].fldSize=12:cols[1].Alignment=HDF_LEFT:cols[1].DataType=SD_CHAR:cols[1].ColForeClr=0:cols[1].ColBackClr=sysBackColor
cols[2].ColName="Description":cols[2].ColWidth=200:cols[2].fldSize=50:cols[2].Alignment=HDF_LEFT:cols[2].DataType=SD_CHAR:cols[2].ColForeClr=0:cols[2].ColBackClr=sysBackColor
cols[3].ColName="Memo":cols[3].ColWidth=200:cols[3].fldSize=50:cols[3].Alignment=HDF_LEFT:cols[3].DataType=SD_CHAR:cols[3].ColForeClr=0:cols[3].ColBackClr=sysBackColor
cols[4].ColName="Debit":cols[4].ColWidth=75:cols[4].fldSize=12:cols[4].Alignment=HDF_LEFT:cols[4].DataType=SD_CHAR:cols[4].ColForeClr=0:cols[4].ColBackClr=sysBackColor
cols[5].ColName="Credit":cols[5].ColWidth=75:cols[5].fldSize=12:cols[5].Alignment=HDF_LEFT:cols[5].DataType=SD_CHAR:cols[5].ColForeClr=0:cols[5].ColBackClr=sysBackColor
cols[6].ColName="Total":cols[6].ColWidth=90:cols[6].fldSize=12:cols[6].Alignment=HDF_LEFT:cols[6].DataType=SD_CHAR:cols[6].ColForeClr=0:cols[6].ColBackClr=sysBackColor

DefineField(hGrid,1,FIELD_EDITBOX,cols[0])
DefineField(hGrid,2,FIELD_EDITBOX,cols[1])
DefineField(hGrid,3,FIELD_EDITBOX,cols[2])
DefineField(hGrid,4,FIELD_EDITBOX,cols[3])
DefineField(hGrid,5,FIELD_EDITBOX,cols[4])
DefineField(hGrid,6,FIELD_EDITBOX,cols[5])
DefineField(hGrid,7,FIELD_EDITBOX,cols[6])

FOR nRows=1 TO 20
FOR nCols=1 TO 7
CreateCell(hGrid,nRows,nCols,"")
NEXT nCols
NEXT nRows
SetUndoBuffer(hGrid)
ELSE
MESSAGEBOX null,"Grid failed to initialize","Grid Test"
ENDIF
run=1
WAITUNTIL run=0

FinishEditing(hGrid)
FreeGrid(hGrid)

CLOSEWINDOW w1
END

SUB main
SELECT @MESSAGE
CASE @IDCREATE
CENTERWINDOW w1
CASE @IDCLOSEWINDOW
run=0
CASE @IDSIZE
CASE @IDMENUPICK
SELECT @MENUNUM
CASE File_Exit
run=0
CASE Proj_Bills

CASE Proj_Payroll

CASE Proj_Income

CASE Proj_Reports_941

CASE Proj_Reports_BalanceSheet
ENDSELECT
ENDSELECT
ENDSUB

billhsln

March 02, 2010, 09:26:39 PM #9 Last Edit: March 02, 2010, 09:28:23 PM by billhsln
I have finally had a few minutes to actually install Sd DataGrid, but it seems I do not have 'SdDataGrid.LIB'.  I have looked around for it in the files available from the web site that SdDataGrid comes from and have tried downloading the files again.  However, I still can not seem to find 'SdDataGrid.LIB' file.

Could some one put it here so I can down load it.

Also, where do I store the DLL files, so that EBasic can find them?

Thanks,
Bill
When all else fails, get a bigger hammer.

LarryMc

I believe you have to use the "Create Import Library" in the IDE "Tools" menu to create the .lib file from the .dll file since the lib file wasn't supplied.

The dll file will need to be in the dir the application is in or or in your c:\windows\system32 folder.

And since the lib will not be a static lib you will have to distribute the dll with any application you distribute that was built using the lib that was created from the dll.

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

billhsln

Thanks, Larry.  Now I can finally compile it and it seems to work.  Will be playing with it to see if it will work for one of the projects I have.

Thanks again,
Bill
When all else fails, get a bigger hammer.