Theos PowerBasic Museum 2017

General Category => General Discussion => Topic started by: David Marco on November 04, 2008, 06:45:50 PM

Title: External function sendmessage to a callback function...
Post by: David Marco on November 04, 2008, 06:45:50 PM
Hi José,

I'm trying to do a special kind of dll using your TB_DHTMLED headers and samples, in order to create a NeoBook plugin.

At this moment, I can create the dialogs within a rectangle, and close them.

Now, I'm working to recreate the callback cases as external functions, for example, the "Open" button  as independient function...

Following this sample I created this function:

FUNCTION AE_HTML_Open (a AS ASCIIZ) EXPORT as LONG
 sendmessage hDlgMain ,%WM_COMMAND, %IDM_OPEN, %True
END FUNCTION

But nothing works.

Could you tell me what is wrong ?

Thanks in advance,
David de Argentina
Title: Re: External function sendmessage to a callback function...
Post by: Paul Squires on November 04, 2008, 07:48:39 PM
You are not sending the WM_COMMAND message correctly. Try this:


SendMessage hDlgmain, %WM_COMMAND, MakLng(%IDM_OPEN, 0), %Null


...or if you know the hWnd of the Open button (I assume that %IDM_OPEN is the control identifier for the open button).


hWndControl = GetDlgItem( hDlgMain, %IDM_OPEN)
SendMessage hDlgmain, %WM_COMMAND, MakLng(%IDM_OPEN, 0), hWndControl

Title: Re: External function sendmessage to a callback function...
Post by: Paul Squires on November 04, 2008, 07:52:21 PM
The previous post also assumes that "hDlgMain" is a global variable that holds the main dialog's window handle. It does, right?

Title: Re: External function sendmessage to a callback function...
Post by: José Roca on November 04, 2008, 08:23:26 PM
 
Also, to use COM in a DLL, the COM library must be initialized using CoInitialize BYVAL %NULL before doing any COM call (a good place could be before creating the dialog), and uninitialize it calling CoUninitialize when done, e.g. when closing the dialog.
Title: Re: External function sendmessage to a callback function...
Post by: David Marco on November 10, 2008, 09:59:06 PM
Thanks José and Paul, is working now..

By the way...

I'm trying to add the tables services, based on your TB_HTMLED11 sample.
I put this lines of code:

FUNCTION AE_HTML_AddTable (a AS ASCIIZ) EXPORT AS STRING
IDEInsertTableParam_SetNumRows pEdHtml, 3
IDEInsertTableParam_SetNumRows pEdHtml, 4
IDEInsertTableParam_SetTableAttrs pEdHtml, "width=100%"
IDEInsertTableParam_SetCellAttrs pEdHtml, "nowrap"
IDHTMLEdit_ExecCommand pEdHtml, %DECMD_INSERTTABLE, %OLECMDEXECOPT_DODEFAULT
UpdateWindow hEdHtml
...
END FUNCTION

But doesn't work...
Any ideas ?

Thanks in advance,
David de Argentina
Title: Re: External function sendmessage to a callback function...
Post by: José Roca on November 10, 2008, 11:14:58 PM
 
You need to create an instance of the InsertTableParam interface.


   LOCAL pInsertTableParam AS DWORD
   LOCAL vInsertTableParam AS VARIANT
   LOCAL pv AS VARIANTAPI PTR

   pInsertTableParam = DHTMLEditCreateObject("{47B0DFC7-B7A3-11D1-ADC5-006008A5848C}"))
   IF ISFALSE pInsertTableParam THEN EXIT FUNCTION
   pv = VARPTR(vInsertTableParam)
   @pv.vt = %VT_DISPATCH
   @pv.vd.pdispVal = pInsertTableParam
   DHTMLEditAddRef pInsertTableParam

   IDEInsertTableParam_SetNumRows pInsertTableParam, 4
   IDEInsertTableParam_SetNumCols pInsertTableParam, 3
   IDEInsertTableParam_SetTableAttrs pInsertTableParam, "width=100%"
   IDEInsertTableParam_SetCellAttrs pInsertTableParam, " bgcolor=" & $DQ & "blue" & $DQ & " noWrap"

   IDHTMLEdit_ExecCommand pEdHtml, %DECMD_INSERTTABLE, %OLECMDEXECOPT_DODEFAULT, vInsertTableParam

   vInsertTableParam = EMPTY
   DHTMLEditRelease pInsertTableParam