Page 1 of 1

dcget combo

Posted: Mon Oct 10, 2016 11:38 pm
by Koverhage
It is possible to make a combo with pushbuttons ?
I wish that the user does not scroll in text, rather he can click on a button.
Example:

Re: dcget combo

Posted: Tue Oct 11, 2016 11:14 am
by rdonnay
Klaus -

I don't want to make any changes to DCGET..COMBO.

Here is some code that shows you how to do this.

Code: Select all

#INCLUDE "dcdialog.CH"
#INCLUDE "appevent.CH"

FUNCTION Main()

/* This example shows how to create a drop-down button list
   from a POPUP button on a GET */

LOCAL GetList[0], cText, bPopUp, oStatic, nPopKey

cText := Space(30)

bPopUp := {|c,oGet|DropButtons(c,oGet,oStatic)}

@ 0,0 DCSTATIC TYPE XBPSTATIC_TYPE_RECESSEDBOX SIZE 80,15 ;
      OBJECT oStatic

DCSETPARENT oStatic

@ 1,1 DCSAY 'Enter some text' GET cText POPUP bPopUp SAYSIZE 0

nPopKey := DC_SetPopKey(xbeK_SH_DOWN)

DCREAD GUI FIT ADDBUTTONS TITLE 'Enter File Names' ;
   SETAPPWINDOW

DC_SetPopKey(nPopKey)

RETURN nil

* ------------

PROC appsys ; RETURN

* ------------

STATIC FUNCTION DropButtons( cText, oGet )

LOCAL GetList[0], aPos, GetOptions, oStatic

aPos := DC_CalcAbsolutePosition({0,0},oGet)

@ 0,0 DCSTATIC TYPE XBPSTATIC_TYPE_RECESSEDBOX OBJECT oStatic ;
      SIZE 200,85

DCSETPARENT TO oStatic

@ 10,10 DCPUSHBUTTON CAPTION 'Button 1' SIZE 90,30 ;
        ACTION {||cText := 'Button 1', DC_ReadGuiEvent(DCGUI_EXIT_OK,GetList)}

@ 45,10 DCPUSHBUTTON CAPTION 'Button 2' SIZE 90,30 ;
      ACTION {||cText := 'Button 2', DC_ReadGuiEvent(DCGUI_EXIT_OK,GetList)}

@ 10,100 DCPUSHBUTTON CAPTION 'Button 3' SIZE 90,30 ;
      ACTION {||cText := 'Button 3', DC_ReadGuiEvent(DCGUI_EXIT_OK,GetList)}

@ 45,100 DCPUSHBUTTON CAPTION 'Button 4' SIZE 90,30 ;
      ACTION {||cText := 'Button 4', DC_ReadGuiEvent(DCGUI_EXIT_OK,GetList)}

DCGETOPTIONS ;
   NOTITLEBAR ;
   BORDER XBPDLG_NO_BORDER ;
   ALWAYSONTOP ;
   PIXEL

DCREAD GUI FIT TITLE 'Choose a button' OPTIONS GetOptions ;
   EVAL {|o|o:setPos({aPos[1],aPos[2]-o:currentSize()[2]+10})} ;
   MODAL ;
   HANDLER buttonHandler

RETURN cText

* ----------

STATIC FUNCTION buttonHandler( nEvent, mp1, mp2, oXbp, oDlg, GetList )

IF nEvent == xbeP_KillDisplayFocus
  RETURN DCGUI_EXIT_ABORT
ENDIF

RETURN DCGUI_NONE

Re: dcget combo

Posted: Tue Oct 11, 2016 10:30 pm
by Koverhage
Roger,

you should not change anything ito DCGET...COMBO.

Thanks for the code sample.