Solved

MM_LOMETRIC

Posted on 2002-03-29
8
958 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
Industry Leaders: 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

749 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