Page 1 of 2

Touch screen help

Posted: Mon Apr 06, 2026 6:27 pm
by digitsoft
Good evening. Can you help me with this touchscreen? I need the products to appear on the right screen when I press a button on the left screen. For example, if I press the "BEBIDAS," "CARNES," or "CERVEZAS" button, it should display the menu associated with that button.

I am using
DCSTATUSBAR oStaticBottom HEIGHT 49 ALIGN DCGUI_ALIGN_BOTTOM SPACING 0

@ xRow:=00.00,00.00 DCSTATIC TYPE XBPSTATIC_TYPE_TEXT SIZE 130.0,36.00 OBJECT oToolsStatic1 COLOR GRA_CLR_BLACK,GRA_CLR_WHITE
@ 0.00,00.0 DCDIALOG oDlgFamilia DRAWINGAREA oDrawinAreaFamilia SIZE 028.0,35.8 NOTITLEBAR BORDER XBPDLG_NO_BORDER SCROLLBARS XBP_SCROLLBAR_VERT PARENT oToolsStatic1 FONT "9.Arial Bold" COLOR GRA_CLR_BLACK,GRA_CLR_WHITE // EVAL {|o| o:setFrameState(XBPDLG_FRAMESTAT_MAXIMIZED),o:Show() }
@ 0.00,28.3 DCDIALOG oDlgProducto DRAWINGAREA oDrawinAreaProducto SIZE 130.0,35.8 NOTITLEBAR BORDER XBPDLG_NO_BORDER SCROLLBARS XBP_SCROLLBAR_VERT PARENT oToolsStatic1 FONT "9.Arial Bold" COLOR GRA_CLR_BLACK,GRA_CLR_WHITE // EVAL {|o| o:setFrameState(XBPDLG_FRAMESTAT_MAXIMIZED),o:Show() }
@ 0.00,00.2 DCSTATIC TYPE XBPSTATIC_TYPE_TEXT SIZE 130.0,35.80 OBJECT oStaticRight COLOR GRA_CLR_BLACK,GRA_CLR_GREEN PARENT oDrawinAreaProducto

nRow := 0.1 ; nCol := 0.5
select "CodFam,Descrip" FROM "FAMILIA" ORDER BY "descrip" CONNECTION aConnection[1] TO oDataBase
IF oDataBase:Reccount()>0
oDataBase:gotop()
do while !oDataBase:eof()
@ nRow,nCol DCPUSHBUTTON CAPTION STRTRAN(ALLTRIM(SQLFieldGet(oDataBase,"descrip"))," ",";") ;
SIZE 25.00,04.00 ;
ACTION PushTouchMe( GetList, @oStaticRight, SQLFieldGet(oDataBase,"CodFam") ) ;
CONFIG aConfigXp(,,,,,"12.Arial Bold",,,XBPALIGN_VCENTER+XBPALIGN_HCENTER ) ;
RESIZE DCGUI_RESIZE_AUTORESIZE ;
PARENT oDrawinAreaFamilia
nRow += 4.1
oDataBase:skip()
END do
END IF
close DATABASE oDataBase
GeneraListaDeProductos( GetList, @oDrawinAreaProducto, "001" )

@ 00.00,00.20 DCSTATIC TYPE XBPSTATIC_TYPE_TEXT SIZE DCGUI_PARENTWIDTH,02.5 OBJECT oTooldStatic2 PARENT oStaticBottom COLOR GRA_CLR_BLACK,GRA_CLR_WHITE //GraMakeRGBColor( { 255, 255, 255} )
@ 00.30,00.80 DCPUSHBUTTON CAPTION {"ENTER",MACEPTAR ,"Aceptar" } SIZE 13.0,2.0 ACTION {|| DC_ReadGuiEvent(DCGUI_EXIT_OK,GetList) } ACCELKEY aGrabar( "Key" ) WHEN {|| .T. } TOOLTIP "Cargar Producto" OBJECT @oGrabar PARENT @oTooldStatic2
@ 00.30,00.00 DCPUSHBUTTON CAPTION {"ESC" ,MCANCELAR,"Cancelar"} SIZE 13.0,2.0 ACTION {|| DC_ReadGuiEvent(DCGUI_EXIT_ABORT,GetList) } ACCELKEY xbeK_ESC TOOLTIP "Salir" PARENT @oTooldStatic2

///@ 00.70,_Col()+04.5 DCSAY {|| "Existencia: "+CalculaExistencia({SQLFieldGet(oPEPAM01,"CodProd"),SQLFieldGet(oPEPAM01,"Existencia")},,3) } SAYFONT "15.Arial Bold" SAYSIZE 65.0,1.5 SAYCOLOR GRA_CLR_DARKRED PARENT oTooldStatic2

DCGETOPTIONS NOMAXBUTTON NOMINBUTTON NOCONFIRM ICON ICON_1 NOTABSTOP

DCREAD GUI TITLE cTitulo ;
FIT ;
MODAL ;
SETFOCUS oSeek ;
OWNER oParent ;
OPTIONS GetOptions ;
HANDLER MyHandler ;
PARENT @oDlg ;
TO lOk ;
eval {|o|DC_CenterObject(oDlg),; // AddHeaderButton(GetList,oBrowseProductos,3,"º",,{|a,x,o| PostAppEvent(xbeP_Keyboard,xbeK_CTRL__R,,oSeek) },{20,20},2,,1,,{GRA_CLR_BLACK,GRA_CLR_WHITE}),;
SetAppFocus(oSeek),;
oDlgFamilia:setSize({oDlgFamilia:currentSize()[1]+1,oDlgFamilia:currentSize()[2]}),;
DC_PointerArrow( SQLOwner() ) }


/*
Element Type Description
------- ------ --------------------------------------------------
[1] C/O Caption string or Bitmap object
[2] N Foreground color
[3] N Start Row, in pixels from top
[4] N Start Column, in pixels from top
[5] N End Row, in pixels from top (bitmap only)
[6] N End Column, in pixels from top (bitmap only)
[7] N Alignment. XBALIGN_* from XBP.CH.
[8] C Font compound name or Font object (caption only)
*/
STATIC FUNCTION GeneraListaDeProductos( GetList, oDrawinArea, cCodFam )
LOCAL oPEPAM01, oPEPAM01U, cFotoProducto, cNombreProd
LOCAL nRow := 0.1, nCol := 0.5, aCaptions

select "CodProd,NombreProd" FROM "PEPAM01" WHERE "CodFam="+SQLString( cCodFam ) ORDER BY "NombreProd" CONNECTION aConnection[1] TO oPEPAM01
dcqout "CodFam:",cCodFam,"|",oPEPAM01:Reccount()

IF oPEPAM01:Reccount()>0
oPEPAM01:gotop()
do while !oPEPAM01:eof()
cFotoProducto := BuscaBitMap(.T.,"PEPAM01","CodProd",SQLFieldGet(oPEPAM01,"CodProd"))

select "Unidad" FROM "PEPAM01U" WHERE "CodProd="+SQLString(SQLFieldGet(oPEPAM01,"CodProd")) ORDER BY "ForVenta" CONNECTION aConnection[1] TO oPEPAM01U
IF oPEPAM01U:Reccount()>0
oPEPAM01U:gotop()
do while !oPEPAM01U:eof()
cNombreProd := ALLTRIM(SQLFieldGet(oPEPAM01,"NombreProd"))+";"+ALLTRIM(SQLFieldGet(oPEPAM01U,"Unidad"))
aCaptions := { { cFotoProducto, ,005,05,152,163,(XBPALIGN_TOP+XBPALIGN_HCENTER) , , , ,.F., , , },; && 157
{ cNombreProd , GRA_CLR_WHITE,350,01, , ,(XBPALIGN_BOTTOM+XBPALIGN_HCENTER),'12.Calibri Bold', , } }

@ 0.1+nRow,nCol+0.2 DCPUSHBUTTONXP ;
CAPTIONARRAY aCaptions ;
SIZE 25.00, 10.00 ;
COLOR GRA_CLR_WHITE, COLOR_SLATEGRAY ;
MOUSECOLOR GRA_CLR_BLACK, GraMakeRGBColor({240,205, 75}) ; && GraMakeRGBColor({30,144,255}) ;
MOUSEFONT '10.Calibri Bold' ;
BORDERCOLOR GRA_CLR_BLACK ;
ACTION {|| .T. } ;
PARENT oDrawinArea
IF MOD(oPEPAM01:Recno(),4)=0
nRow += 10.2 ; nCol := 0.5
ELSE
nCol += 25.2
END IF
oPEPAM01U:skip()
end do
END IF
oPEPAM01:skip()
END do
END IF
close DATABASE {oPEPAM01,oPEPAM01U}
RETURN DC_GetRefresh( GetList )

Thank you.

Re: Touch screen help

Posted: Tue Apr 07, 2026 12:16 am
by skiman
Hi,

Right screen? Do you want to display it on a second monitor?

Re: Touch screen help

Posted: Tue Apr 07, 2026 1:13 am
by Tom
I think it's much simpler. He wants to actualize the items (DCPUSHBUTTONXPs) on the right hand side of the "Productos Consultados"-dialog depending on the button clicked on the left side.

Re: Touch screen help

Posted: Tue Apr 07, 2026 4:18 am
by Tom
If you want to stay with this architecture, place all buttons possible (even on top of each other) and use the HIDE clause to not show those you don't need depending on the selection on the left. Change the value for the condition there (like HIDE {||nMenuItem # 1}), fire "DC_GetRefresh(oArea)" to show/hide the buttons you don't use from the ACTION clause of the buttons on the left. OR: Place all button groups on different STATIC(AREA)s having all the same parent/size and pos, and hide the STATICs you don't need depending on the selection left. Refresh the parent to hide/show the areas after you toggled the dependency var with the menu buttons.

Another solution would be to create the maximum number of buttons used and combine the HIDE-solution with codeblocks for the captions, which will get a little complicated since you use a captionarray. A cool solution for this would be to get the captionarray from a function.

A third idea is to use a browse instead of a number of buttons, but this browse had to be created with ownerdrawing.

There might be dozends of other solutions for your issue.

Re: Touch screen help

Posted: Tue Apr 07, 2026 4:49 am
by digitsoft
Yes

Re: Touch screen help

Posted: Wed Apr 08, 2026 12:58 am
by skiman
Hi,

I suppose your 'yes' is the answer for the second monitor? Or is it 'yes' for the solution of Tom?

In case you want it on a second monitor.

With the following you get the width of the primary monitor.
aWorkArea := dc_getworkarea()
nWidth := aWorkArea[3] - aWorkArea[1]

Then nWidth+1,0 is the first pixel of the second monitor.

Re: Touch screen help

Posted: Wed Apr 08, 2026 4:43 am
by reganc
Hi Chris
skiman wrote: Wed Apr 08, 2026 12:58 am In case you want it on a second monitor.

With the following you get the width of the primary monitor.
aWorkArea := dc_getworkarea()
nWidth := aWorkArea[3] - aWorkArea[1]

Then nWidth+1,0 is the first pixel of the second monitor.
Just for info, is there an easy way to see if a second monitor is even available?

Re: Touch screen help

Posted: Wed Apr 08, 2026 5:37 am
by Tom

Code: Select all

lHave2ndMonitor := IF(confirmbox(,'Do you have a second monitor?','Just a question',XBPMB_YESNO,XBPMB_QUESTION+XBPMB_SYSMODAL,XBPMB_DEFBUTTON2)=XBPMB_RET_YES,.T.,.F.)
8-)

Re: Touch screen help

Posted: Mon Apr 13, 2026 1:16 am
by reganc
Tom wrote: Wed Apr 08, 2026 5:37 am

Code: Select all

lHave2ndMonitor := IF(confirmbox(,'Do you have a second monitor?','Just a question',XBPMB_YESNO,XBPMB_QUESTION+XBPMB_SYSMODAL,XBPMB_DEFBUTTON2)=XBPMB_RET_YES,.T.,.F.)
8-)
Oh, very funny... :)

Re: Touch screen help

Posted: Mon Apr 13, 2026 1:27 am
by Tom
8-)
Take a look at the VirtualScreen class(object) of Xbase++ (2.0). VirtualScreen():getPhysicalScreenCount() returns the number of physical screens attached to the workstation.