egrid 4 - dll version.

Developed or developing a new product in PureBasic? Tell the world about it.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

egrid 4 - dll version.

Post by srod »

Hi,

I think a separate thread is warranted for this since there are significant differences between the new dll version of the egrid library and the original static PB library found in the following thread: http://www.purebasic.fr/english/viewtop ... 433#162433

Both static and dynamic versions are essentially functionally equivalent, so no worries there. Any purchase of the original PB static library version automatically entitles you to the dll version.

I've obviously created the dll in order to be able to offer developers in other languages a cheap and what I regard as a quite flexible grid control. However, if it's useful for PB developers then, well here it is! :)

First thing I would say is that the dll version differs in the way it handles some string fields which have been forced on me for various reasons. It means that the dll version handles an egrid in a manner which is not quite so natural for a PB programmer, but fits more into the windows way of doing things (handles + string buffers etc.) My advice for the PB programmer is thus to stick with the static library versions.

(I'll outline in the next post the main differences between the static lib and the dynamic one).

The install for the Purebasic dynamic library version of egrid comes with 2 versions of the dll; Ansi and Unicode, import libraries, a .pbi include file with the imports and all required constants etc and a whole bunch of examples. There's also a help manual etc.

You can download the various versions of the library from the egrid site:

http://www.purecoder.net/egrid.htm

Next post, - the main differences between the two versions.
Last edited by srod on Sat Mar 31, 2007 12:23 am, edited 1 time in total.
I may look like a mule, but I'm not a complete ass.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

The main differences between the static and dynamic versions of the egrid lib.

The first difference of note is that, as with any gadget created within a dll, the #gadget identifier used will not be recognised by the host Purebasic program's gadget and event commands. Thus, for example, the following command

Code: Select all

egrid_CreateGrid(1, 0, 0, 400, 400, ... etc.)
used in your main program, will create an egrid with a control identifier equal to 1, but this value will not be recognised in your PB event loop etc. (This is true for any gadget created in a dll in such a way). However this isn't really a problem for egrid, because just about every event of note can be trapped within your CellCallback function anyhow.

The egrid_CreateGrid() command will now return the Windows handle of the new grid (not the #gadget) and so you cannot use #Pb_Any with this command in the dll version. Also, this command now requires the handle of the parent window as one of it's parameters (see help manual).

The command egrid_GetCellText() now returns the number of characters (not bytes) in the text of the cell specified (as opposed to the text itself). This can be used to then allocate a buffer of the required length to receive the text. Calling this function with a non-zero pointer to a buffer as one of its parameters will then place the retrieved text in the said buffer etc.

The other major alteration (forced on me by repeated crashes!) is that the egridCellInfo structure used in CellCallback functions no longer has a 'text' field. Instead it has a 'ptrText' field which is a pointer to a string buffer. In the case that the library needs to pass a string to your callback (e.g. through the #egrid_InsertChar message), then it will pass a pointer to a buffer which you can access with:

Code: Select all

PeekS(*Cellinfo\ptrText)
etc. In the case where you need to return a string through this structure (e.g. with #egrid_NotifyCellType) then you must place the address of a string buffer containing the text within this field. Now it is important here that this string buffer remains intact on exit from the CellCallBack procedure and so it cannot point to a local variable. Either point to a global string variable or a static one or even a constant string literal.

That's about it folks. There are 7 examples in the package and they show how to work with these changes.

One more post to follow...
Last edited by srod on Sat Mar 31, 2007 12:39 am, edited 1 time in total.
I may look like a mule, but I'm not a complete ass.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Final post!

As already mentioned, I now wish to create the necessary 'wrappers' for various other programming languages.

Aurora and Emergence Basic are in hand.

If there are any Powerbasic guru's reading this, who think they might be able to take my dll package and create a wrapper for Powerbasic, then I'd be very interested in offerring the said person a sizeable % of the income generated from sales of the resulting Powerbasic package etc.

ditto for any individual able to do likewise for any other appropriate language; Realbasic, Freebasic, Hotbasic,... anything! :) Of course there are some languages where no such wrapper is possible, namely those in which you cannot obtain the address of a function in order to set up a CellCallback etc. (e.g. BlitzBasic).

Please p.m. me if interested.

:)
I may look like a mule, but I'm not a complete ass.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

thanks, works fine :D

Tip: You should change the first lines of egrid.pbi to:

Code: Select all

;******************************************************************************************
;'egrid' editable grid control. By Stephen Rodriguez.
;******************************************************************************************

CompilerIf #PB_Compiler_Unicode
Import "egrid_unicode.lib" 
CompilerElse
Import "egrid_ansi.lib"
CompilerEndIf
greetings Thomas
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Great idea. Nice one. 8)
I may look like a mule, but I'm not a complete ass.
Post Reply