Show tips for large size image in C ++ Builder

zhaozj2021-02-17  50

---- Using the TIMAGE control in C Builder to easily read and display image, but the TIMAGE control itself can not receive input focus, and there is no scroll bar, and the large image extends beyond the display area. When you need to strengthen the TIMAGE control. This article brings two most easy-to-real and effective way to meet the needs of different applications.

---- Method 1: Increase the scroll bar.

---- Increase the rolling strip can be implemented in the TIMAGE in the Tscrollbox control. Proceed as follows:

---- (1), put a TSCrollBox control in the window, adjust its size.

---- (2), setting the AutoScroll property of the TscrollBox control to True.

---- (3), in the Tscrollbox control is a TIMAGE control.

---- (4), set the properties of the TIMAGE control: AutoSize is true, Left is 0, top is 0. After the above, the image is larger than the display window, the scroll bar will self-movement, and if the image is smaller than the display window, the scroll strip automatically disappears, and the browse of the large image.

---- Method 2: Image roam.

---- Image roof refers to the movement of the image without the scroll bar, through the keyboard or the mouse control image, from the smaller display area to node the image of the image. The mouse control is explained as an example.

---- (1), put a TPANEL control in the window, adjust its size.

---- (2), in the TPANEL control is set up a TIMAGE control.

---- (3), the AutoSize property of the TIMAGE control is true, the LEFT property is 0, and the TOP attribute is 0.

---- (4), add two private variables in the class definition of TFORM1: int ix0, i0;

---- (5), respond to the TIMOUSEDOWN and ONMOUSEMOVE events.

Void __fastcall tform1 :: image1mousedown (TOBJECT * SENDER,

TMOUSEBUTTON button, TshiftState Shift, Int X, Int Y)

{

IX0 = x;

IY0 = Y;

}

Void __fastcall tform1 :: image1mousemove

(Tobject * Sender, TshiftState Shift, Int x, int y)

{

Int IdelTax, IDELTAY;

IF (Shift.Contains (SSLEFT))

{

IdelTax = x - ix0;

Ideltay = y- xi0;

IdelTay

Image1-> Left = IdelTax;

IF (IDELTAY) Image1-> Top = IdelTay;

}

}

---- (6), press the left button dragging when running, the image will follow.

---- (7), if there is a keyboard control, just refer to the code control code, and add the keyboard control.

---- (8), when the actual application is required, the boundary limit is required to ensure that the image will not be moved out of the display area.

---- The above two methods should be used in the same way in this person, and the effect is very good.

转载请注明原文地址:https://www.9cbs.com/read-28736.html

New Post(0)