Modify code of gfx

save number in the GFX textbox

function EIOW_BOX( Text, x1, y1, x2, y2, BorderColor, BackColor , textcolor , fnt, fntsize, fntweight )
{
     GfxSetOverlayMode( 0 );
    // GfxSelectFont( "Tahoma", 9, 800 );
     GfxSelectFont( "fnt", fntsize, fntweight, 0, 0, 0 );
     GfxSelectPen( BorderColor ,3);
     GfxSetBkMode( 1 );
     GfxSelectSolidBrush( BackColor );
     GfxSetBkColor( BackColor );
     GfxSetTextColor( textcolor );
     GfxRectangle( x1, y1, x2, y2 );
     GfxDrawText( Text, x1, y1, x2, y2, 32 | 1 | 4);
}

add this part of the code that is for GUI and use it for GFX


global _x0, _y0;
    local rc ;

    x = x + _x0;     y = y + _y0;
    rc = GuiEdit( idEdit, x, y, width, height, notifyHitReturn ); //

    ID = GuiGetEvent( 0, 0 );     event = GuiGetEvent( 0, 1 );
    if( ID == idEdit ) StaticVarSetText( "sV" + idEdit,  GuiGetText( idEdit ), 1 );

    if( rc == guiNew )
    {  // after restart Amibroker read FIRST these Static Line
        txt = StaticVarGettext( "sV" + idEdit );
        GuiSetText( txt, idEdit );
    }

    GuiSetColors( idEdit, idEdit, 1, textColor, bgColor, textColor );

    return GuiGetValue( idEdit );

thank you all

Unfortunately your question isn't clear enough and does not provide all necessary details to give you an answer. Please follow this advice: How to ask a good question

I agree with you
I will rewrite it

this the code



procedure EIOWOrigin(x0, y0) {
	global _x0, _y0;
	_x0 = x0; _y0 = y0;
}
procedure EIOWSetColors(fgColor, bgColor) {
	GfxSetTextColor(fgColor); GfxSetBkColor(bgColor); 
	GfxSelectPen(fgColor); GfxSelectSolidBrush(bgColor);
}

    
    function EIOW_BOX( Text, x1, y1, x2, y2, BorderColor, BackColor , textcolor , fnt, fntsize, fntweight )
{
     GfxSetOverlayMode( 0 );
    // GfxSelectFont( "Tahoma", 9, 800 );
     GfxSelectFont( "fnt", fntsize, fntweight, 0, 0, 0 );
     GfxSelectPen( BorderColor ,3);
     GfxSetBkMode( 1 );
     GfxSelectSolidBrush( BackColor );
     GfxSetBkColor( BackColor );
     GfxSetTextColor( textcolor );
     GfxRectangle( x1, y1, x2, y2 );
     GfxDrawText( Text, x1, y1, x2, y2, 32 | 1 | 4);
}

procedure  EIOW_Label(Text, x1, y1, x2, y2, textcolor , fnt, fntsize, fntweight) 
{
       GfxSelectFont( "fnt", fntsize, fntweight, 0, 0, 0 );
       GfxSetTextColor( textcolor );
	 GfxDrawText( Text, x1, y1, x2, y2, 32 | 1 | 4);
}
procedure EIOW_Frame( x1, y1, x2, y2 ) {
	
	 GfxSelectSolidBrush( colorBlack);
     GfxSetBkColor( colorBlack );
    GfxRectangle(x1, y1, x2, y2);
    
	//GfxDrawText(titl, pipx, pipy, pipx+width, pipy+hheight, 1|4|32);
		
    }
    
    


function EIOWEditNumber( idEdit, initialValue, x, y, width, height, textColor, bgColor )
{  // this function hold the text for the next restart of Amibroker
    global _x0, _y0;
    local rc ;

    x = x + _x0;     y = y + _y0;
    rc = GuiEdit( idEdit, x, y, width, height, notifyHitReturn ); //

    ID = GuiGetEvent( 0, 0 );     event = GuiGetEvent( 0, 1 );
    if( ID == idEdit ) StaticVarSetText( "sV" + Name() + idEdit,  GuiGetText( idEdit ), 1 );

    if( rc == guiNew )
    {  
        txt = StaticVarGettext( "sV" + Name() + idEdit );
        GuiSetText( txt, idEdit );
    }

    GuiSetColors( idEdit, idEdit, 1, colorWhite, colorDarkGreen, colorLightGrey );

    return GuiGetValue( idEdit );
}
    
    
    
procedure EIOW_CLC(EIOWx,EIOWy) {
	local  txt,textColor , bgColor , n,n2,n3,n4,n5,n6,n7,n8;
	      
	      	Ax = Param("x_ax", 0, 0, 1980, 20);          Ay = Param("y_ay", 0, 0, 1024, 20);

	
	EIOWOrigin(EIOWx,EIOWy);

	EIOW_Frame(EIOWx + 20, EIOWy + 80 , EIOWx + 650 , EIOWy + 515); // 30, 0, 30, 700, 180, colorWhite, colorblack(30, 0, 30, WITDTH, HIGHT, colorWhite, colorblack )
	
	
	n1 = EIOWEditNumber(1,0, 25, 100, 80, 25, colorBlue, colorYellow);
		GuiSetColors( 1, 1, 5, colorWhite, colorDarkGreen, colorLightGrey );
	
    EMAQW1 =EIOW_BOX( "" , 210, 400, 125, 370,  colorYellow, colorRed , colorWhite , "Tahoma", 10, 800 );
  

	
	}
	
	
		

// postion 
EIOWx = Param("x_origin", 20, 0, 1980, 20);
EIOWy = Param("y_origin", 20, 0, 1024, 20);
EIOW = ParamToggle("Show EIOW_CLC", "No|Yes", 1);

if (EIOW) {
	
	EIOW_CLC(EIOWx+80, EIOWy+80);
	
}

the first textbox does not have BorderColor , textcolor and BackColor

the second it has it all

I need to be able to use the color with the first box as box 2

this my issue

thank you

hi all and happy days

function EIOWEditNumber( idEdit, initialValue, x, y, width, height, textColor, bgColor )
{  // this function hold the text for the next restart of Amibroker
  global _x0, _y0;
  local rc ;

  x = x + _x0;     y = y + _y0;
  rc = GuiEdit( idEdit, x, y, width, height, notifyHitReturn ); //

  ID = GuiGetEvent( 0, 0 );     event = GuiGetEvent( 0, 1 );
  if( ID == idEdit ) StaticVarSetText( "sV" + Name() + idEdit,  GuiGetText( idEdit ), 1 );

  if( rc == guiNew )
  {  
      txt = StaticVarGettext( "sV" + Name() + idEdit );
      GuiSetText( txt, idEdit );
  }

  GuiSetColors( idEdit, idEdit, 1, colorWhite, colorDarkGreen, colorLightGrey );

  return GuiGetValue( idEdit );
}

i tried many time to let it work but i could not .

i use this one as AB

GuiSetColors( idEdit, idEdit, 1, colorWhite, colorDarkGreen, colorLightGrey );

but not working also to center the number in center of the text box.

thank you all

Please do read the manual
https://www.amibroker.com/f?guisetcolors

It says:

Please note that currently only buttons support custom colors and custom border. As for v6.21 Edit fields always use system look

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.