Solved

MM_LOMETRIC

Posted on 2002-03-29
8
971 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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month9 days, 7 hours left to enroll

623 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