Author Topic: COM 64  (Read 20367 times)

0 Members and 2 Guests are viewing this topic.

JRS

  • Guest
Re: COM 64
« Reply #45 on: August 14, 2018, 11:14:18 AM »
For me, VB6 on Windows 10 is experimental. I'm going to keep my VB IDE and VS2008 going on Win7 until Microsoft pulls the plug.

What I develop on Win7 runs and themes well on Win10.

JRS

  • Guest
Re: COM 64
« Reply #46 on: August 14, 2018, 06:32:02 PM »
Quote from: Charles
Aurel created an ATL-based browser example:

Works (running in the IDE) on Win7. I will have to give it a try on Win10.

@Charles - I'm unable to create a .exe of this program. (dependent or independent) Runs fine from the IDE.
« Last Edit: August 14, 2018, 07:45:08 PM by John »

Charles Pegge

  • Guest
Re: COM 64
« Reply #47 on: August 14, 2018, 11:33:35 PM »
Hi John,

I've tested successfully with RTL32 and RTL64.

Here is a cleaned up version

Code: [Select]
'gui-skeleton app
$ Filename "t.exe"
uses RTL32
'uses RTL64
uses awinh

#lookahead
INT win,win2
INT x,y,w,h,x2,y2,w2,h2
x=0:y=10:w=800:h=600
x2=410:y2=10:w2=400:h2=300
INT winstyle,wstyle2,wbstyle
winstyle = WS_MINMAXSIZE or WS_CLIPCHILDREN
wbstyle = WS_CHILD OR WS_VISIBLE OR WS_BORDER
INT btt0,btt1,btt2
INT b0ID = 100, b1ID=101, b2ID=102
INT bmpB0,bmpB1,bmpB2,bmpB3,bmpB4,bmpB5
bmpB0 = LoadImage(0,"btBack.bmp",0,28,28,16)
bmpB1 = LoadImage(0,"data/btOpen.bmp",0,30,30,16)
bmpB2 = LoadImage(0,"data/btSave.bmp",0,30,30,16)


% WM_FORWARDMSG = &H37F ' (895)

% IDB_BACK = 1001
% IDB_FWRD = 1002
% IDB_NAVG = 1003
% IDC_URL  = 1004
% IDC_WB   = 1005

extern lib "ATL.dll"
! AtlAxWinInit () as sys
! AtlAxGetControl  ( sys hWnd, **pp ) as int
end extern

int hWb

'create window
'
win = SetWindow("ATL:Browser",x,y,w,h,0,winstyle)

'create buttons
'
btt0 = SetButton(win,4,4,30,30,"<<",0x50000080,0x200,b0ID)
SendMessage btt0 , BM_SETIMAGE, 0, bmpB0
btt1 = SetButton(win,38,4,30,30,"<<",0x50000080,0x200,b1ID)
SendMessage btt1 , BM_SETIMAGE, 0, bmpB1
btt2 = SetButton(win,74,4,30,30,"<<",0x50000080,0x200,b2ID)
SendMessage btt2 , BM_SETIMAGE, 0, bmpB2


'Initializes ATL
AtlAxWinInit

'create browser window
hWb = CreateWindowEx(0, "AtlAxWin", "www.google.com",wbstyle , 4, 40, w-16,(h-56)-64, win, IDC_WB, 0, 0)
'
Wait()
'
function WndProc (sys hwnd,wmsg,wparam,lparam) as sys callback
==============================================================
select hwnd

case win

  select wmsg
  '
  case WM_CLOSE
    DestroyWindow win
    PostQuitMessage 0
  case WM_SIZE
    GetSize(win,0,0,w,h)
    MoveWindow(hWb,4,40,w-6,(h-56)-32 ,1)
  case WM_COMMAND
    controlID = LoWord(wParam) 'get control ID
    notifyCode = HiWord(wParam) 'get notification message
    '
    select controlID
    '
    case b0ID
      if notifycode=0         
        print "< GO BACK >"
      end if     
    case b1ID
      if notifycode=0         
        print "< GO FOR >"
      end if
    case b2ID
       If notifycode=0         
         print "TESTING....1...2....3"
       End If
    end select
  end select
end select

return default

end function

JRS

  • Guest
Re: COM 64
« Reply #48 on: August 16, 2018, 04:57:16 AM »
This version doesn't compile or run from the IDE any longer.  It does create a t.exe version that seems to run. I'm going to give it a try on Win10.

I'm using the latest build on Win7.

Update

It seems to run on Windows 10 Build 1803 but no button graphics.

« Last Edit: August 16, 2018, 05:09:57 AM by John »

Charles Pegge

  • Guest
Re: COM 64
« Reply #49 on: August 16, 2018, 05:59:33 AM »
Hi John,

It loads its button graphics from the data subfolder.

JRS

  • Guest
Re: COM 64
« Reply #50 on: August 16, 2018, 06:38:54 AM »
Quote
It loads its button graphics from the data subfolder.

Thanks!

I still feel that if O2 could generate OCX controls / forms, it would be a big plus and generate interest in the compiler.

« Last Edit: August 16, 2018, 06:56:26 AM by John »

Aurel

  • Guest
Re: COM 64
« Reply #51 on: August 17, 2018, 05:17:51 AM »
Hi Charles ,,John
I almost forget for this example .
I don't know from where is this few constant:

% IDB_BACK = 1001
% IDB_FWRD = 1002
% IDB_NAVG = 1003
% IDC_URL  = 1004
% IDC_WB   = 1005

and how to use them in this program .
Probably can be executed trough SendMessage ?

JRS

  • Guest
Re: COM 64
« Reply #52 on: August 17, 2018, 09:16:50 AM »
Thanks Aurel for creating this example. It shows COM is a viable option in O2.

José Roca

  • Guest
Re: COM 64
« Reply #53 on: August 17, 2018, 09:45:12 AM »
The only requirements for a language to work with COM is being able to create structures of pointers (for example, an array of pointers to the methods/procedures, know as virtual table) and, either explicitly or implicitly, call functions through pointers.

José Roca

  • Guest
Re: COM 64
« Reply #54 on: August 17, 2018, 09:53:45 AM »
Thanks Aurel for creating this example. It shows COM is a viable option in O2.

Sorry, but that example only shows how to use ATL.DLL to host the WebBrowser Control. The program itself doesn't use COM in any way.

Aurel

  • Guest
Re: COM 64
« Reply #55 on: August 17, 2018, 11:30:29 AM »
Yes Jose  have a right that just show how attach atl control in window
and don't have any other functions...
I found it some time ago on Jose forum.

But i found something interesting on code project
https://www.codeproject.com/Articles/3365/Embed-an-HTML-control-in-your-own-window-using-plain-C
it is web browser control written in pure C and WOW looks very complex.
There is a source code for webcontrol dll ...so probably require compiling with C compiler
because translate whole code to oxgen should be huge task ...ufff
anyone know with what compile this C code?

Aurel

  • Guest
Re: COM 64
« Reply #56 on: August 17, 2018, 11:38:49 AM »
Hmm crap..
It looks that this dll is full of bugs and strange problems
according to comments on code project.  >:(

Charles Pegge

  • Guest
Re: COM 64
« Reply #57 on: August 17, 2018, 12:06:30 PM »
o2 can use the header classes directly. You just need to know what you want. Here are the ones I used for Text to speech (in SAPI5), with a slight cleanup:

Code: [Select]
  extern virtual

  '-------------
  class IUnknown
  '=============

    HRESULT QueryInterface(refiid id, pvObject* ppv)
    ULONG   AddRef()
    ULONG   Release()

  end class

  'from sapi.h


  'MIDL_INTERFACE("5EFF4AEF-8487-11D2-961C-00C04F8EE628")
  'ISpNotifySource : public IUnknown
  '
  extern virtual
  '
  '--------------------
  class ISpNotifySource
  '====================

    public

    extends IUnknown

        HRESULT SetNotifySink(
            /* [in] */ __RPC__in_opt ISpNotifySink *pNotifySink)
       
        HRESULT SetNotifyWindowMessage(
            /* [in] */ HWND hWnd,
            /* [in] */ UINT Msg,
            /* [in] */ WPARAM wParam,
            /* [in] */ LPARAM lParam)
       
        HRESULT SetNotifyCallbackFunction(
            /* [in] */ SPNOTIFYCALLBACK *pfnCallback,
            /* [in] */ WPARAM wParam,
            /* [in] */ LPARAM lParam)
       
        HRESULT SetNotifyCallbackInterface(
            /* [in] */ ISpNotifyCallback *pSpCallback,
            /* [in] */ WPARAM wParam,
            /* [in] */ LPARAM lParam)
       
        HRESULT SetNotifyWin32Event( void)
       
        HRESULT WaitForNotifyEvent(
            /* [in] */ DWORD dwMilliseconds)
       
        HANDLE GetNotifyEventHandle( void)

  end class



  'MIDL_INTERFACE("BE7A9CCE-5F9E-11D2-960F-00C04F8EE628")
  'ISpEventSource : public ISpNotifySource
  '

  '-------------------
  class ISpEventSource
  '===================

    public

    extends ISpNotifySource

        HRESULT SetInterest(
            /* [in] */ ULONGLONG ullEventInterest,
            /* [in] */ ULONGLONG ullQueuedInterest)
       
        HRESULT GetEvents(
            /* [in] */ ULONG ulCount,
            /* [size_is][out] */ SPEVENT *pEventArray,
            /* [out] */ ULONG *pulFetched)
       
        HRESULT GetInfo(
            /* [out] */ SPEVENTSOURCEINFO *pInfo)
       
  end class



    'MIDL_INTERFACE("6C44DF74-72B9-4992-A1EC-EF996E0422D4")
    'ISpVoice : public ISpEventSource
    '

    '-------------
    class ISpVoice
    '=============
    '
    public

    extends ISpEventSource

        HRESULT SetOutput(
            /* [in] */ IUnknown *pUnkOutput,
            /* [in] */ BOOL fAllowFormatChanges)
       
        HRESULT GetOutputObjectToken(
            /* [out] */ ISpObjectToken **ppObjectToken)
       
        HRESULT GetOutputStream(
            /* [out] */ ISpStreamFormat **ppStream)
       
        HRESULT Pause( void)
       
        HRESULT Resume( void)
       
        HRESULT SetVoice(
            /* [in] */ ISpObjectToken *pToken)
       
        HRESULT GetVoice(
            /* [out] */ ISpObjectToken **ppToken)
       
        HRESULT Speak(
            /* [string][in] */
            __in_opt  LPCWSTR pwcs,
            /* [in] */ DWORD dwFlags,
            /* [out] */
            __out_opt  ULONG *pulStreamNumber)

        HRESULT SpeakStream(
            /* [in] */ IStream *pStream,
            /* [in] */ DWORD dwFlags,
            /* [out] */
            __out_opt  ULONG *pulStreamNumber)
       
        HRESULT GetStatus(
            /* [out] */ SPVOICESTATUS *pStatus,
            /* [out] */ LPWSTR *ppszLastBookmark)
       
        HRESULT Skip(
            /* [string][in] */ LPCWSTR pItemType,
            /* [in] */ long lNumItems,
            /* [out] */ ULONG *pulNumSkipped)
       
        HRESULT SetPriority(
            /* [in] */ SPVPRIORITY ePriority)
       
        HRESULT GetPriority(
            /* [out] */ SPVPRIORITY *pePriority)
       
        HRESULT SetAlertBoundary(
            /* [in] */ SPEVENTENUM eBoundary)
       
        HRESULT GetAlertBoundary(
            /* [out] */ SPEVENTENUM *peBoundary)
       
        HRESULT SetRate(
            /* [in] */ long RateAdjust)
       
        HRESULT GetRate(
            /* [out] */ long *pRateAdjust)
        HRESULT SetVolume(
            /* [in] */ USHORT usVolume)
       
        HRESULT GetVolume(
            /* [out] */ USHORT *pusVolume)
       
        HRESULT WaitUntilDone(
            /* [in] */ ULONG msTimeout)
       
        HRESULT SetSyncSpeakTimeout(
            /* [in] */ ULONG msTimeout)
       
        HRESULT GetSyncSpeakTimeout(
            /* [out] */ ULONG *pmsTimeout)
       
        /* [local] */ HANDLE SpeakCompleteEvent( void)
       
        /* [local] */ HRESULT IsUISupported(
            /* [in] */ LPCWSTR pszTypeOfUI,
            /* [in] */ void *pvExtraData,
            /* [in] */ ULONG cbExtraData,
            /* [out] */ BOOL *pfSupported)
       
        /* [local] */ HRESULT DisplayUI(
            /* [in] */ HWND hwndParent,
            /* [in] */ LPCWSTR pszTitle,
            /* [in] */ LPCWSTR pszTypeOfUI,
            /* [in] */ void *pvExtraData,
            /* [in] */ ULONG cbExtraData)
       
    end class

    end extern

The full code can be found in inc\com  and examples\com. We could produce something that looks a bit simpler - (C baggage!)
« Last Edit: August 17, 2018, 12:30:42 PM by Charles Pegge »

Aurel

  • Guest
Re: COM 64
« Reply #58 on: August 17, 2018, 12:38:08 PM »
well i am not sure that cwebcontrol looks like a very complex beast
 ???

JRS

  • Guest
Re: COM 64
« Reply #59 on: August 17, 2018, 01:58:27 PM »
Quote
o2 can use the header classes directly. You just need to know what you want.

That is what makes O2 one of the friendliest C BASIC compilers around. Even FreeBasic (basic to C translator) can't read C header files.

I agree with Charles, COM is just around the corner with O2. It would be great if José Roca would mentor in this effort.

@Charles - How is O2 going to handle variants?
« Last Edit: August 17, 2018, 08:14:50 PM by John »