Solved

MM_LOMETRIC

Posted on 2002-03-29
8
966 Views
Last Modified: 2008-02-01
Hi all, I have procedure like this

procedure TForm1.Paint;
var
   // ...
begin
 inherited;

  // Some work with canvas

end;

Now I want to set canvas units to mm with

x:=SetMapMode(Canvas.handle, MM_LOMETRIC);

so, when I put this line in TForm1.Paint procedure, application stucked. Where should I do this, and how ?

Cheers,
Zeko
0
Comment
Question by:zeko
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 3

Expert Comment

by:SteveWaite
ID: 6906380
have a go with these examples..
procedure TForm1.FormPaint(Sender: TObject);
var
  OldVPOrigin, OldOrigin: TPoint
begin
  with PaintBox1.Canvas do
  begin
    SetMapMode(Handle, MM_LOMETRIC);

  //  SetViewPortOrgEx(Handle, 0, 0, @OldVPOrigin);
  //  SetWindowOrgEx(Handle, 0, 0, @OldOrigin);
  //  SetViewPortExtEx(Handle, FinalWidth, FinalHeight, @OldViewPortExtent);
  //  SetWindowExtEx(Handle, BackBuf.Width, BackBuf.Height, @OldWindowExtent);

    SetWindowExtEx(Handle, BackBuf.Width, BackBuf.Height, nil);
    SetViewPortExtEx(Handle, FinalWidth, FinalHeight, nil);

    CopyMode := cmSrcCopy;
    BitBlt(Handle, 0, 0, BackBuf.Width, BackBuf.Height, ABitmap.Canvas.Handle, 0, 0, SRCCOPY);

    //  SetViewPortOrgEx(Handle, OldVPOrigin.X, OldVPOrigin.Y, nil);
    //  SetWindowOrgEx(Handle, OldOrigin.X, OldOrigin.Y, nil);
    //  SetViewPortExtEx(Handle, OldViewPortExtent.X, OldViewPortExtent.Y, nil);
    //  SetWindowExtEx(Handle, OldWindowExtent.X, OldWindowExtent.Y, nil);
    //  Brush.Style := bsSolid;
    //  Font.Color := clYellow;
    //  TextOut(20, 20, 'hello');
  end;
end;

Regards,
Steve
0
 

Author Comment

by:zeko
ID: 6906804
I am working with form canvas not (PaintBox) and my Paint function declaration is like this:

TForm1 = class(TForm)
   procedure FormCreate(Sender: TObject);
   procedure FormDestroy(Sender: TObject);
   procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
   procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
   procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
    procedure Button1Click(Sender: TObject);
 private
   // ...
 public
   procedure Paint; override;

Sorry but I don't think that u answered this question.
0
 
LVL 3

Expert Comment

by:SteveWaite
ID: 6907919
Then just do it this way:


TForm1 = class(TForm)
  procedure FormPaint(Sender: TObject);

procedure TForm1.FormPaint(Sender: TObject);
var
  PrevMapMode: Integer;
begin
 with Canvas do // that means Form1.Canvas
 begin
   PrevMapMode := SetMapMode(Handle, MM_LOMETRIC);


Now each logical unit is mapped to 0.1 millimeter. Positive x is to the right; positive y is up.

If the function succeeds, the return value identifies the
previous mapping mode.


Steve
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:SteveWaite
ID: 6907929
Same thing if you want to override Paint.
0
 
LVL 3

Accepted Solution

by:
SteveWaite earned 30 total points
ID: 6907961
as in:
procedure TForm1.Paint;
var
  // ...
begin
 inherited;

  with Canvas do // that means Form1.Canvas
  begin
    SetMapMode(Handle, MM_LOMETRIC);

 // Some work with canvas

end;
0
 

Author Comment

by:zeko
ID: 6908671
Well, it's not working in override Paint, I tested it again. I've got window with canvas background same as my desktop background.
0
 

Author Comment

by:zeko
ID: 6908673
Ops, I think that I found mistake, I used DoubleBuffered := true;  in my Form.OnCreate event.

Thanks SteveWaite, here is your earned points. You made a effort to help me.
0
 
LVL 3

Expert Comment

by:SteveWaite
ID: 6908846
Thanks!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question