2024년 11월 4일 월요일

Gradient Color Timer Change

 



procedure TForm1.Gradation_Draw( angle : integer );

begin

  GRect.Fill.Gradient.Points[0].Color := GColor1;

  GRect.Fill.Gradient.Points[0].Offset := 0;


  GRect.Fill.Gradient.Points[1].Color := GColor2;

  GRect.Fill.Gradient.Points[1].Offset := 1;


  if IsAType then

  begin

    GRect.Fill.Gradient.StartPosition.X := 0.0;

    GRect.Fill.Gradient.StartPosition.Y := 0.0;

    GRect.Fill.Gradient.StopPosition.X :=  angle / 10;    

    GRect.Fill.Gradient.StopPosition.Y :=  1.0;

  end

  else

  begin

    GRect.Fill.Gradient.StartPosition.X := 0.0;

    GRect.Fill.Gradient.StartPosition.Y := 0.1;

    GRect.Fill.Gradient.StopPosition.X :=  1.0;

    GRect.Fill.Gradient.StopPosition.Y :=  angle / 10;   

  end;


  GRect.Repaint;

end;



//***************************************************************************************************************************

procedure TForm1.ColorTimer1Timer(Sender: TObject);

begin

  if ( R1 = $ff0000 ) and ( G1 = 0 ) and ( B1 < $0000ff ) then                           

    B1 := B1 + $000001


  else if (( 0 < R1 ) and ( R1 <= $ff0000 )) and ( G1 = 0 ) and ( B1 = $0000ff ) then     

    R1 := R1 - $010000


  else if ( R1 = 0 ) and ( G1 < $00ff00 ) and  ( B1 = $0000ff ) then                        

    G1 := G1 + $000100


  else if ( R1 = 0 ) and ( G1 = $00ff00 ) and (( 0 < B1 ) and ( B1 <= $0000ff ))  then       

    B1 := B1 - $000001


  else if ( R1 < $ff0000 ) and ( G1 = $00ff00 ) and ( B1 = $000000 )  then                  

    R1 :=  R1 + $010000


  else if ( R1 = $ff0000 ) and (( 0 < G1 ) and ( G1 <= $00ff00 )) and ( B1 = $000000 ) then  

    G1 := G1 - $000100


  else

    ColorTimer1.Enabled := FALSE;


  GColor1 := $FF000000 +  R1 + G1 + B1;

  Rectangle1.Fill.Color := GColor1;

end;

2024년 8월 29일 목요일

Post How to send a web page.

This method creates a temporary file called temp post request.html, puts parameters in it, and calls it using a web browser.


procedure OpenBrowserWithPostRequest;

var

  HTMLFileName, HTMLContent: string;

  HTMLFile: TextFile;

begin

  // temp HTML file

  HTMLFileName := ExtractFilePath( ParamStr(0)) + 'temp_post_request.html';


  // HTML file write

  HTMLContent :=

 '<html>' +

    '<body onload="document.forms[0].submit()">' +

    '<form action="http://127.0.0.1/exam1" method="POST">' +

    '<input type="hidden" name="param1" value="exam">' +

    '<input type="hidden" name="param2" value="1">' +

    '<input type="hidden" name="param3" value="3">' +

    '</form>' +

    '</body>' +

    '</html>';


  AssignFile( HTMLFile, HTMLFileName );

  Rewrite( HTMLFile );

  Write( HTMLFile, HTMLContent );

  CloseFile( HTMLFile );

  ShellExecute(0, 'open', PChar( HTMLFileName ), nil, nil, SW_SHOWNORMAL);

end;