Solved

MM_LOMETRIC

Posted on 2002-03-29
8
931 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
  • 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
 
LVL 3

Expert Comment

by:SteveWaite
ID: 6907929
Same thing if you want to override Paint.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

895 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now