Language C ( To Antonio )

Re: Language C ( To Antonio )

Postby lailton.webmaster » Mon Jul 27, 2009 1:52 am

Daniel, aqui estas uno exemplo


Code: Select all  Expand view
/*-----------------------------------------------------------------------------------------------*/
#include "fivewin.ch"
/*-----------------------------------------------------------------------------------------------*/
function main()
 
 public ownd, oact, progid:="Agent.Control.2"
 define window ownd color 0,0
 
        oAct:=MyClass():New(ownd,progid,100,100,100,100)

//     erros con los testes
//       ownd:oClient:=oAct
//      ownd:oClient:=oAct:hWnd

 activate window ownd

return nil
/*-----------------------------------------------------------------------------------------------*/
CLASS myCLASS From TControl
DATA hWnd
      method new() Constructor
ENDCLASS
/*-----------------------------------------------------------------------------------------------*/
method new(win,prog,nTop,nLeft,nBottom,nRight) CLASS myClass
       ::hWnd:=CRWIN(win:hWnd,prog,nTop,nLeft,nBottom,nRight)
return self
/*-----------------------------------------------------------------------------------------------*/
#pragma BEGINDUMP
#include <hbvmopt.h>
#include <windows.h>
#include <commctrl.h>
#include <hbapi.h>
#include <hbvm.h>
#include <hbstack.h>
#include <ocidl.h>
#include <hbapiitm.h>
#ifdef HB_ITEM_NIL
   #define hb_dynsymSymbol( pDynSym )        ( ( pDynSym )->pSymbol )
#endif
PHB_SYMB s___GetMessage = NULL;
typedef HRESULT ( WINAPI *LPAtlAxWinInit )       ( void );
typedef HRESULT ( WINAPI *LPAtlAxGetControl )    ( HWND, IUnknown** );
typedef HRESULT ( WINAPI *LPAtlAxCreateControl ) ( LPCOLESTR, HWND, IStream*, IUnknown** );
HMODULE hDll = NULL;
LPAtlAxWinInit       AtlAxWinInit;
LPAtlAxGetControl    AtlAxGetControl;
LPAtlAxCreateControl AtlAxCreateControl;
static void LoadAtl( void )
{
   if( ! hDll )
   {
      hDll = LoadLibrary( "Atl.dll" );
      AtlAxWinInit       = ( LPAtlAxWinInit )       GetProcAddress( hDll, "AtlAxWinInit" );
      AtlAxGetControl    = ( LPAtlAxGetControl )    GetProcAddress( hDll, "AtlAxGetControl" );
      AtlAxCreateControl = ( LPAtlAxCreateControl ) GetProcAddress( hDll, "AtlAxCreateControl" );
      AtlAxWinInit();
   }
}/*-----------------------------------------------------------------------------------------------*/
HB_FUNC( CRWIN)
{
   HWND hWndCtrl;
   LoadAtl();
       hWndCtrl = CreateWindowEx(
      (DWORD) 0                             , // nExStyle
      (LPCTSTR) "AtlAxWin"                  , // cClsName
      (LPCTSTR) hb_parc( 2 )                , // cProgId
      (DWORD)   WS_CHILD | WS_VISIBLE | WS_TABSTOP      , // style
      (INT)     hb_parni( 3 )               , // nLeft
      (INT)     hb_parni( 4 )               , // nTop
      (INT)     hb_parni( 5 )               , // nWidth
      (INT)     hb_parni( 6 )               , // nHeight
      (HWND)    hb_parnl( 1 )               , // OParent:handle
       0,
       0,
       NULL );
   hb_retnl( (long) hWndCtrl );
}
/*-----------------------------------------------------------------------------------------------*/
#pragma ENDDUMP
/*-----------------------------------------------------------------------------------------------*/
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: Language C ( To Antonio )

Postby Daniel Garcia-Gil » Mon Jul 27, 2009 8:44 am

Lailton...

From this post viewtopic.php?p=76632#p76632

Code: Select all  Expand view

/*-----------------------------------------------------------------------------------------------*/
#include "fivewin.ch"
#include "Constant.ch"

/*-----------------------------------------------------------------------------------------------*/
function main()
 
 local oWnd, oAct, cProgid:="Agent.Control.2"
 define window oWnd color 0,0
 
        oAct := MyClass():New( oWnd, cProgid, 100, 100, 100, 100 )

//     erros con los testes
       ownd:oClient:=oAct
//      ownd:oClient:=oAct:hWnd

 activate window oWnd

return nil

/*-----------------------------------------------------------------------------------------------*/

#define COLOR_BTNFACE      15

CLASS myCLASS From TControl

   DATA hWnd
   
   method New() Constructor
   
   
ENDCLASS
 
/*-----------------------------------------------------------------------------------------------*/      
       
METHOD New( oWnd, cProgId, nTop, nLeft, nBottom, nRight, nClrFore, nClrBack, lPixel,;
            lDesign, cMsg, lVertical ) CLASS myCLASS

   DEFAULT nTop     := 0, nLeft := 0,;
           oWnd     := GetWndDefault(),;
           nClrFore := oWnd:nClrText,;
           nClrBack := GetSysColor( COLOR_BTNFACE ),;
           lPixel   := .f.,;
           lDesign  := .f.,;
           nRight   := 200, nBottom := 21,;
           lVertical := .f.

   ::nId       = ::GetNewId()
   ::oWnd      = oWnd
   ::cMsg      = cMsg
   ::nTop      = If( lPixel, nTop, nTop * SAY_CHARPIX_H )
   ::nLeft     = If( lPixel, nLeft, nLeft * SAY_CHARPIX_W )
   ::nBottom   = nBottom
   ::nRight    = nRight
   ::lDrag     = lDesign
   ::lCaptured = .f.
   ::nClrText  = nClrFore
   ::nClrPane  = nClrBack

   ::Register()

   if ! Empty( oWnd:hWnd )
      ::hWnd:=CRWIN( oWnd:hWnd, cProgId, nTop, nLeft, nBottom, nRight )
//      ::Create()
      ::Default()
      oWnd:AddControl( Self )
   else
      oWnd:DefControl( Self )
   endif

   if lDesign
      ::CheckDots()
   endif

return Self      
       
       
return self
/*-----------------------------------------------------------------------------------------------*/
#pragma BEGINDUMP
//#include <hbvmopt.h>
#include <windows.h>
#include <commctrl.h>
#include <hbapi.h>
#include <hbvm.h>
//#include <hbstack.h>
#include <ocidl.h>
//#include <hbapiitm.h>
#ifdef HB_ITEM_NIL
   #define hb_dynsymSymbol( pDynSym )        ( ( pDynSym )->pSymbol )
#endif

PHB_SYMB s___GetMessage = NULL;
typedef HRESULT ( WINAPI *LPAtlAxWinInit )       ( void );
typedef HRESULT ( WINAPI *LPAtlAxGetControl )    ( HWND, IUnknown** );
typedef HRESULT ( WINAPI *LPAtlAxCreateControl ) ( LPCOLESTR, HWND, IStream*, IUnknown** );
HMODULE hDll = NULL;
LPAtlAxWinInit       AtlAxWinInit;
LPAtlAxGetControl    AtlAxGetControl;
LPAtlAxCreateControl AtlAxCreateControl;

static void LoadAtl( void )
{
   if( ! hDll )
   {
      hDll = LoadLibrary( "Atl.dll" );
      AtlAxWinInit       = ( LPAtlAxWinInit )       GetProcAddress( hDll, "AtlAxWinInit" );
      AtlAxGetControl    = ( LPAtlAxGetControl )    GetProcAddress( hDll, "AtlAxGetControl" );
      AtlAxCreateControl = ( LPAtlAxCreateControl ) GetProcAddress( hDll, "AtlAxCreateControl" );
      AtlAxWinInit();
   }
}

/*-----------------------------------------------------------------------------------------------*/

HB_FUNC( CRWIN)
{
   HWND hWndCtrl;
   LoadAtl();
       hWndCtrl = CreateWindowEx(
      (DWORD) 0                             , // nExStyle
      (LPCTSTR) "AtlAxWin"                  , // cClsName
      (LPCTSTR) hb_parc( 2 )                , // cProgId
      (DWORD)   WS_CHILD | WS_VISIBLE | WS_TABSTOP      , // style
      (INT)     hb_parni( 3 )               , // nLeft
      (INT)     hb_parni( 4 )               , // nTop
      (INT)     hb_parni( 5 )               , // nWidth
      (INT)     hb_parni( 6 )               , // nHeight
      (HWND)    hb_parnl( 1 )               , // OParent:handle
       0,
       0,
       NULL );
   hb_retnl( (long) hWndCtrl );
}
/*-----------------------------------------------------------------------------------------------*/

#pragma ENDDUMP
/*-----------------------------------------------------------------------------------------------*/
 
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Language C ( To Antonio )

Postby lailton.webmaster » Mon Jul 27, 2009 9:36 am

THanks so much ! :D
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 85 guests