Help for get when F1 pressed. Possible?

Help for get when F1 pressed. Possible?

Postby JC » Sat Apr 12, 2008 12:44 pm

Hi again my friends!

Only a doubt... How I can define a help for a get for exhibition when the user press the F1 key?

It's possible?
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Re: Help for get when F1 pressed. Possible?

Postby mmercado » Sat Apr 12, 2008 9:59 pm

JC wrote:Only a doubt... How I can define a help for a get for exhibition when the user press the F1 key?

1.- SetHelpFile( "YourHelpFile.hlp" )
2.- When defining the Get control you should use the clause: HELPID YourHelpTopic

Then, when user presses th F1 key, program will show the defined topic.

Notice: YourHelpTopic can be a numeric or alphameric expression according to your help file's topic definition.

Regards.

Manuel Mercado
User avatar
mmercado
 
Posts: 782
Joined: Wed Dec 19, 2007 7:50 am
Location: Salamanca, Gto., México

Postby Rochinha » Sun Apr 13, 2008 2:09 am

Friends,

Try modify this sample:

TheHelp.prg
Code: Select all  Expand view  RUN
// Sample showing how to work with new help techniques from FiveWin.

#include "FiveWin.ch"
#include "NewHelp.ch"
#include "Inkey.ch"

#define SRCPAINT   15597702 // 0xEE0086
#define SRCAND      8913094

#define GWW_ID          -12

static oBmp1, oBmp2, oFont

function Main()
   local oDlg, oBtn, oCursor
   local cName    := PadR( "Hello" , 30 )
   local cAddress := PadR( "World!", 30 )

   REQUEST DBFCDX
   rddsetdefault( "DBFCDX" )

   // SetKey( VK_F1, { | nKey | TheHelp( CtrlSearch(oDlg) ) } )

   DEFINE CURSOR oCursor RESOURCE "Help"
   DEFINE BITMAP oBmp1 RESOURCE "Genie1"
   DEFINE BITMAP oBmp2 RESOURCE "Genie2"
   DEFINE FONT oFont NAME "Arial" SIZE 0, -9
   SET _3DLOOK ON
   DEFINE DIALOG oDlg RESOURCE "Test"
   REDEFINE GET oGet1 VAR cName    ID ID_NAME    OF oDlg HELPID ID_NAME
   REDEFINE GET oGet2 VAR cAddress ID ID_ADDRESS OF oDlg HELPID ID_ADDRESS
   //
   oGet1:bKeyDown := {|nKey,bFlags| iif( nKey==VK_F2, TheHelp( CtrlSearch(oDlg) ), .t.) }
   oGet2:bKeyDown := {|nKey,bFlags| iif( nKey==VK_F2, TheHelp( CtrlSearch(oDlg) ), .t.) }
   //
   ACTIVATE DIALOG oDlg CENTERED
   RELEASE OBJECTS oCursor, oBmp1, oBmp2, oFont
   return nil

function TheHelp( idCtrl )
   local cProcName := Padr(ProcName( 1 ),10)
   local nProcLine := 0 // ProcLine( 0 )
   local cProcCtrl := StrZero( idCtrl, 4 )
   local cTexto    := Space( 200 )
   local aStru
   if !file( "HELP.DBF" )
      aStru := { { "PROG"    ,"C" ,10 , 0 } , ;
                 { "LINHA"   ,"C" , 6 , 0 } , ;
                 { "VARIAVEL","C" , 4 , 0 } , ;
                 { "TEXTO"   ,"M" ,10 , 0 } }
      dbCreate( "HELP.DBF", aStru )
   endif
   use help new
   if !file( "HELP.CDX" )
      index on prog+linha+variavel to help
   endif
   set index to help
   dbGotop()
   dbSeek( cProcName+StrZero(nProcLine,6)+cProcCtrl )
   if !found()
      MsgGet( "Digite uma ajuda", "Conteudo:", @cTexto )
      dbAppend()
      help->PROG     := cProcName
      help->LINHA    := STRZERO(nProcLine,6)
      help->VARIAVEL := cProcCtrl
      help->TEXTO    := cTexto
   else
      cTexto         := TEXTO
      MsgFancy( If( Empty( cTexto ), "Sorry, I am a very limited Genius...", Alltrim( cTexto ) ) )
   endif
   close help
   return nil

/*
* SOURCE: NewHelp.prg
*/
function MsgFancy( cMsg )
   local oDlg, oBrush
   DEFINE BRUSH oBrush STYLE NULL             // Transparent painting !
   DEFINE DIALOG oDlg FROM 2, 2 TO 20, 60 BRUSH oBrush STYLE WS_POPUP
   ACTIVATE DIALOG oDlg CENTERED ;
      ON PAINT ( PalBmpDraw( oDlg:hDC, 0, 0, oBmp2:hBitmap, 0, 0, 0, SRCPAINT ),;
                 PalBmpDraw( oDlg:hDC, 0, 0, oBmp1:hBitmap, 0, 0, 0, SRCAND ),;
                 oDlg:Say( 3.7, 10, cMsg,,, oFont ) ) ;
      ON LEFT CLICK oDlg:End()
   return nil

/*
* SOURCE: TestFoc2.prg
*/
function CtrlSearch(oDlgActive)
   local nAt := AScan( oDlgActive:aControls, { | oCtrl | oCtrl:lFocused } )
   return nAt


TheHelp.rc
Code: Select all  Expand view  RUN
#include "WinApi.ch"
#include "NewHelp.ch"

help   CURSOR "../cursors/help.cur"
genie1 BITMAP "../bitmaps/genie1.bmp"
genie2 BITMAP "../bitmaps/genie2.bmp"

test DIALOG 28, 66, 171, 68
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Press help and then click a control"
FONT 8, "Arial"
BEGIN
   LTEXT "&Name:", -1, 14, 11, 22, 8
   EDITTEXT ID_NAME, 37, 10, 130, 12, ES_LEFT | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP
   LTEXT "&Address:", -1, 5, 27, 29, 8
   EDITTEXT ID_ADDRESS, 37, 25, 130, 12, ES_LEFT | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP
   PUSHBUTTON "&Ok", ID_OK, 15, 51, 33, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
   PUSHBUTTON "&Cancel", 2, 69, 50, 33, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
   PUSHBUTTON "&Help", ID_HELP, 123, 50, 33, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
END

STRINGTABLE
BEGIN
   ID_NAME,    "Type here the name of the customer"
   ID_ADDRESS, "Type here the address of your customer"
   ID_OK,      "Press here when you want to save this info"
   IDCANCEL,   "Press here if you want to cancel this operation"
   ID_HELP,    "As you are checking, pressing here offers help!"
END


How to use:
Code: Select all  Expand view  RUN
   ...
   SetKey( VK_F2, nil )
   DEFINE DIALOG oDlg RESOURCE "dlgResource"
          ...
          REDEFINE GET oGet1 VAR cGet1 ID 500 PICTURE "@!" OF oDlg
          REDEFINE GET oGet2 VAR cGet2 ID 500 PICTURE "@!" OF oDlg
          REDEFINE GET oGetN VAR cGetN ID 500 PICTURE "@!" OF oDlg
          //
          oGet1:bKeyDown := {|nKey,bFlags| iif( nKey==VK_F2, TheHelp( CtrlSearch(oDlg) ), .t.) }
          oGet2:bKeyDown := {|nKey,bFlags| iif( nKey==VK_F2, TheHelp( CtrlSearch(oDlg) ), .t.) }
          oGetN:bKeyDown := {|nKey,bFlags| iif( nKey==VK_F2, TheHelp( CtrlSearch(oDlg) ), .t.) }
          ...
   endif
   ACTIVATE DIALOG oDlg CENTERED
   SetKey( VK_F2, { || AnotherYourFunction() } )
   ...
Rochinha
 
Posts: 310
Joined: Sun Jan 08, 2006 10:09 pm
Location: Brasil - Sao Paulo


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 81 guests