whether there is another, more beautiful and elegant solution for
RadioButtons effect in command DCPUSHBUTTONXP, when using the keyboard
F1, F2, F3, F4, of the solutions that I managed to do, and that is pretty rough ?
Code: Select all
#include "Appevent.ch"
#include "Common.ch"
#include "Xbp.ch"
#include "Font.ch"
#include "Gra.ch"
#include "Xbtsys.ch"
#INCLUDE "DCDIALOG.CH"
#INCLUDE "DCGRA.CH"
#PRAGMA Library( "DCLIPX.LIB" )
PROCEDURE APPSYS()
RETURN NIL
PROCEDURE MAIN()
TEST()
RETURN NIL
*************************************************************************
FUNCTION TEST()
*************************************************************************
LOCAL GetList := {}, GetOptions, oDlg
LOCAL ;
x1 := 0.6 ,;
y1 := 0.6 ,;
du := 15-0.2 ,;
bb := 3-0.1 ,;
bmpOkvir := nil ,;
CUR := {"user32.dll",114}
LOCAL ;
co1 := GRA_CLR_WHITE, co2 := GRA_CLR_DARKGREEN, ;
co3 := GRA_CLR_BLACK, co4 := GRA_CLR_YELLOW, ;
co5 := GRA_CLR_DARKRED, fo1 := "12.Arial Bold"
PUBLIC o1,o2,o3,o4,oEnd // dcpushbutton objects
SET CHARSET TO ANSI
@ 0,0.5 ;
DCSTATIC TYPE XBPSTATIC_TYPE_GROUPBOX;
SIZE 61.5, 4 ;
OBJECT bmpOkvir ;
COLOR GRA_CLR_RED
//--- F1 keyboard
@ x1,y1 ;
DCPUSHBUTTONXP CAPTION "GROUP1;F1" ;
PARENT bmpOkvir SIZE du,bb ACCELKEY xbeK_F1 ;
ACTION {|a,b,o| ;
selectcolorbutton(o,GetList), SetAppFocus(oEnd)} ;
CURSOR CUR SELECTENABLE SELECTCOLOR co1,co5 SELECTED ; // INIT SELECTED
OUTLINE COLOR co1,co2 CLICKCOLOR co3,co4 FONT fo1 OBJECT o1
//--- F2 keyboard
@ x1,y1+15 ;
DCPUSHBUTTONXP CAPTION "GROUP2;F2" ;
PARENT bmpOkvir SIZE du,bb ACCELKEY xbeK_F2 ;
ACTION {|a,b,o| ;
selectcolorbutton(o,GetList), SetAppFocus(oEnd)} ;
CURSOR CUR SELECTENABLE SELECTCOLOR co1,co5 ;
OUTLINE COLOR co1,co2 CLICKCOLOR co3,co4 FONT fo1 OBJECT o2
//--- F3 keyboard
@ x1,y1+15+15 ;
DCPUSHBUTTONXP CAPTION "GROUP3;F3" ;
PARENT bmpOkvir SIZE du,bb ACCELKEY xbeK_F3 ;
ACTION {|a,b,o| ;
selectcolorbutton(o,GetList), SetAppFocus(oEnd)} ;
CURSOR CUR SELECTENABLE SELECTCOLOR co1,co5 ;
OUTLINE COLOR co1,co2 CLICKCOLOR co3,co4 FONT fo1 OBJECT o3
//--- F4 keyboard
@ x1,y1+15+15+15 ;
DCPUSHBUTTONXP CAPTION "GROUP4;F4" ;
PARENT bmpOkvir SIZE du,bb ACCELKEY xbeK_F4 ;
ACTION {|a,b,o| ;
selectcolorbutton(o,GetList), SetAppFocus(oEnd)} ;
CURSOR CUR SELECTENABLE SELECTCOLOR co1,co5 ;
OUTLINE COLOR co1,co2 CLICKCOLOR co3,co4 FONT fo1 OBJECT o4
//--- End
@ 4,0 ;
DCPUSHBUTTON CAPTION "The;End" ;
SIZE du/2,bb ALIGNCAPTION BS_MULTILINE;
ACTION {|a,b,o| DC_ReadGuiEvent(DCGUI_EXIT_OK,GetList) } CURSOR CUR OBJECT oEnd
@ 4.2,9 DCSAY "The group is activated with mouse LbClick on the green commandbutton (Ok)" SAYSIZE 0
@ 5.0,9 DCSAY "The group is activated by clicking on a keyboard button F1, F2, F3, F4 (??)" SAYSIZE 0
@ 5.8,9 DCSAY "Note: Activated group must be red and the other groups are green" SAYSIZE 0
@ 6.6,9 DCSAY " It must be with the keyboard F1, F2, F3, F4 get RadioButtons effect" SAYSIZE 0
DCGETOPTIONS AUTORESIZE // WINDOWWIDTH 500 WINDOWHEIGHT 300
DCREAD GUI TITLE "TEST :: DCPUSHBUTTONXP Tips-And-Tricks Roger Donnay" OPTIONS GetOptions FIT ;
SETFOCUS @oEnd PARENT @oDlg MODAL EVAL {|o| SetAppWindow(o) }
RETURN NIL
*************************************************************************
STATIC FUNCTION selectcolorbutton(o,getlist)
*************************************************************************
o1:SELECTED := .F. ; setappfocus(o1) ; dc_getrefresh(o1)
o2:SELECTED := .F. ; setappfocus(o2) ; dc_getrefresh(o2)
o3:SELECTED := .F. ; setappfocus(o3) ; dc_getrefresh(o3)
o4:SELECTED := .F. ; setappfocus(o4) ; dc_getrefresh(o4)
setappfocus(o)
o:SELECTED := .T.
dc_getrefresh(o)
setappfocus(o)
RETURN NIL