TPW shapes/lines 
Author Message
 TPW shapes/lines

Hi.

I've been trying to figure out how to draw basic polygons and straight
lines in TPW.  I've looked in help and the manuals but I just can't
understand it (please excuse my feeble mental capacity at the moment).
There was one example file, TPW/DOCDEMOS/COLLECT4.PAS, that demonstrated
the use of ellipses and rectangles but I found it difficult to read.

What I would like is if someone could email me a source that clearly
demonstrates how to draw shapes and lines so that I can see how it's
done. And remember, I'm using Turbo Pascal for WINDOWS.

Thanks a lot. :c)

--
 _______________________________________________
|   Sam Jones   | "You can't harm me! My wings  |
+------aka------+  are like a shield of steel!" |
| Flash  Gordon |                    ---Batfink |
 



Wed, 18 Jun 1902 08:00:00 GMT  
 TPW shapes/lines

Quote:

> I've been trying to figure out how to draw basic polygons and straight
> lines in TPW.  I've looked in help and the manuals but I just can't
> understand it (please excuse my feeble mental capacity at the moment).
> There was one example file, TPW/DOCDEMOS/COLLECT4.PAS, that demonstrated
> the use of ellipses and rectangles but I found it difficult to read.

> What I would like is if someone could email me a source that clearly
> demonstrates how to draw shapes and lines so that I can see how it's
> done. And remember, I'm using Turbo Pascal for WINDOWS.

>

 I'm assuming by the lack of response that either nobody knows the answer or
nobody wants to reply because they think it's some kind of assignment or
something.

Well, I'm wise enough to know not to ask anyone here to do my work for me,
I'm asking for this example because I desparately want to write programs
that draw patterns and shapes (wireframes of 3d obects and such like) but I
haven't a clue about how to draw lines in TPW. All I need is to know how to
implement the drawing window and what sort of commands to use to draw a line
from point A to point B.

So, please, if somebody knows how to draw in TPW, help me out?

--
 _______________________________________________
|   Sam Jones   | "You can't harm me! My wings  |
+------aka------+  are like a shield of steel!" |
| Flash  Gordon |                    ---Batfink |
 



Wed, 18 Jun 1902 08:00:00 GMT  
 TPW shapes/lines

: > I've been trying to figure out how to draw basic polygons and straight
: > lines in TPW.  I've looked in help and the manuals but I just can't
: > understand it (please excuse my feeble mental capacity at the moment).
: > There was one example file, TPW/DOCDEMOS/COLLECT4.PAS, that demonstrated
: > the use of ellipses and rectangles but I found it difficult to read.
: >
: > What I would like is if someone could email me a source that clearly
: > demonstrates how to draw shapes and lines so that I can see how it's
: > done. And remember, I'm using Turbo Pascal for WINDOWS.

:  I'm assuming by the lack of response that either nobody knows the answer or
: nobody wants to reply because they think it's some kind of assignment or
: something.

       I think the problem may be the number of people
using TPforW is but a small fraction of the readers.
       But I don't see why the graphics library should
be different from TP6.0, can't you even draw one line?

: Well, I'm wise enough to know not to ask anyone here to do my work for me,
: I'm asking for this example because I desparately want to write programs
: that draw patterns and shapes (wireframes of 3d obects and such like) but I
: haven't a clue about how to draw lines in TPW. All I need is to know how to
: implement the drawing window and what sort of commands to use to draw a line
: from point A to point B.
: So, please, if somebody knows how to draw in TPW, help me out?

        I think more examples would be available if you
can establish that the same statements, like DRAW or
LINE, or CIRCLE as used in TP6.0 will work.
        I didn't read your original article because
I don't have TPW, sorry.
        If you want to email me, I can give you some
TP6.0 graphics source.

Ken Fischer

---



Wed, 18 Jun 1902 08:00:00 GMT  
 TPW shapes/lines


writes

Quote:

>       I think the problem may be the number of people
>using TPforW is but a small fraction of the readers.
>       But I don't see why the graphics library should
>be different from TP6.0, can't you even draw one line?

TP is BGI based real mode, TPW writes windows programs only.

Quote:

>: Well, I'm wise enough to know not to ask anyone here to do my work for me,
>: I'm asking for this example because I desparately want to write programs
>: that draw patterns and shapes (wireframes of 3d obects and such like) but I
>: haven't a clue about how to draw lines in TPW. All I need is to know how to
>: implement the drawing window and what sort of commands to use to draw a line
>: from point A to point B.
>: So, please, if somebody knows how to draw in TPW, help me out?

You need to have a look at the LineTo and MoveTo functions (In WinProcs
I think - but the helpfile should ..err.. help).

The windows functions need a "Device Context" to be able to draw which
you either need to create "CreateDC" and then destroy "DeleteDC" these
as required or, if you already have a DC for a window use "GetDC" and
"ReleaseDC" - windows only has so many resources and you an run out of
them.

--

Never curse the Crocodile's mother before crossing the river



Wed, 18 Jun 1902 08:00:00 GMT  
 TPW shapes/lines

Quote:

>> What I would like is if someone could email me a source that clearly
>> demonstrates how to draw shapes and lines so that I can see how it's
>> done. And remember, I'm using Turbo Pascal for WINDOWS.
> I'm assuming by the lack of response that either nobody knows the
answer or
>nobody wants to reply because they think it's some kind of assignment
or
>something.

Not exactly. For one instance, I didn't know what you were talking
about. What code do you have, and what was is supposed to do?
Furthermore, I don't mail in response. And I don't supply sources.

Quote:
>Well, I'm wise enough to know not to ask anyone here to do my work for
me,
>I'm asking for this example because I desparately want to write
programs
>that draw patterns and shapes (wireframes of 3d obects and such like)
but I
>haven't a clue about how to draw lines in TPW. All I need is to know
how to
>implement the drawing window and what sort of commands to use to draw a
line
>from point A to point B.

One of the manuals of TPW 1.5 starts with an example of a scribble
program. Work your way through it, it's very useful (in fact, it started
my career in Windows programming)

Quote:
>So, please, if somebody knows how to draw in TPW, help me out?

Take a look at MoveTo, LineTo, PolyLine etc. Lookup (in your on-line
help) an article called "(the) Graphical Device Interface" or "GDI",
which is quite explanatory, although not suitable for the newbee.
--
Zweitze de Vries
zweitze<at>iname<dot>com
When replying, please adjust reply address


Wed, 18 Jun 1902 08:00:00 GMT  
 TPW shapes/lines

Quote:


> > I've been trying to figure out how to draw basic polygons and straight
> > lines in TPW.  I've looked in help and the manuals but I just can't
> > understand it (please excuse my feeble mental capacity at the moment).
> > There was one example file, TPW/DOCDEMOS/COLLECT4.PAS, that demonstrated
> > the use of ellipses and rectangles but I found it difficult to read.

> > What I would like is if someone could email me a source that clearly
> > demonstrates how to draw shapes and lines so that I can see how it's
> > done. And remember, I'm using Turbo Pascal for WINDOWS.

> >

>  I'm assuming by the lack of response that either nobody knows the answer or
> nobody wants to reply because they think it's some kind of assignment or
> something.

> Well, I'm wise enough to know not to ask anyone here to do my work for me,
> I'm asking for this example because I desparately want to write programs
> that draw patterns and shapes (wireframes of 3d obects and such like) but I
> haven't a clue about how to draw lines in TPW. All I need is to know how to
> implement the drawing window and what sort of commands to use to draw a line
> from point A to point B.

> So, please, if somebody knows how to draw in TPW, help me out?

> --
>  _______________________________________________
> |   Sam Jones   | "You can't harm me! My wings  |
> +------aka------+  are like a shield of steel!" |
> | Flash  Gordon |                    ---Batfink |
>  

i'm using bpw (borland pascal 7.0).Hope the program will work with tpw.
you can add your own menu,icon... in bpw but i've deleted them to make
the program simplier.

{************************************************}
{                                                }
{   Demo program                                 }
{   Copyright (c) 1991 by Borland International  }
{                                                }
{************************************************}

{ "Generic" Windows application written in Turbo Pascal }

program Generic;

uses WinTypes, WinProcs;

const
  AppName = 'Generic';

const
  rgb_Red    = $000000FF;
  rgb_Green  = $0000FF00;
  rgb_Blue   = $00FF0000;
  rgb_Yellow = rgb_red + rgb_green;
  rgb_Purple = rgb_red + rgb_blue;
  rgb_Cyan   = rgb_green + rgb_blue;

procedure drawall(window:hwnd);
var
 dc:hdc;
 f:pchar;
 my_brush:hbrush;
 my_pen:hpen;
begin
 dc:=getdc(window);   {dc=inside of your window }

 my_brush:=createsolidbrush(rgb_red);
 my_pen:=createpen(ps_solid,0,rgb_purple);

 SelectObject(dc,my_pen);  {color of rectangle and line }
 SelectObject (dc,my_brush);   {color of inside of the rectangle }
 Rectangle (dc,90,70,150,120);

 setbkcolor (dc,rgb_red);
 settextcolor (dc,rgb_green);
 f:='deneme';
 textout (dc,91,71,f,6);

 moveto(dc,10,8);
 lineto(dc,30,35);

end;

function WindowProc(Window: HWnd; Message, WParam: Word;
  LParam: Longint): Longint; export;
var
  AboutProc: TFarProc;
  dc:hdc;
  x,y:integer;
begin
  WindowProc := 0;
  dc:=getdc(window);
  case Message of

    wm_activate:
      begin
        drawall(window);
        Exit;
      end;
    wm_lbuttondown:
      begin
        x:=loword(lparam);
        y:=hiword(lparam);
        lineto(dc,x,y);          {draw line from origin to x,y}
        Exit;
      end;
    wm_Destroy:
      begin
        PostQuitMessage(0);
        Exit;
      end;
  end;
  WindowProc := DefWindowProc(Window, Message, WParam, LParam);
end;

procedure WinMain;
var
  Window: HWnd;
  Message: TMsg;
const
  WindowClass: TWndClass = (
    style: 0;

    cbClsExtra: 0;
    cbWndExtra: 0;
    hInstance: 0;
    hIcon: 0;
    hCursor: 0;
    hbrBackground: 0;
    lpszMenuName: AppName;
    lpszClassName: AppName);
begin
  if HPrevInst = 0 then
  begin
    WindowClass.hInstance := HInstance;
    WindowClass.hIcon := LoadIcon(0 , idi_application );
    WindowClass.hCursor := LoadCursor(0, idc_arrow );
    WindowClass.hbrBackground := CreateSolidBrush(rgb_red);
    if not RegisterClass(WindowClass) then Halt(255);
  end;
  Window := CreateWindow(
    AppName,
    '  Window',
    ws_Overlapped + ws_sysmenu + ws_minimizebox ,
    200,
    100,
    200,
    200,
    0,
    0,
    HInstance,
    nil);
  ShowWindow(Window, CmdShow);
  UpdateWindow(Window);
  Drawall(Window);

  while GetMessage(Message, 0, 0, 0) do
  begin
    TranslateMessage(Message);
    DispatchMessage(Message);
  end;
  Halt(Message.wParam);
end;

begin
  WinMain;
end.



Wed, 18 Jun 1902 08:00:00 GMT  
 TPW shapes/lines

Quote:

>  I'm assuming by the lack of response that either nobody knows the answer or
> nobody wants to reply because they think it's some kind of assignment or
> something.

Also, there are a few chapters in the manuals that explain these things,
so you might try and reading those (assuming you have the manuals). I found
the explanations quite clear and easy to follow. Alternatively, try and
find a book on windows programming with TPW or BP 7.0 (might be difficult
by now). There is a lot more to windows than just drawing a few lines.

Quote:
> Well, I'm wise enough to know not to ask anyone here to do my work for me,
> I'm asking for this example because I desparately want to write programs
> that draw patterns and shapes (wireframes of 3d obects and such like) but I
> haven't a clue about how to draw lines in TPW. All I need is to know how to
> implement the drawing window and what sort of commands to use to draw a line
> from point A to point B.

Basically, what you do to draw a line from (xa,ya) to (xb, yb) is:
{assuming all proper declarations}

BEGIN
  dc := GetDc( HWindow);   {get a device context (dc) for...}
                           {...the window you want to draw in}
  MoveTo( dc, xa, ya);     {move to start of line}
  LineTo( dc, xb, yb);     {draw to end of line}
  ReleaseDc( HWindow, dc); {release dc (forget this and you will block the system}
END;

This assumes you know how to create a program with a window in TPW.
If you need anything more, get a book or the manuals, or spend time
with the examples and help files.
If this is enough, you shouldn't have had to ask it in the 1st place.

Regards,

Remco
--

Remco Vi?tor                           Department of Chemistry

                                        University of Glasgow
                                        Glasgow G12 8QQ
                                        U.K.



Wed, 18 Jun 1902 08:00:00 GMT  
 TPW shapes/lines



Quote:

> i'm using bpw (borland pascal 7.0).Hope the program will work with tpw.
> you can add your own menu,icon... in bpw but i've deleted them to make
> the program simplier.

> {************************************************}
> {                                                }
> {   Demo program                                 }
> {   Copyright (c) 1991 by Borland International  }

This copyright means that Borland International is the only one
authorized to post this program.


Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Linking lines and shapes

2. Q : Replacing ugly hourglass-shaped SQL -cursor?

3. Shapes in graphics mode?!?

4. Want to Use Graphical Shapes

5. Background Colour and Shapes kinda question

6. Text Cursor Shape

7. mouse cursor shape in bp7

8. Self-made mouse-shape over buttons ??

9. Read file line per line

10. Newbie question about moving thru table line by line

11. Can I turn 26 line mode to 50 line mode

12. Blank line between lines: HELP!

 

 
Powered by phpBB® Forum Software