Board index » delphi » WIN 1.5 PASCAL - LineTo function

WIN 1.5 PASCAL - LineTo function

Does anyone know how to use the lineto function or similar function to
draw a box(single line) to my screen.

thanks
dmh...@aol.com

 

Re:WIN 1.5 PASCAL - LineTo function


Quote
Dmhusa wrote:
> Does anyone know how to use the lineto function or similar function to
> draw a box(single line) to my screen.

Quoting myself:

Subject: Re: Function RGB - Pascal Win 1.5
Date:  Fri, 17 Sep 1999 17:45:07 +0200
From: Frederic <f...@altavista.net>

Quote
Hrymack wrote:
> Is there a way to draw line to form a box in TPW 1.5

You have to create a  window, find out its Device Context and draw to it.
The following program creates a generic window and draws a rectangle to it
which will be filled with pixels using the SetPixel and RGB functions:

uses owindows, wintypes, winprocs;
type
  TApp = object(TApplication)
           procedure InitMainWindow; virtual;
         end;
var
  Prog : TApp;

procedure TApp.InitMainWindow;
begin
  MainWindow := New(PWindow, Init(nil, 'MyTitle'))
end;

procedure DrawRectangle;
var
  DC : HDC;
  x, y : integer;
begin
  DC := GetDC(Application^.MainWindow^.HWindow);
  Rectangle(DC, 100, 100, 201, 201);

  for x := 101 to 199 do
    for y := 101 to 199 do
      SetPixel(DC, x, y, RGB(x, y, x div y))
end;

begin
  Prog.Init('');

  DrawRectangle;

  Prog.Run;
  Prog.Done
end.

Instead of Rectangle, you can use any other graphics function.

Note that if you minimize the window or another window becomes active, the
colorful rectangle will have disappeared when you reactivate your program.
To avoid that, you would have to create a user-defined window derived from
TWindow and write a virtual TWindow.Paint method.

Re:WIN 1.5 PASCAL - LineTo function


Quote
Dmhusa wrote:
> Does anyone know how to use the lineto function or similar function to
> draw a box(single line) to my screen.

Why not use the LineTo procedure?
{sample code}
Var DC:hDC;
Begin
 DC:=GetDC(Window);
 MoveTo(DC,0,0);        {move the cursor to a position without drawing}
 LineTo(DC,100,100);    {draws a line...}
 ReleaseDC(Window,DC);
End;

--
http://www.geocities.com/aibrain/        "AIBrain Home Page"

"To gain an initmate knowledge of our weapons of destruction,
please place both hands over your eyes and count to three..." -SC2

Other Threads