VB   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了重拾VB6(26):color, picutre object, printing大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

来自MSDN-2001-OCT: Visual Tools and Languages/Visual studio 6.0 Documentation/Visual Basic Documentation/Using Visual Basic/ProgrAMMer’s Guide/Part 2: what Can You Do With Visual Basic/Working with Text and Graphics/

1. Color Value

(1) Visual Basic uses a consistent system for all color properties and graphics methods. A color is represented by a Long Integer,and this value has the same meaning in all contexts that specify a color.

(2) There are four ways to specify a color value at run time: RGB function,QBColor function,intrinsic constants,Enter a color value directly. 另外,还可以用system colors(随系统设定而变化)。

2. Color Palette

(1) Visual Basic displays metafiles using the default palette of 16 VGA colors.

(2) The hardware palette contains 256 entries defining the actual RGB values that will be displayed on screen. The system halftone palette is a predefined set of 256 RGB values made available by Windows itself. A logical palette is a set of up to 256 RGB values contained within a bitmap or other image.

Windows can draw using the 256 colors in the hardware palette. Twenty of @R_607_8270@ 256 colors,called static colors,are reserved by the system and cAnnot be changed by an application. Static colors include the 16 colors in the default VGA palette (the same as the colors defined by Visual Basic’s QBColor function),plus four additional shades of gray. The system halftone palette always contains @R_607_8270@ static colors.

The foreground window (the window with focus) determines the 236 nonstatic colors in the hardware palette. Each time the hardware palette is changed,all BACkground windows are redrawn using @R_607_8270@ colors. If the colors in a BACkground window’s logical palette don’t perfectly match those currently in the hardware palette,Windows will assign the closest match.

On true-color (16-million color) displays,Visual Basic always uses the correct color. On monochrome or 16-color displays,Visual Basic will dither BACkground colors and colors set with the FillColor property. Dithering is a process used to simulate colors not available from the video adapter and display driver.

With 256-color video drivers,you can use up to 256 colors with graphics methods. By default,the 256 colors available in Visual Basic are those in the system halftone palette. Although you can specify an exact color using the RGB function,the actual color displayed will be the closest match from the halftone palette.

Although the default palette for Visual Basic is the system halftone palette,you can also control the display of colors with the PaletteMode and Palette properties of forms,user controls,and user documents. In this case,the color match is much the same,except that colors will be matched to the closest color in the hardware palette.

(3) The PaletteMode property only applies to 256-color displays. On high-color or true-color displays,color SELEction is handled by the video driver using a palette of 32,000 or 16 million colors respectively. Even if you’re progrAMMing on a system with a high-color or true-color display,you still may want to set the PaletteMode,because many of your users may be using 256-color displays.

(4) 总之,为256色系统设计时,在调色板方面有许多需要额外虑的问题。

3. Using the Picture Object

(1) You could think of the Picture object as a invisible picture box that you can use as a staging area for images:

Private Sub Command1_Click()
   Dim objPic As Picture
   Set objPic = LoadPicture("Butterfly.gif")
   Set Picture1.Picture = objPic
End Sub

(2) There are lots of things you can do with bitmaps,icons,or metafiles in the Windows API,but the Picture object already does most of them for you.

There are now two completely different ways to paint graphics on a window (or blit). You can use BitBlt or StretchBlt on the hDC of an object,or you can use the PaintPicture method on the Picture object or property. If you have an Image control,you can only use PaintPicture because Image controls do not have an hDC.

There is no direct relationship between a Picture.Handle and a PictureBox.hDC. The hDC property of the picture box is the handle provided by the operaTing system to the device context of the picture box control. The Handle property of the Picture object is actually the handle of the GDI object that is contained in the Picture object.

4. PrinTing

(1) The code in your application determines the type and quality of print output available from your application. But the users’ printer drivers and printers also impact print quality.

(2) 从程序里打印有3种方法:printform,用打印机列表(控制面板里列出的)里的printer,或者用printer object.

其中printer object打印效果最好。不过它用起来也最麻烦,要写最多的代码,打图的时候也比较占资源。详见:PrinTing with the Printer Object。

大佬总结

以上是大佬教程为你收集整理的重拾VB6(26):color, picutre object, printing全部内容,希望文章能够帮你解决重拾VB6(26):color, picutre object, printing所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。