Add Mouse control on console Harbour app

220 views
Skip to first unread message

Martin Fears

unread,
Sep 21, 2026, 9:46:09 AMSep 21
to Harbour Users
How / where do I start (baby steps / hand-holding required please).
There must be someone (many) out there who has already been down this road?

I have a 30 year old Clipper 5 app and in the last two years I have migrated it to Harbour and incorporated pscript to manage all printed output - all working fine just now.

The next phase of my "overhaul" is to now convert the app to be mouse compatible.  Currently, lots of use of <Esc> and <Enter> along with many <F_> keys to launch specific actions.  I'm not a fully competent coder (more an enthusiastic DIY-er), so if someone can point me to some useful instructions on how to make a Harbour app mouse-compatible and/or highlighting key concepts, and with some simple example code I can follow and learn from, that should help me on my journey.

Last year I did look at going full GUI with GTWVT? but concluded all the screen rewriting would become an almost full application re-write, so backed down from that.

I'm currently using Harbour 3.2 - would the advice be to first upgrade to latest Harbour version (3.4?) before embarking on my mousification adventure?

As always, your wise words of wisdom are appreciated.

Martin
Message has been deleted

marcos...@gmail.com

unread,
Sep 21, 2026, 12:17:10 PMSep 21
to Harbour Users
Hi Martin,

Yes, Harbour in terminal supports the mouse. You keep your `@...SAY/GET`, `Inkey()` and F-keys, and *additionally* respond to clicks. Four concepts:

1. `SET EVENTMASK TO K_LBUTTONDOWN` — enables left-click events.
2. `nKey := Inkey(0)` — returns 1002 (`K_LBUTTONDOWN`) on a click.
3. `MRow()` / `MCol()` — click position.
4. You compare those coordinates against your screen regions and act.

It's not mandatory to upgrade from 3.2 to 3.4 just for the mouse, but 3.4 fixes things on modern Windows consoles and high-DPI. If your 3.2 is stable, test in a small separate project first; don't upgrade and add mouse at the same time.

Compile with: `hbmk2 test.prg -lgtwvt`

⚠️ Mandatory: link `gtwvt.lib` (Borland) or `libgtwvt.a` (MinGW). If you compile with Borland using a `.lnk`, add `gtwvt.lib` manually to the library list. Otherwise you'll get `Unresolved external '_HB_FUN_HB_GT_WVT_DEFAULT'`.

The optimal solution is to switch to MiniGui Extended.

Project site:

https://www.hmgextended.com/

You can send me any example you have so I can show you how to migrate from Clipper to MiniGui Extended.

Attached: terminal code with mouse support and a MiniGui Extended example.

Regards,

Marcos Jarrin
test.rar

paul.smi...@gmail.com

unread,
Sep 21, 2026, 10:09:10 PMSep 21
to Harbour Users
Hi Martin
Here's a sample of the code I used when upgrading an old summer 87 programme.
Cheers
Paul

*----- Save this code as test.prg
*----- Then compile with: hbmk2 test -gtwvt

PROCEDURE MAIN()
#include "inkey.ch"
SET( _SET_EVENTMASK, INKEY_ALL )
SET KEY 1003 TO mousey
SET KEY 1004 TO mousey
SET KEY 1009 TO mousey
SET KEY 1014 TO mousey
SET KEY 1015 TO mousey

DO WHILE .T.
   clear  
   @ 10,26 PROMPT "  Add     "
   @ 12,26 PROMPT "  Edit    "
   @ 14,26 PROMPT "  Delete  "
   MENU TO choice
   
   DO CASE
   CASE choice=0
      RETURN
   CASE choice=1
      tone(100,1)
   CASE choice=2
      tone(500,1)
   CASE choice=3
      tone(1000,1)
   ENDCASE
   
ENDDO


*!*********************************************************************
*!
*!       Function: MOUSEY()
*!
*!      Called by: MAIN()         (procedure in MAIN.PRG)
*!
*!*********************************************************************
FUNCTION mousey
DO CASE

*----- middle button = f10

CASE LASTKEY() =1009
   tone(2000,2)
   hb_keyput(-9)
   
*----- left click up = enter

CASE LASTKEY() =1003
   KEYBOARD CHR(13)
   
*----- right click down = escape

CASE LASTKEY() =1004
   KEYBOARD CHR(27)
   
*----- mouse wheel foward = up arrow

CASE LASTKEY() =1014
   KEYBOARD CHR(5)

*----- mouse wheel back = down arrow

CASE LASTKEY() =1015
   KEYBOARD CHR(24)
   
ENDCASE

Martin Fears

unread,
Sep 25, 2026, 11:53:00 AM (12 days ago) Sep 25
to Harbour Users
Thanks for replies so far.

Are there other benefits to going to MiniGUI beyond just mouse compatibility?
Might this involve quite a bit of re-write aka extra work?
If I'm going to code-in mouse co-ordinates to all my screens to trigger actions for mouse-clicks, would it be worthwhile to go MinGUI all-in?  Can someone send me a simple MiniGUI code/project so I can get a flavour of what this will look like.

I'm trying to weigh-up if a simple convert for Mouse is any much less work than going all in MiniGUI which may bring additional benefits - what are my Pros & Cons Vs effort?

For example, to be able to scroll a TBROWSE with a mouse wheel could be useful - do these options both support something like that?  Or am I getting way ahead of my (modest) expectations?

I'll look to go to Harbour 3.4 once my app is in a stable position - is there anything important I'm missing out on whilst I delay?

Many thanks

Martin

Reply all
Reply to author
Forward
0 new messages