Hi Mindaugus

Mindaugas Kavaliauskas wrote:
> 
> I've tried to add ActiveX to my plain WinAPI Hello world sample. I 
> needed to add *TWO* lines (marked by /* !!!*/) below and #pragma 
> begindump/enddump. THAT'S ALL! I understand that event handler is 
> missing and OleAutomation object should be created, but this is not so 
> much code. I have a feeling, that if I'll do some ActiveX support, I'll 
> do that starting from zero, instead of trying to analyse all current 
> code. WARNING: The bad side will be that my code could be not compatible 
> to existing one, the good one is that it will be simple and clear.
> 
> ===============================================
> #include "c:\cawi32\include\windows.ch"
> 
> REQUEST HB_GT_NUL_DEFAULT
> 
> FUNC main()
> LOCAL nAddr, hWnd, cMsg
> 
>    AtlAxInit() /* !!! */
> 
>    nAddr := MakeWndProc({|X,Y,Z,T| WndProc(X,Y,Z,T)})
>    RegisterClass("MainWndCls",, COLOR_WINDOW + 1, LoadCursor(EMPTYPTR(), 
> IDC_ARROW), LoadIcon(EMPTYPTR(), IDI_APPLICATION),,,, nAddr)
>    hWnd := CreateWindow("MainWndCls", "CAWI32 Sample Hello", 
> WS_OVERLAPPEDWINDOW, 100, 100, 600, 500)
>    ShowWindow(hWnd, SW_SHOWNORMAL)
>    UpdateWindow(hWnd)
>    DO WHILE GetMessage(@cMsg)
>      TranslateMessage(cMsg)
>      DispatchMessage(cMsg)
>    ENDDO
> RETURN 0
> 
> FUNC WndProc(hWnd, nMsg, wParam, lParam)
> LOCAL hDC, sPS, hMenu, hSubMenu
> 
>    IF nMsg == WM_CREATE
> 
>      CreateWindow("ATLAXWin", "http://www.harbour-project.org";, WS_CHILD 
> + WS_VISIBLE + WS_BORDER + WS_HSCROLL + WS_VSCROLL, 10, 10, 500, 400, 
> hWnd) /* !!! */
> 
>    ELSEIF nMsg == WM_PAINT
>      hDC := BeginPaint(hWnd, @sPS)
>      EndPaint(hWnd, @sPS)
>    ELSEIF nMsg == WM_DESTROY
>      PostQuitMessage()
>      RETURN 0
>    ENDIF
> RETURN DefWindowProc(hWnd, nMsg, wParam, lParam)
> 
> PROC RDDSYS();  RETURN
> 
> PROC HB_GTSYS();  RETURN
> 
> #pragma begindump
> #include "hbapi.h"
> #include <windows.h>
> static HMODULE hLib = NULL;
> 
> HB_FUNC( ATLAXINIT )
> {
>     BOOL ( CALLBACK *pAtlAxWinInit )( void );
> 
>     hLib = LoadLibrary( "atl.dll" );
>     if( ( unsigned long ) hLib > 32 )
>     {
>        pAtlAxWinInit = GetProcAddress( hLib, "AtlAxWinInit" );
>        if( pAtlAxWinInit )
>           ( *pAtlAxWinInit )();
>     }
>     // I leave hLib not freed to avoid unloading of library
> }
> #pragma enddump
> ===============================================
> 

Almost thi smuch I am using in one of my old xHarbour project where
I needed only to display something. But I wanted more with evenets 
and all that. Only control does not mean anything. So this big code.
But at the heart of it it is almost the same you explained above.



> You'll not be able to compile it, but all function are straight wrappers 
> of WinAPI (MakeWndProc() is an exception, it registers codeblock and 
> returns window procedure address). So, I hope you'll be able to create 
> ActiveX control in your environment, if you have idea how to create a 
> window in it and access hWnd.
> 

It will be good to have this lighter code as well. 
So please do so. Though current one already is working, see other post.

Thanks for this clean implementation.

NOTE: FWH has to adopt new implementation into its core code.

Regards
Pritpal Bedi

-- 
View this message in context: 
http://www.nabble.com/Errors-with-11032-tp23521549p23605843.html
Sent from the Harbour - Dev mailing list archive at Nabble.com.

_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to