May 01, 2024, 03:08:18 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


CreateObject?

Started by J B Wood (Zumwalt), October 20, 2006, 03:10:59 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

JR

Works better now. Have to made a change to mine. I haven't done anything with Aurora since July and wasn't aware that support for enumerations has been added.

JR

BTW I'm assuming that optional parameters can only be omitted if all of them are at the end of the parameters list, so when using a declaration like the one below we have to pass all the parameters because the last one is not optional. With VB you can omit them using ",,", but if I'm not wrong you can't do the same with Aurora. Am I right?


declare virtual Execute(/*[out][opt]*/opt VARIANT* RecordsAffected, /*[in][opt]*/opt VARIANT* Parameters, /*[in][opt][hasdefault]*/opt long Options, _Recordset* ppRetval),HRESULT;


Ionic Wind Support Team

Yes the optional parameters in Aurora are much like the ones in C++.  Actually you can define a function that has optional paramters before the end of the parameter list, you just cant use them from Aurora. 

Ionic Wind Support Team

sapero

The opt keyword didn't mean you can push NULL as optional VARIANT, it must be a valid variant pointer, but the variant can be set to empty.
Same with optional BSTR - if default value is L"" you can not push null.
JosÃÆ'Ã,©, maybe you know how to get the default value from optional parameters? I do have iviewers source (small oleview), but cannot find where it is :)

JR

November 06, 2006, 02:09:07 PM #29 Last Edit: November 06, 2006, 02:11:34 PM by José Roca
Oh, yes. My browser shows the default value in the comments.

This is the (PowerBASIC) code I'm using:


   LOCAL pex AS PARAMDESCEX PTR              ' // Pointer to a PARAMDESCEX structure

   ...
   ...

   ' -------------------------------------------------------------------------------
   ' Default value
   ' -------------------------------------------------------------------------------
   strDefaultValue = ""
   IF (@ppParam[x].u.uparamdesc.wParamFlags AND %PARAMFLAG_FHASDEFAULT) = %PARAMFLAG_FHASDEFAULT THEN
      ' // Pointer to a PARAMDESCEX structure
      pex = @ppParam[x].u.uparamdesc.pparamdescex
      ' // Vartype
      vt = @pex.vardefaultvalue.vt
      IF vt = %VT_BSTR THEN
         ' // Get the content of the unicode string
         bstrLen = SysStringByteLen(BYVAL @pex.varDefaultValue.vd.bstrVal)
         IF bstrLen THEN
            strDefaultValue = $DQ & ACODE$(PEEK$(@pex.varDefaultValue.vd.bstrVal, bstrLen)) & $DQ
         ELSE
            strDefaultValue = $DQ & $DQ
         END IF
      ELSE
         ' // Get the integer value
         IF udt_LibDoc.syskind = %SYS_WIN16 THEN
            strDefaultValue = FORMAT$(@pex.varDefaultValue.vd.iVal)
         ELSE
            SELECT CASE vt
               CASE %VT_BOOL
                  strDefaultValue = FORMAT$(@pex.varDefaultValue.vd.boolVal)
               CASE %VT_I2, %VT_INT
                  strDefaultValue = FORMAT$(@pex.varDefaultValue.vd.iVal)
               CASE %VT_UI1, %VT_I1
                  strDefaultValue = FORMAT$(@pex.varDefaultValue.vd.bVal)
               CASE %VT_R4
                  strDefaultValue = FORMAT$(@pex.varDefaultValue.vd.fltVal)
               CASE %VT_R8
                  strDefaultValue = FORMAT$(@pex.varDefaultValue.vd.dblVal)
               CASE %VT_CY, %VT_I8, %VT_UI8
                  strDefaultValue = FORMAT$(@pex.varDefaultValue.vd.cyVal)
               CASE %VT_DATE
                  strDefaultValue = FORMAT$(@pex.varDefaultValue.vd.date)
               CASE ELSE
                 strDefaultValue = FORMAT$(@pex.varDefaultValue.vd.lVal)
            END SELECT
         END IF
      END IF
   END IF
   IF LEN(strDefaultValue) THEN TV_InsertItem(@pmd.hTreeView2, hChildNode, "Default value = " & strDefaultValue)
   ' -------------------------------------------------------------------------------


BTW be aware that sometimes an alias is returned as the parameter type. For example, for the ADO library, your browser declares ppRetval as PositionEnum_Param, but the name of the enumeration is PositionEnum. PositionEnum_Param is an alias for PositionEnum.


declare virtual get_AbsolutePosition(PositionEnum_Param* ppRetval),HRESULT;


You will have to retrieve the aliases and use defines.

JR

The .u. in

pex = @ppParam
  • .u.uparamdesc.pparamdescex

    and the .vd. in

    @pex.varDefaultValue.vd.bstrVal

    are unions

    PowerBASIC didn't had support for unnamed unions when I wrote this code.

    ACODE$ is a command that converts an unicode string to ansi.

sapero

Thanks JosÃÆ'Ã,©, i've tried in same way, but always got exceptions.
Today testing the PARAMDESCEX under MS compiler i've found a bug in structure packing:
//oaidl.h (SDK)
// somewhere #include "pack8"
typedef struct tagPARAMDESCEX
{
    ULONG cBytes;
    VARIANTARG varDefaultValue;
} PARAMDESCEX;

My definition was: struct PARAMDESCEX,8 but offset from cBytes to varDefaultValue was still 4 bytes instead 8.
So a hack cBytes[2] helped.
Structure packing works only for 1,2,4 but 8 not.

J B Wood (Zumwalt)

My machines still bomb on the viewer.
I'll see if my dll is outdated.

JR

Quote
My definition was: struct PARAMDESCEX,8 but offset from cBytes to varDefaultValue was still 4 bytes instead 8.
So a hack cBytes[2] helped.
Structure packing works only for 1,2,4 but 8 not.

I had the same problem. See my structure definition for PowerBASIC:


' ========================================================================================
' PARAMDESCEX Structure
' Contains information about the default value of the parameter.
' Note: cBytes returns 24 bytes as the size of the structure. I have had to add a dowrd
' as a filler to get it to work with PowerBasic.
' ========================================================================================

TYPE PARAMDESCEX
   cBytes AS DWORD                    ' size of this struct
   filler AS DWORD
   varDefaultValue AS VARIANTAPI      ' default value of this parameter
END TYPE


sapero

I've uploaded newer version with fixed invoke method. You can now pass a VARIANT as parameter, as ilustrated in CBrowser example.
Added examples:
- DHTMLEdit - very simple HTML editor
- Speech - click it! :)
- WebBrowser - uses older version of browser control
- WebBrowser2

Both browser examples are supporting popups, opening new windows as owned, not in IE

Earn

sapero,

This is great stuff.  I'll need to study it much to see how it all works.

The WebBrowser2 example, however, crashes with an access violation when I close the app.

Thanks Earn.

sapero

It crashes too if you open and close new window, then click any URL in the first window :-X

// update to previous post:
The method Advise has now one optional parameter - name of events interface. Usefull if the class has more eventsinls.
Method Attach - added optional IID* parameter - if your object implements more than one interface you can connect to other, instead default interface.

// debug/testing:
Added GetInvokeArguments(wstring wszmethod) - if you need parameter types, it is located in separate module and is not linked if not used.
Same with GetErrorDesc(m_hr) (separate module, but shared with GetInvokeArguments) - returns printable error description for failed invoke call.
This method describes only IDispatch::Invoke, all other error strings you can find in winerror.inc.

Steven Picard

I played around with this a little bit and I think this would be great as a standard part of Aurora. Any chance of that happening?  I guess that decision is really up to Sapero and Paul but it is something I would like to see happen.

Mike Stefanik

Native support for COM (servers and clients), along with things like having variants be an intrinsic type, would be wonderful features for Aurora. On the other hand, at this point I don't think anything significant should be done that would delay its release. In my opinion, Aurora is already well past a commercial 1.0 release, aside from the documentation which needs to be finished. The focus now should be on wrapping things up. And as every developer knows, the last 5% of a project is 95% of the work.
Mike Stefanik
www.catalyst.com
Catalyst Development Corporation

Steven Picard

I don't entirely disagree with you but since Sapero has already done much of the work I see no reason why not to include it as a standard part of Aurora.  It would be nice to be there from day one.  Just my opinion of course. :)

Mike Stefanik

The problem is a) it's more documentation, and b) it would be included in a half-baked state. What sapero has done is very useful, but it doesn't translate into comprehensive COM support for the language.
Mike Stefanik
www.catalyst.com
Catalyst Development Corporation

Steven Picard

Quote from: Mike Stefanik on November 13, 2006, 12:44:17 PM
The problem is a) it's more documentation

I thought that was Paul's most favorite thing to do. :D Just kidding.

sapero

I'm currently working on a tool where you can select a ocx control from the registry, select a coclass, interface and sink-methods, then after clicking magic button you get complete project with wrapped methods and ... window :)
For now it can create project (.awp file) and class source and include.
I hope tomorrow it will be uploaded as alpha 1.

Steven Picard

I'm very much looking forward to this!!  :D

J B Wood (Zumwalt)

Your not the only one....

sapero

November 20, 2006, 06:00:05 AM #45 Last Edit: November 21, 2006, 07:21:43 AM by sapero
Ok, here it is!
Lol, create application with only one click ;DÂÃ,  I'm sure you find bugs and get it crashed while browsing ocx controls with bugs.
One bug i have found in OO defrag control (and mailed the developer) - while unloading unused dlls (CoFreeUnusedLibraries) the application just closes (ExitProcess is called or stack overflow).

Standard project files and external libraries are extracted from resource (all packed in single cab file, api=SetupIterateCabinet)
In next release it will be changed to allow modifications in template source file.
Main dialog looks like property sheet but has only one page, the button 'Next' creates the project and runs the application if checked.
Second page will be added to initially set control properties or call methods...

The state of checkbox "define unknown variable types" is ignored, an extra include file with dumped enums/structs is created as needed.

CInvoker has been updated:
1. put() is now cdecl and accepts any number of parameters,
2. putref() added (cdecl)

To Paul: i've got many times error while assembling: undefined symbol __imp_lstrcpyW, while using the w2s() function.
This simple line helped:#emit extern __imp_lstrcpyW

J B Wood (Zumwalt)

wooohooo no other language can boast this!
YOU ROCK

ExMember001

yep awesome work!
thanks for sharing  ;D

now i just need to understand what is an ocx control and how to use that properly ...  ;)

Rock Ridge Farm (Larry)

How do I compile this - I get lots of errors.

Rock Ridge Farm (Larry)

This thing is really cool - 3 or 4 years I might understand it.