图片的缩放问题以及窗体中的控件变化 (100分)

  • 主题发起人 主题发起人 wkh_ak
  • 开始时间 开始时间
W

wkh_ak

Unregistered / Unconfirmed
GUEST, unregistred user!
我的程序在不同的分辨率的情况下,其主页面的图片的就不会完整,而且其中的控件的位置也就变化了,请教怎么样才能让图片根据分辨率的不同而缩放,控件的位置也能不变。完成其效果!
请大侠帮忙!
 
利用IMAGES控件中的Stretch:=true 并且让Align:=alClient就可以了呀
 
利用images控件中的Stretch:=true 并且让Align:=alClient可以解决这个问题,但是有个小毛病就是如果在这个图片上有其它的控件,那它的位置就不能和图片一起变化,所以你必须将其它的控件的top,left设置为一个定值才行。
这个问题你自己再好好试试!
 
image控件不能作为容器的,最好将image放在一个panel上,然后将其的控件也放在Panel上应该就可以了。
image和panel的align属性都设为alClient.
 
Stretch:=true 并且让Align:=alClient
 
Stretch:=true ;Align:=alClient
 
使用archor属性。
 
说的方法都不行呀,达不到要求!
 
用stretchBlt函数最简单。
 
to yyii_yyii:stretchBlt函数到底怎么呀?
能详细说吗?
谢谢!
 
to wkh_ak:
就是Win32的API啊,在GDI32中的。下面的完整函数说明
BOOL StretchBlt(
HDC hdcDest, // handle to destination DC
int nXOriginDest, // x-coord of destination upper-left corner
int nYOriginDest, // y-coord of destination upper-left corner
int nWidthDest, // width of destination rectangle
int nHeightDest, // height of destination rectangle
HDC hdcSrc, // handle to source DC
int nXOriginSrc, // x-coord of source upper-left corner
int nYOriginSrc, // y-coord of source upper-left corner
int nWidthSrc, // width of source rectangle
int nHeightSrc, // height of source rectangle
DWORD dwRop // raster operation code
);
Parameters
hdcDest
[in] Handle to the destination device context.
nXOriginDest
[in] Specifies the x-coordinate, in logical units, of the upper-left corner of the destination rectangle.
nYOriginDest
[in] Specifies the y-coordinate, in logical units, of the upper-left corner of the destination rectangle.
nWidthDest
[in] Specifies the width, in logical units, of the destination rectangle.
nHeightDest
[in] Specifies the height, in logical units, of the destination rectangle.
hdcSrc
[in] Handle to the source device context.
nXOriginSrc
[in] Specifies the x-coordinate, in logical units, of the upper-left corner of the source rectangle.
nYOriginSrc
[in] Specifies the y-coordinate, in logical units, of the upper-left corner of the source rectangle.
nWidthSrc
[in] Specifies the width, in logical units, of the source rectangle.
nHeightSrc
[in] Specifies the height, in logical units, of the source rectangle.
dwRop
[in] Specifies the raster operation to be performed. Raster operation codes define how the system combines colors in output operations that involve a brush, a source bitmap, and a destination bitmap.
See BitBlt for a list of common raster operation codes.

Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero.

Windows NT/2000/XP: To get extended error information, call GetLastError.

Remarks
StretchBlt stretches or compresses the source bitmap in memory and then copies the result to the destination rectangle. This bitmap can be either a compatible bitmap (DDB) or the output from CreateDIBSection. The color data for pattern or destination pixels is merged after the stretching or compression occurs.

When an enhanced metafile is being recorded, an error occurs (and the function returns FALSE) if the source device context identifies an enhanced-metafile device context.

If the specified raster operation requires a brush, the system uses the brush currently selected into the destination device context.

The destination coordinates are transformed by using the transformation currently specified for the destination device context; the source coordinates are transformed by using the transformation currently specified for the source device context.

If the source transformation has a rotation or shear, an error occurs.

If destination, source, and pattern bitmaps do not have the same color format, StretchBlt converts the source and pattern bitmaps to match the destination bitmap.

If StretchBlt must convert a monochrome bitmap to a color bitmap, it sets white bits (1) to the background color and black bits (0) to the foreground color. To convert a color bitmap to a monochrome bitmap, it sets pixels that match the background color to white (1) and sets all other pixels to black (0). The foreground and background colors of the device context with color are used.

StretchBlt creates a mirror image of a bitmap if the signs of the nWidthSrc and nWidthDest parameters or if the nHeightSrc and nHeightDest parameters differ. If nWidthSrc and nWidthDest have different signs, the function creates a mirror image of the bitmap along the x-axis. If nHeightSrc and nHeightDest have different signs, the function creates a mirror image of the bitmap along the y-axis.

Not all devices support the StretchBlt function. For more information, see the GetDeviceCaps.

ICM: No color management is performed when a blit operation occurs.

Windows 98/Me, Windows 2000/XP: When used in a multiple monitor system, both hdcSrc and hdcDest must refer to the same device or the function will fail. To transfer data between DCs for different devices, convert the memory bitmap to a DIB by calling GetDIBits. To display the DIB to the second device, call SetDIBits or StretchDIBits.


 
to yyii_yyii:我英语学的不好,还是看不懂怎么用?你能给我写个例子吗?
我的要求是控件不会因为分辨率的变化而它的位置不会变化!
 
to wkh_ak:
你要的到底是图伸缩还是控件位置动态调整啊?要是后者的话,MS可是提供了大量的
函数的喔,看看MSDN/Windows development/SDK document/user interface下的
说明即可,基本就是api调用,不用写什么代码。
 
to yyii_yyii:我的程序是在800*600的分辨率中做的,但现在在其它的分辨率中控件的位置就乱了,所以我的要求也可以说是控件的动态调整,多多请教,谢谢!
 
控件位置的动态调整,一般是需要在控件的父控件的OnResize事件中写代码处理的。
如果仅是主界面图片在高分辨率下显示不全的问题,完全可以通过TImage控件的Stretch属性来处理,不过TImage好像需要放在TPanel控件上好处理一些。
 
Stretch:=true 并且让Align:=alClient

================
怎么会不行呢?
 
to wkh_ak:
调整位置不是有MoveWindow、SetWindowPos等等函数吗?直接调用即可,写一个布局
函数,根据分辨率和字体调整即可,很简单的。
 
http://www.delphibbs.com/delphibbs/dispq.asp?lid=2332387
 
想不明白,也没遇到这种怪事:每个控件都有它自己的TOP和Left,也就是说位置是相对于窗口而固定不变的了,怎么可能因这为分辨率变了,控件的“位置就乱了”呢? 不明白。
 
后退
顶部