Author |
Topic  |
|
anprosh
3 Posts |
Posted - Dec 01 2011 : 04:27:43
|
Help me, please.
I need to place crosshairs in front of ImageEnView1. I use Image1 for it.
All events of the mouse passed throw Image1 to ImageEnView1 correctly, Zoom and Pan works correctly, but the crosshairs are not visible.
I have reduced the sizes ImageEnView1, and have seen that crosshairs are visible in Image1 only.
For Image1 Transparent=true and is executed Bring to front.
Why I don't see the crosshairs in ImageEnView1 area?
+----------------:-----+-----+ | : | | | : | | |................:.....|-----| | : | | | ImageEnView1 : | | | : | | +----------------:-----+ | | Image1 | | | Transparent | | | Bring to front | | +----------------------------+
It is a part of an source code: ===============================
Graphics::TBitmap*Cross; Copy = new Graphics::TBitmap(); .....................
void __fastcall TForm1::ImageEnView1MouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { if (Shift.Contains(ssAlt)) { PatBlt(Cross->Canvas->Handle, 0, 0,Image1->Width, Image1->Height, WHITENESS); Cross->Canvas->MoveTo(X,0); Cross->Canvas->LineTo(X,Image1->Height); Cross->Canvas->MoveTo(0,Y); Cross->Canvas->LineTo(Image1->Width,Y); Image1->Canvas->Draw(0,0,Cross); Image1->Refresh(); } if (Shift.Contains(ssRight)) { //brightness, contrast ..................... } } ................
//-------------------------------------------------------------------- void __fastcall TForm1::Image1MouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { ImageEnView1MouseMove(ImageEnView1, Shift, X, Y); }
//-------------------------------------------------------------------- void __fastcall TForm1::Image1MouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { ImageEnView1MouseDown(ImageEnView1, Button, Shift, X, Y); }
//-------------------------------------------------------------------- void __fastcall TForm1::Image1MouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { ImageEnView1MouseUp(ImageEnView1,Button, Shift, X, Y); } |
|
fab
   
1310 Posts |
Posted - Dec 01 2011 : 07:46:14
|
I can suggest a solution that uses only ImageEn:
- define two field, like MouseX and MouseY.
- handle the event TImageEnView.OnMouseMove, just to save current mouse position and update ImageEn viewer:
procedure TForm1.ImageEnView1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
MouseX := X;
MouseY := Y;
ImageEnView1.Update();
end;
- handle the event TImageEnView.OnDrawBackBuffer, to draw the cross:
procedure TForm1.ImageEnVect1DrawBackBuffer(Sender: TObject);
begin
ImageEnView1.BackBuffer.Canvas.Pen.Color := clRed;
ImageEnView1.BackBuffer.Canvas.MoveTo(MouseX, 0);
ImageEnView1.BackBuffer.Canvas.LineTo(MouseX, ImageEnView1.BackBuffer.Height);
ImageEnView1.BackBuffer.Canvas.MoveTo(0, MouseY);
ImageEnView1.BackBuffer.Canvas.LineTo(ImageEnView1.BackBuffer.Width, MouseY);
end;
Hope this helps. |
 |
|
anprosh
3 Posts |
Posted - Dec 01 2011 : 10:36:08
|
Thanks for help, Fabrizio, it works Ok now. |
 |
|
|
Topic  |
|
|
|