There is an image of a map, such as England. Using the Image component, how to make on OnMouseUp passing new X, Y (ShiftState) coordinates to change image coordinates? Just like in Google Maps, only without scaling: change location, move with mouse.

    1 answer 1

    Well, if you mean moving the image around the TImage component with the mouse, then this can be done, for example, like this:

     var bmp:TBitMap; // ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΠ°, загруТаСмая Π² ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½Ρ‚ TImage procedure TForm1.FormShow(Sender: TObject); // здСсь ΠΏΠ΅Ρ€Π²ΠΎΠ½Π°Ρ‡Π°Π»ΡŒΠ½Π°Ρ Π·Π°Π³Ρ€ΡƒΠ·ΠΊΠ° begin bmp:=Tbitmap.Create; bmp.LoadFromFile('yourImage.bmp'); // Π·Π°Π³Ρ€ΡƒΠΆΠ°Π΅ΠΌ ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΡƒ( ΠΌΠΎΠΆΠ½ΠΎ ΠΈ Π² Π΄Ρ€ΡƒΠ³ΠΎΠΌ событии) image1.Canvas.Draw(0,0,bmp); end; procedure TForm1.Image2MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin if ssleft in shift then // Ссли Π½Π°ΠΆΠ°Ρ‚Π° лСвая ΠΊΠ½ΠΎΠΏΠΊΠ° ΠΌΡ‹ΡˆΠΈ, Ρ‚ΠΎ... begin // ΠΎΡ‡ΠΈΡ‰Π°Π΅ΠΌ ΠΊΠ°Π½Π²Ρƒ ΠΎΡ‚ Ρ€Π°Π½Π΅Π΅ Π·Π°Π³Ρ€ΡƒΠΆΠ΅Π½Π½ΠΎΠ³ΠΎ рисунка PatBlt(image1.Canvas.Handle,0,0,image1.ClientWidth,image1.ClientHeight,WHITENESS); // пСрСрисовываСм ΠΊΠ°Π½Π²Ρƒ с Π½ΠΎΠ²Ρ‹ΠΌΠΈ ΠΊΠΎΠΎΡ€Π΄ΠΈΠ½Π°Ρ‚Π°ΠΌΠΈ рисунка image1.Canvas.Draw(x,y,bmp); end; 

    PS

    Please do not interfere with all in one pile: Google Maps, Delphi, drawings and motion on the canvas. You are very confused by this people. Simply form your question correctly ...