Page 1 of 1

DASHBOARD WITH DRAWBOX IN MAIN FORM WITH RUN-TIME UPDATE

Posted: Sat Mar 04, 2023 5:42 pm
by jairpinho
Hello, people, I need to update data at runtime in the main window or in other windows, but you must update at runtime as the data is updated as if it were a summary dashboard. I found some examples that work very well but it doesn't update at runtime and it only works with the window's onpaint
Drawbox.zip
project in hmg 3.4.4
(5.23 KiB) Downloaded 162 times

Code: Select all


*******************************************************************************
* PROGRAMA: Demo ON PAINT event
* LENGUAJE: HMG
* FECHA:    Setiembre 2012
* AUTOR:    Dr. CLAUDIO SOTO
* PAIS:     URUGUAY
* E-MAIL:   srvet@adinet.com.uy
* BLOG:     http://srvet.blogspot.com
*******************************************************************************


#include "hmg.ch"
#include "minigui.ch"
#include "i_Color2.ch"
DECLARE WINDOW Win1
FUNCTION MAIN
//Local aSer:={ {20 }, {50 }, {2 } , {10 }} 

SET CODEPAGE TO PORTUGUESE
	IF !IsWindowDefined(Win1)
	   Load WINDOW Win1
	   CENTER WINDOW Win1
	   ACTIVATE WINDOW Win1
	  ELSE
  		Center	WINDOW  win1
		RESTORE 	WINDOW 	win1
		Return
	endif

RETURN Nil



PROCEDURE GraphsStatus() 
Local nval1 := win1.text_2.value
Local aSerieValues_PSM := {}
aSerieValues_PSM	:={	{	nval1	,30		,40		,50		, 60 },;
							{10						,12		,28		,36		, 70 },;
							{22						,55		,18		,4		, 10 },;
							{10						,20		,40		,11 	, 20};
						}
UpdateGraph ( GetFormHandle ("win1") )

return


PROCEDURE HMG_DrawBOXGraphs() 
					

	DrawBox_DASH("win1",;
	2 /*nTipo*/,;
	win1.text_1.value /*cTextVal*/,;
	"PSM ABERTOS"/*cTextTag*/,;
	120/*nLineStart_Pos*/,;
	80 /*nLine_BoxSizeHeight*/,;
	20/*nCol_Start*/,;
	200/*nCol_BoxSizeWidth*/,;
	32 /*nFonteSizeValor*/,;
	1/*nTipoFonte*/ ,;
	14 /*nFonteSizeTag*/,;
	2/*nTipoFonteTag*/ ,; 
	7 /*nBorderSize*/,;
	25/*nRaioBorder*/,;
	BORDA2/*aColorBorder*/,;
	ABERTO/*aColor_BK*/,;
	.f./*lTagBK*/,;
	nil/*aColorTagBK*/;
	)  
	
	DrawBox_DASH("win1",;
	2 /*nTipo*/,;
	"18"/*cTextVal*/,;
	"PSM ATENDIDOS"/*cTextTag*/,;
	220/*nLineStart_Pos*/,;
	80 /*nLine_BoxSizeHeight*/,;
	20/*nCol_Start*/,;
	200/*nCol_BoxSizeWidth*/,;
	32 /*nFonteSizeValor*/,;
	1/*nTipoFonte*/ ,;
	14 /*nFonteSizeTag*/,;
	2/*nTipoFonteTag*/ ,; 
	7 /*nBorderSize*/,;
	25/*nRaioBorder*/,;
	BORDA2/*aColorBorder*/,;
	FINALIZADO/*aColor_BK*/,;
	.f./*lTagBK*/,;
	nil/*aColorTagBK*/;
	)  	


	DrawBox_DASH("win1",;
	2 /*nTipo*/,;
	"18"/*cTextVal*/,;
	"PSM ATENDIMENTO"/*cTextTag*/,;
	120/*nLineStart_Pos*/,;
	80 /*nLine_BoxSizeHeight*/,;
	240/*nCol_Start_Pos*/,;
	200/*nCol_BoxSizeWidth*/,;
	32 /*nFonteSizeValor*/,;
	1/*nTipoFonte*/ ,;
	14 /*nFonteSizeTag*/,;
	2/*nTipoFonteTag*/ ,; 
	7 /*nBorderSize*/,;
	25/*nRaioBorder*/,;
	BORDA2/*aColorBorder*/,;
	ATENDIMENTO/*aColor_BK*/,;
	.f./*lTagBK*/,;
	nil/*aColorTagBK*/;
	)  	


	DrawBox_DASH("win1",;
	2 /*nTipo*/,;
	"18"/*cTextVal*/,;
	"PSM CANCELADOS"/*cTextTag*/,;
	220/*nLineStart_Pos*/,;
	80 /*nLine_BoxSizeHeight*/,;
	240/*nCol_Start_Pos*/,;
	200/*nCol_BoxSizeWidth*/,;
	32 /*nFonteSizeValor*/,;
	1/*nTipoFonte*/ ,;
	14 /*nFonteSizeTag*/,;
	2/*nTipoFonteTag*/ ,; 
	7 /*nBorderSize*/,;
	25/*nRaioBorder*/,;
	BORDA2/*aColorBorder*/,;
	CANCELADO/*aColor_BK*/,;
	.f./*lTagBK*/,;
	nil/*aColorTagBK*/;
	)  	


***********************///// ORDEM DE SERVICOS///////***************

	DrawBox_DASH("win1",;
	2 /*nTipo*/,;
	"22"/*cTextVal*/,;
	"PSM ABERTOS"/*cTextTag*/,;
	520/*nLineStart_Pos*/,;
	80 /*nLine_BoxSizeHeight*/,;
	20/*nCol_Start*/,;
	200/*nCol_BoxSizeWidth*/,;
	32 /*nFonteSizeValor*/,;
	1/*nTipoFonte*/ ,;
	14 /*nFonteSizeTag*/,;
	2/*nTipoFonteTag*/ ,; 
	7 /*nBorderSize*/,;
	25/*nRaioBorder*/,;
	BORDA2/*aColorBorder*/,;
	ABERTO/*aColor_BK*/,;
	.f./*lTagBK*/,;
	nil/*aColorTagBK*/;
	)  
	
	DrawBox_DASH("win1",;
	2 /*nTipo*/,;
	"18"/*cTextVal*/,;
	"PSM ATENDIDOS"/*cTextTag*/,;
	620/*nLineStart_Pos*/,;
	80 /*nLine_BoxSizeHeight*/,;
	20/*nCol_Start*/,;
	200/*nCol_BoxSizeWidth*/,;
	32 /*nFonteSizeValor*/,;
	1/*nTipoFonte*/ ,;
	14 /*nFonteSizeTag*/,;
	2/*nTipoFonteTag*/ ,; 
	7 /*nBorderSize*/,;
	25/*nRaioBorder*/,;
	BORDA2/*aColorBorder*/,;
	FINALIZADO/*aColor_BK*/,;
	.f./*lTagBK*/,;
	nil/*aColorTagBK*/;
	)  	


	DrawBox_DASH("win1",;
	2 /*nTipo*/,;
	"18"/*cTextVal*/,;
	"PSM ATENDIMENTO"/*cTextTag*/,;
	520/*nLineStart_Pos*/,;
	80 /*nLine_BoxSizeHeight*/,;
	240/*nCol_Start_Pos*/,;
	200/*nCol_BoxSizeWidth*/,;
	32 /*nFonteSizeValor*/,;
	1/*nTipoFonte*/ ,;
	14 /*nFonteSizeTag*/,;
	2/*nTipoFonteTag*/ ,; 
	7 /*nBorderSize*/,;
	25/*nRaioBorder*/,;
	BORDA2/*aColorBorder*/,;
	ATENDIMENTO/*aColor_BK*/,;
	.f./*lTagBK*/,;
	nil/*aColorTagBK*/;
	)  	


	DrawBox_DASH("win1",;
	2 /*nTipo*/,;
	"18"/*cTextVal*/,;
	"PSM CANCELADOS"/*cTextTag*/,;
	620/*nLineStart_Pos*/,;
	80 /*nLine_BoxSizeHeight*/,;
	240/*nCol_Start_Pos*/,;
	200/*nCol_BoxSizeWidth*/,;
	32 /*nFonteSizeValor*/,;
	1/*nTipoFonte*/ ,;
	14 /*nFonteSizeTag*/,;
	2/*nTipoFonteTag*/ ,; 
	7 /*nBorderSize*/,;
	25/*nRaioBorder*/,;
	BORDA2/*aColorBorder*/,;
	CANCELADO/*aColor_BK*/,;
	.f./*lTagBK*/,;
	nil/*aColorTagBK*/;
	)  	




RETURN

PROCEDURE DrawBox_DASH(cForm,nTipo,cTextVal,cTextTag,nLineStart,nLineEnd,nCol_Start,nCol_End,nFonteSize,nTipoFonte,nFonteSizeTag,nTipoFonteTag,nBorderSize,nRaioBorder,aColorBorder,aColor_BK,lTagBK,aColorTagBK)    
LOCAL Width1, Height1
LOCAL hDC1, BTstruct1
LOCAL Alpha := 50
LOCAL cText
Local cFonteValor := ""
Local cFonteTag := ""

 if nTipoFonte == 1 
	cFonteValor := "Open Sans"
 elseif nTipoFonte == 2
	cFonteValor := "Arial"
 elseif nTipoFonte == 3
 
 else
 
 endif
 
 
 if nTipoFonteTag == 1 
	cFonteTag := "Open Sans"
 elseif nTipoFonteTag == 2
	cFonteTag := "Arial"
 elseif nTipoFonteTag == 3
 
 else
 
 endif


   Width1  := BT_ClientAreaWidth  (cForm)
   Height1 := BT_ClientAreaHeight (cForm)

    hDC1 = BT_CreateDC (cForm, BT_HDC_ALLCLIENTAREA, @BTstruct1)
		nTypeText1  := BT_TEXT_TRANSPARENT + BT_TEXT_BOLD 
		nTypeText2  := BT_TEXT_BOLD 

        // nAlingText := BT_TEXT_LEFT + BT_TEXT_TOP
		 nAlingText := BT_TEXT_CENTER //+ BT_TEXT_TOP
		 nAlingText2 := BT_TEXT_CENTER + BT_TEXT_BASELINE //+ BT_TEXT_BOTTOM
		 
		 if nTipo = 1 
			BT_DrawFillRoundRect (hDC1,nLineStart, nCol_Start,nCol_End ,nLineEnd , nRaioBorder, nRaioBorder, ORANGE, RED, nBorderSize)
			BT_DrawText (hDC1, (nLineEnd /2) + nLineStart + (nFonteSize/2)/*pos linha*/ , (nCol_End / 2 ) +  nCol_Start /*pos col*/ , cTextVal, cFonteValor, nFonteSize, BLACK, if(lTagBK,aColorTagBK,nil) , if(lTagBK,nTypeText2,nTypeText1) , nAlingText2)
			//BT_DeleteDC (BTstruct1)
		 endif
		 
		 if nTipo = 2 
			 BT_DrawFillRoundRect (hDC1, nLineStart, nCol_Start, nCol_End, nLineEnd, nRaioBorder, nRaioBorder, aColor_BK, aColorBorder, nBorderSize)
			 BT_DrawText (hDC1, (nLineStart+nBorderSize) , (nCol_End / 2 ) +  nCol_Start /*pos col*/ , cTextTag, cFonteTag, nFonteSizeTag, BLACK,if(lTagBK,aColorTagBK,nil) , if(lTagBK,nTypeText2,nTypeText1), nAlingText)
			 BT_DrawText (hDC1, nLineEnd  + (nLineStart-(nBorderSize*2)) /*pos linha*/  , (nCol_End / 2 ) +  nCol_Start /*pos col*/ , cTextVal, cFonteValor, nFonteSize,BLACK,  ,nTypeText1  , nAlingText2)
			// BT_DeleteDC (BTstruct1)
		 endif
		 
		 if nTipo = 3 
			/*
			 BT_DrawFillRoundRect (hDC1, 400, 50, 300, 100, nRaioBorder, nRaioBorder, ORANGE, RED, nBorderSize)
			 BT_DrawText (hDC1, (400+(nBorderSize/2))-16 , 50+150, "PSM ABERTOS", "Comic Sans MS", nFonteSize, BLACK,if(lTagBK,aColorTagBK,nil) , if(lTagBK,nTypeText2,nTypeText1), nAlingText)
			 BT_DrawText (hDC1, (450+(nBorderSize/2))-32 , 50+150, "1500", "Comic Sans MS", nFonteSize, BLACK, , nTypeText1, nAlingText)		 
			 BT_DeleteDC (BTstruct1)
			*/
		 endif
		 
		 /*
		 if nTipo = 1 
			BT_DrawFillRoundRect (hDC1,050, 50, 300, 100, 10, 10, ORANGE, RED, 5)
			BT_DrawText (hDC1, (100+(5/2))-32 , 50+150, "1500", "Comic Sans MS", 32, BLACK, , nTypeText2, nAlingText)
		 endif
		 
		 if nTipo = 2 
			 BT_DrawFillRoundRect (hDC1, 200, 50, 300, 100, 10, 10, ORANGE, RED, 5)
			 BT_DrawText (hDC1, (200+5) , 50+150, "PSM ABERTOS", "Comic Sans MS", 16, BLACK, , nTypeText1, nAlingText)
			 BT_DrawText (hDC1, 300-(5*2) , 50+150, "1500", "Comic Sans MS", 40, BLACK, , nTypeText2, nAlingText2)
		 endif
		 
		 if nTipo = 3 
			 BT_DrawFillRoundRect (hDC1, 400, 50, 300, 100, 10, 10, ORANGE, RED, 5)
			 BT_DrawText (hDC1, (400+(5/2))-16 , 50+150, "PSM ABERTOS", "Comic Sans MS", 16, BLACK, , nTypeText1, nAlingText)
			 BT_DrawText (hDC1, (450+(5/2))-32 , 50+150, "1500", "Comic Sans MS", 32, BLACK, , nTypeText2, nAlingText)		 
			 BT_DeleteDC (BTstruct1)
		 endif		 
		 */
		 
RETURN






Re: DASHBOARD WITH DRAWBOX IN MAIN FORM WITH RUN-TIME UPDATE

Posted: Sun Mar 05, 2023 5:25 am
by AUGE_OHR
hi,

instead of

Code: Select all

* UpdateGraph ( GetFormHandle ("win1") )
use

Code: Select all

INVALIDATERECT( GetFormHandle ("win1") )

Re: DASHBOARD WITH DRAWBOX IN MAIN FORM WITH RUN-TIME UPDATE

Posted: Tue Mar 07, 2023 3:13 am
by andyglezl
Hola
Es solo una idea, me base en lo que quieres hacer, no como lo quieres programar.
*--------------------------------------------------------------------------------------------------------
Hello
It's just an idea, I base it on what you want to do, not how you want to program it.