Odd Behaviour

Moderator: Rathinagiri

BobFBurns
Posts: 16
Joined: Fri Apr 05, 2013 8:45 am
DBs Used: DBF, ACCDB
Location: 25Km South of London
Contact:

Re: Odd Behaviour

Post by BobFBurns »

Hi CalScot
Thank you and everyone else who has replied. I am converting an amateur radio logbook program from DOS to Windows. The original application of around 10,000 lines with "Lotus 123" like menus compiles in Harbour and runs under Windows but lacks a proper GUI and printing facilities. Having said that, when I use the program in a radio competition which also requires me to use the radio equipment and a morse key or microphone at the same time the GUI would be too time consuming and full control from the keyboard is much faster - if I can find or program the required controls. This is my current challenge!
I noticed that PageDown is missing from the On Key control list but is present in the Clipper 5.3 list.
Regards
Bob (UK callsign G3OOU, website www.g3oou.co.uk)
User avatar
CalScot
Posts: 303
Joined: Thu Mar 21, 2013 12:22 am
Location: California

Re: Odd Behaviour

Post by CalScot »

Bob,

Interesting!

Although there's no OnKey for PgDn, I believe that you could use PgDn to invoke an associated procedure, such as to SetFocus on the "Save" or "Next" button, or however you've defined it, the nett effect of which would be to allow you to emulate the DOS_based Clipper input screen.

You could similarly assign procedures to UpArrow and DnArrow to set focus on the prior or subsequent TabStop.

For more on this, see the HMG-Help at:
"CA-Clipper 5.3"
"Guide To CA-Clipper"
"Commands"
Then scroll down to
"SET KEY Assign a procedure invocation to a key"
which, when clicked, displays the page on:
"SET KEY <nInkeyCode> TO [<idProcedure>]"

PgDn is Chr(3) and the InKey() code is K_PGDN. Make sure to " #Include 'inkey.ch' " if you use "K_PGDN" (advised!) rather than the ASCII Value.

I haven't tested it, but see no reason why it wouldn't work. (Famous last words, right?)

Good luck!
CalScot
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Odd Behaviour

Post by esgici »

BobFBurns wrote: I noticed that PageDown is missing from the On Key control list ...

Code: Select all

#include <hmg.ch>

PROCEDURE Main()

   DEFINE WINDOW frmMain at 0, 0 WIDTH 400 HEIGHT 300 MAIN
      ON KEY ESCAPE ACTION ThisWindow.Release
      ON KEY PRIOR  ACTION MsgBox( "Page Up" )
      ON KEY NEXT   ACTION MsgBox( "Page Down" )
   END WINDOW // frmMain
   
   CENTER   WINDOW frmMain
   ACTIVATE WINDOW frmMain

RETURN // Main() 

*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.
Happy HMG'ing :D
Viva INTERNATIONAL HMG :D
BobFBurns
Posts: 16
Joined: Fri Apr 05, 2013 8:45 am
DBs Used: DBF, ACCDB
Location: 25Km South of London
Contact:

Re: Odd Behaviour

Post by BobFBurns »

Hi All
Thanks for the suggestions. The initial problem is resolved. As advised in the previous post I also discovered that PgDn is known as NEXT and PgUp as PREVIOUS. The following code is one way to emulate the navigation process in Clipper. No doubt there are more elegant ways to code it but this does work.
Regards
Bob

#include "hmg.ch"
Function Main
set navigation extended /* Allow Return to move to next text box */
FldPtr := 1 /* Field number */
FldMax := 4 /* Maximum number of text boxes */
DEFINE WINDOW Win_1 ;
AT 0, 0;
WIDTH 600 ;
HEIGHT 300 ;
TITLE 'HMG Test';
MAIN

on key UP of Win_1 action kytest(1) /* cursor up */
on key DOWN of Win_1 action kytest(2) /* cursor down */
on key Next of Win_1 action kytest(3) /* PgDn */

@ 40, 10 label label_1 value "Str1" width 40
@ 80, 10 label label_2 value "Str2" width 40
@ 120, 10 label label_3 value "Str3" width 40
@ 160, 10 label label_4 value "Str4" width 40

@ 40, 80 TEXTBOX TEXT_1 ;
NUMERIC INPUTMASK "999,999.99"
@ 80, 80 TEXTBOX TEXT_2 value "test"
@ 120, 80 TEXTBOX TEXT_3
@ 160, 80 textbox text_4

END WINDOW

CENTER WINDOW Win_1
ACTIVATE WINDOW Win_1
on key TAB of Win_1 action kytest()

Return

function KyTest(P_1)
do case
case P_1 = 1 /* Cursor Up */
fldptr = fldptr - 1
if fldptr < 1
fldptr := 1
endif
Nav(fldptr)
case P_1 = 2 /* Cursor Down */
fldptr := fldptr + 1
if fldptr > FldMax
fldptr := FldMax
endif
Nav(fldptr)
Case P_1 = 3 /* PgDn - only active in Edit mode */
fldptr := 1
Nav(fldptr)
/* save current record and close Edit mode */
endcase
// msginfo ("Fld Ptr = "+str(fldptr))
return nil

function Nav(P_2)
do case
case P_2 = 1
win_1.text_1.setfocus
case P_2 = 2
win_1.text_2.setfocus
case P_2 = 3
win_1.text_3.setfocus
case P_2 = 4
win_1.text_4.setfocus
endcase
return nil
Leopoldo Blancas
Posts: 388
Joined: Wed Nov 21, 2012 7:14 pm
Location: México

Re: Odd Behaviour

Post by Leopoldo Blancas »

Hola...

Muy bien !!!

Quiero sugerirte que utilices los controles que hay arriba donde escribes tu Post, hay unos botones que ayudan a mejorar a que se vea mejor el código, hay un botón que se llama "Code" y entre los Code pones tu código para que se vea más claro. Por ejemplo:

Code: Select all

   IF nCode == 0
       MsgBox("El nCode Vale 0")
   ELSE
       MsgBox("El nCode NO Vale 0")
   END IF
Espero te sirva.

Saludos
Polo
*---------------------------------------------------------------
Hello ...

Very well!

I want to suggest you use the controls that are above where you write your post, there are buttons that help to improve the code look better, there is a button called "Code" and enter the code you put your code to make it look more clear. For example:

Code: Select all

    IF nCode == 0
        MsgBox ("The nCode Vale 0")
    ELSE
        MsgBox ("The nCode NOT Vale 0")
    END IF
I hope you serve.

regards
Polo
User avatar
CalScot
Posts: 303
Joined: Thu Mar 21, 2013 12:22 am
Location: California

Re: Odd Behaviour

Post by CalScot »

Thank you, Polo.
I hadn't noticed the "Code" option, but it will be very useful!!
Thanks again.
CalScot
Post Reply