Activex y otras observaciones

120 views
Skip to first unread message

theos....@gmail.com

unread,
Jan 16, 2026, 1:16:45 AMJan 16
to Harbour Users
Por curiosidd, ya que a fin de año e inicio, aprecen brujitos (a) de todo tipo, se me ocurrio hacer un pequeño simple juego del tarot, pero usando lo mas basico de Harbour modo consola a lo mas usando gtwvt y hbwin. Entonces a empezar a buscar recursos, primero el mouse para ver las funcionalidades que brinda, fui a los ejemplos de Harbour, dir tests y el ejemplo MOUSE.PRG no funciona, tal vez sea WINDOWS 11 64bit y Harbour 32 bit ya que el default de la consola ahora es el Windows Teminal. Pero viendo otros ejemplo como wvtext.prg se ve que si funciona. Todo bien con los BOXs que simula una carta, y si doy un click y aparezca una imagen, un BMP. A buscar por las librerias, ni una funcion simple, en HBWIN donde era mas probable de encontrar algo como wapi_ShowImage(), en GTWVT segun include describe HB_GTI_DISPIMAGE, nicaragua. Copiloto, ayudame, chato puede ser con Activex, ya que no quieres usar C, como seria. Con el internet explorer "Shell.Explorer", en vez de darle un un url le das la ruta de una imagen. Fui al ejemplo de Harbour para ver si ya funciona pues hace tiempo vi que tenia errores. Ahora en Windows 11 parece que ya no existe ese control de "MSCAL.Calendar" por lo que da error y ademas esconde otro como: "Error BASE/1005  No existe la variable de instancia: _msgDestructor." Si el control existe y funciona bien a la ahora de cerrar objecto  HB_SYMBOL_UNUSED( oCtrl ) . Por momentos parecia que podia hacerlo en forma "limpia".  Tendre que usar un codigo simple C que vi en un ejemplo que solo muestra BMP y con la ayuda Copiloto que realize el trabajo sucio para otras funcionalidades.  Les muestro el ejemplo con otro control MSComCtl2.MonthView.2 no se si lo tendran en su maquina, pero el "Shell.Explorer" debe cajon debe existir. El problema es rastear el identificar del los Eventos de un control cundo el primer parametro deberia identificar como una cadena del nombre del evento aqui es un codigo.  
#require "hbwin"
#include "inkey.ch"
#include "hbgtinfo.ch"
#include "hbclass.ch"

#include "Fileio.ch"

#if ! defined( __HBSCRIPT__HBSHELL )
   REQUEST HB_GT_WVT_DEFAULT
   REQUEST HB_GT_WIN
#endif


PROCEDURE Main()

   LOCAL oCtrl

   #if defined( __HBSCRIPT__HBSHELL )
      hbshell_gtSelect( "GTWVT" )
   #endif
   cls

   IF (nHandle := FCREATE("errores.log", FC_NORMAL)) == -1
      ? "File cannot be created:", FERROR()
      Return
   ENDIF

   oCtrl := HActiveX():Init( wapi_GetActiveWindow(), "MSComCtl2.MonthView.2", 0, 0, 300, 200 )
   oCtrl:MonthColumns := 1
   oCtrl:MonthRows := 1
   oCtrl:Value := ctod("2026/02/01")

   INKEY(0)

   HB_SYMBOL_UNUSED( oCtrl )

RETURN

CREATE CLASS HActiveX

   VAR oOLE
   VAR hWnd
   METHOD Init( hWnd, cProgId, nTop, nLeft, nWidth, nHeight, cID )
   METHOD Event( ... )
   ERROR HANDLER OnError()
   DESTRUCTOR Close()

ENDCLASS

METHOD Init( hWnd, cProgId, nTop, nLeft, nWidth, nHeight, cID ) CLASS HActiveX

   LOCAL nStyle := WIN_WS_CHILD + WIN_WS_VISIBLE + WIN_WS_CLIPCHILDREN

   win_axInit()
   ::hWnd := wapi_CreateWindowEx( 0, "AtlAxWin", cProgId, nStyle, nLeft, nTop, nWidth, nHeight, hWnd, 0 )
   ::oOLE := win_axGetControl( ::hWnd, {| event, ... | ::Event( event, ... ) }, cID )

   RETURN Self

PROCEDURE Event( ... ) CLASS HActiveX
   LOCAL aParams := { ... }
   LOCAL cEvent := ""

   // El primer parámetro suele ser el nombre del evento
   IF Len(aParams) >= 1 .AND. ValType(aParams[1]) == "N"    // "C"
      cEvent := aParams[1]
   ENDIF

   DO CASE
   CASE cEvent == 4    // "DateClick"
      Alert("DateClick - " + Valtype(aParams[2])  )

   //CASE cEvent == 3  //"DateDblClick"
   //   Alert("DateDblClick - " + Valtype(aParams[2]) )
   //CASE cEvent ==    // "GetDayBold"
   //   Alert("GetDayBold")
   CASE cEvent == 1    // "SelChange"
   //   Alert("SelChange")
   OTHERWISE
   //  ? "Evento desconocido:", cEvent , "Params:", aParams
   ENDCASE

   RETURN

METHOD OnError() CLASS HActiveX
   RETURN hb_ExecFromArray( ::oOLE, __GetMessage(), hb_AParams() )

METHOD Close() CLASS HActiveX

   wapi_DestroyWindow( ::hWnd )
   ::hWnd := NIL
   ::oOLE := NIL

   RETURN NIL
  

miro....@gmail.com

unread,
Jan 16, 2026, 7:24:44 PMJan 16
to Harbour Users


This user is a developer working with 
Harbour (a modern, open-source evolution of the Clipper programming language) who is trying to create a Tarot Card game.

He is currently stuck on the technical implementation of the user interface—specifically, how to detect mouse clicks on "cards" and how to display images (the Tarot cards) within a console-style window on Windows 11.

Here is a breakdown of his specific problems and what he is trying to achieve:

1. The Core Objective
  • The Game: A simple Tarot game where the screen shows boxes (simulating cards). When a user clicks a box, it should "flip" and reveal an image (a BMP or other format).

  • The Tech Stack: He wants to use GTWVT (a Harbour graphics driver that makes a console window act like a Windows GUI window) and HBWIN (a library for Windows API integration).

2. The Problems He Is Facing
  • Broken Mouse Support: He found that the standard Harbour mouse examples (MOUSE.PRG) don't work. He suspects this is because Windows 11 now uses the "Windows Terminal" as the default console, which handles mouse input differently than the old cmd.exe.

  • Difficulty Displaying Images: He is looking for a simple command like ShowImage(x, y, file), but Harbour doesn't have a "one-liner" for this in the standard libraries. He found HB_GTI_DISPIMAGE but finds it complex or poorly documented for his needs.

  • ActiveX / OLE Issues:

    • He tried using ActiveX (embedding an external component like a web browser) to display the images.

    • He specifically tried using Shell.Explorer (the Internet Explorer engine) to load local image files.

    • The Error: He is hitting a specific Harbour crash: Error BASE/1005 Instance variable: _msgDestructor does not exist. This usually happens when Harbour tries to clean up an OLE object (like a window or a button) that has already been destroyed or was not initialized correctly.

    • Missing Components: He noticed that older Windows controls (like MSCAL.Calendar) are missing in Windows 11, making old examples unusable.

3. What He Needs From You (The "Help")

He is asking for a "cleaner" way to:

  1. Display an image inside the Harbour console window without writing complex C code.

  2. Handle ActiveX events: He is struggling with how to tell the program, "The user clicked this specific part of the ActiveX control."

  3. Fix the Destructor Error: He wants to know why his code crashes when closing the application or the control.

Summary in Plain English

The user is trying to build a "retro-style" app on a "modern" OS. He’s frustrated because the bridge between the old console world (Harbour/Clipper) and the new Windows 11 environment is full of bugs, missing libraries, and deprecated features. He is looking for a reliable way to show a picture and click a button using Harbour's OLE/ActiveX capabilities.

Reply all
Reply to author
Forward
0 new messages