The Big Red Toolbox

S309PictureBox

A powerful implementation of PictureBox.

September 27, 1999

Copyright 1999 NS BASIC Corporation


Written by Terry Myhrer, September 1999

NS Basic is (c) NS Basic Corporation
Windows CE is (c) Microsoft Corporation

The S309PictureBox.ocx Version 1.8 provides a PictureBox ActiveX control that can:

The S309PictureBox maintains the picture being displayed as an image, which is not necessarily the same width and/or height as the S309PictureBox. You can have the S309PictureBox automatically size itself to the width and height of the image or have the image stretched or shrunk to the size of the S309PictureBox when displayed. All drawing and pixel manipulation is done on the image.

This is a beta control and will expire on November 1, 1999

Object Creation

addobject "s309.picturebox.1","btnSelect",5,5,20,20

Samples

Properties
Name Values Description
AnimationAvailable True|False Returns True if animation is available for the image displayed. (Read Only)
AnimationInterval 0-65535 Sets or returns a value indicating whether the PictureBox will animate the image displayed with the PlayingCard property The AnimationInterval is in milliseconds.Setting the AnimationInterval property to a value greater than 0 will enable the animation. 1000=one second. Currently only available with the PlayingCard property set to 62 (Haunted Castle), 63(Bubbling Fish), 64 (Cheating Hand), 65(Helpful Robot), with the WildCard property set to True, or with the PlayingCard property set to any of the face cards or 53 (the Joker).
Appearance -2, -1, 0, 1, 2 Sets or returns a value indicating the appearance of the PictureBox. The Appearance property has no effect if BorderStyle property is not set to 1.
Interactions between BorderStyle and Appearance properties. BorderStyle
0 1
Appearance 2 No Border 3D Raised Border (Tiles)
1 No Border 3D Raised Border (Soft)
0 No Border Single Line Border
-1 No Border 3D Sunken Border (Soft)
-2 No Border 3D Sunken Border (Tiles)
AutoRefresh True|False Sets or returns a value indicating whether the PictureBox will automatically refresh after image manipulation.
AutoSize True|False Sets or returns a value indicating whether the PictureBox will automatically change to the size of the image being displayed.
BackColor color Sets or returns the background color of the PictureBox.
BitmapOnClipboard True|False Returns True if there is a bitmap image on the clipboard. (Read Only)
BorderStyle 0, 1 Sets or returns a value indicating the border style of the PictureBox.Can be used with the Appearance property to display 3D borders.
BorderStyle Description
0 No Border
1 Single line border
Center 0, 1, 2, 3 Sets or returns a value indicating whether the PictureBox will automatically center the image being displayed in the PictureBox.
Center Horizontally Vertically
0 No No
1 Yes No
2 No Yes
3 Yes Yes
Clip True|False Sets or returns a value indicating whether the image should be clipped when it is loaded when used with the hBitmap, Picture, PlayingCard, ResourceBitmapID properties. Only a portion of the image is kept and it is not resized. Used with the ClipHeight, ClipLeft, ClipTop, and ClipWidth FillColor properties. You can increase the size of the overall image without resizing the existing image. The new area not covered by the clipped existing image will be filled with the color in the FillColor property.
ClipHeight integer Sets or returns the number of pixels from top edge of original image to bottom edge of image to clip. Used with the ClipImage method, Clip, ClipLeft, ClipTop, and ClipWidth properties.
ClipLeft integer Sets or returns the number of pixels from left edge of original image to left edge of image to clip. Used with the ClipImage method, Clip, ClipHeight, ClipTop, and ClipWidth properties.
ClipTop integer Sets or returns the number of pixels from top edge of original image to top edge of image to clip. Used with the ClipImage method, Clip, ClipHeight, ClipLeft, and ClipWidth properties.
ClipWidth integer Sets or returns the number of pixels from left edge of original image to right edge of image to clip. Used with the ClipImage method, Clip, ClipHeight, ClipLeft,  and ClipTop properties.
CommonBitmapID integer Sets or returns a value indicating which Common Controls Bitmap should or is being shown. Set CommonBitmapType property before setting CommonBitmapID property. Setting this property will cause the image to be loaded and displayed in the PictureBox.
CommonBitmapID CommonBitmapType
  -1 or 1 -2 or 2
  Bitmap Description
-1 (Read Only) No Bitmap No Bitmap
0 Cut Bitmap Large Icons Bitmap
1 Copy Bitmap Small Icons Bitmap
2 Paste Bitmap List Bitmap
3 Undo Bitmap Details Bitmap
4 Redo Bitmap Sort By Name Bitmap
5 Delete Bitmap Sort By Size Bitmap
6 File New Bitmap Sort By Date Bitmap
7 File Open Bitmap Sort By Type Bitmap
8 File Save Bitmap Parent Folder Bitmap
9 Print Preview Bitmap Net Connect Bitmap
10 Properties Bitmap Net Disconnect Bitmap
11 Help Bitmap New Folder Bitmap
12 Find Bitmap Illegal value
13 Replace Bitmap Illegal value
14 Print Bitmap Illegal value
CommonBitmapType integer Sets or returns a value indicating which Type Common Controls bitmap should or is being shown. Set CommonBitmapType property before setting CommonBitmapID property.
CommonBitmapType Description
-2 Disabled View Bitmaps
-1 Disabled Standard Bitmaps
0 No Bitmap
1 Enabled Standard Bitmaps
2 Enabled View Bitmaps
FillColor color Sets or returns the fill color to be used when manipulating an image in the PictureBox. This property defaults to the color white.
FillStyle 0, 1 Sets or returns the fill style to be used when manipulating an image in the PictureBox.
FillStyle Description
0 Solid - Will be filled in the color in the FillColor property.
1 Transparent - the background will show through.
hBitmap integer Sets or returns the HBITMAP of the image. This should only be used to set the hBitmap property of one S309PictureBox to the hBitmap property of another S309PictureBox. This is used to copy the image from one S309PictureBox to another S309PictureBox. Setting this property will cause the image to be loaded and displayed in the PictureBox.
Height integer Sets or returns the number of pixels from the top edge to the bottom edge of the PictureBox.
ImageBitsPerPixel integer Sets or returns a value indicating the number of bits per pixel (color depth) of the image.
Bits Per Pixel Number Of Colors
1 2
2 4
4 16
8 256
16 65,535
24 16,777,216
ImageHeight integer Returns the height of the image from the file. (Read Only)
ImageLoadBitsPerPixel integer Sets or returns a value indicating the number of bits per pixel (color depth) of the image to use when loading images with the Picture property. (If ImageLoadBufferSize = 0, ImageLoadBitsPerPixel might be ignored.)
Bits Per Pixel Number Of Colors
1 2
2 4
4 16
8 256
16 65,535
24 16,777,216
ImageLoadBufferSize integer Returns or sets the buffer size used when loading an image with the Picture property. (Default: ImageLoadBufferSize = 0, which will use the height and width from the file instead of ImageLoadMaxHeight and ImageLoadMaxWidth properties and will attempt to use the bits per pixel value from the file instead of ImageLoadBitsPerPixel property when loading images with the Picture property.
ImageLoaded True|False Returns True if the PictureBox currently has an image loaded. (Read Only)
ImageLoadMaxHeight integer Return or sets the maximum image height when loading images with the Picture property. (If ImageLoadBufferSize = 0, ImageLoadMaxHeight will be ignored.)
ImageLoadMaxWidth integer Return or sets the maximum image width when loading images with the Picture property.(If ImageLoadBufferSize = 0, ImageLoadMaxWidth will be ignored.)
ImageWidth integer Returns the width of the image from the file. (Read Only)
Invert True|False Sets or returns a value indicating whether the colors of the image will be inverted when loaded into the PictureBox when used with the hBitmap, Picture, PlayingCard, ResourceBitmapID properties.
Left integer Sets or returns the number of pixels from the left edge of the output window to the left edge of the PictureBox.
Mirror 0, 1, 2, 3 Sets or returns a value indicating whether the picture will be mirrored in the PictureBox when loading the image with the hBitmap, Picture, PlayingCard, ResourceBitmapID properties or the MirrorImage method.
Mirror Horizontally Vertically
0 No No
1 Yes No
2 No Yes
3 Yes Yes
MouseMovePoints 0, 1, 2 Sets or returns the mode of dealing with extra mouse move points.
MouseMovePoints Description
0 Do not capture or use extra mouse move points. This option takes the fewest CPU cycles.
1 Capture extra mouse move points and send them through the MouseDown event.This option takes the most CPU cycles.
2 Capture extra mouse move points and make them available to DrawMouseMoveLines,   DrawMouseMoveLinesEx, and GetMouseMovePoint methods, but do not send them through the MouseMove event. This option is the best trade off between CPU cycles and amount of detail in drawing.
MouseMovePointsCount integer Returns the number of mouse move points stored for the DrawMouseMoveLines,   DrawMouseMoveLinesEx, and GetMouseMovePoint methods. (Read Only)
Name string Returns the name of the PictureBox. (Read Only)
Overlay True|False Sets or returns a value indicating whether the image being loaded should be overlaid on the existing image when used with the hBitmap, Picture, PlayingCard, ResourceBitmapID properties.
OverlayLeft integer Sets or returns the number of pixels from left edge of original image to left edge of new image. Used with the Overlay and OverlayTop properties.
OverlayTop integer Sets or returns the number of pixels from top edge of original image to top edge of new image. Used with the Overlay and OverlayLeft properties.
OverlayTransparentColor -1, color Returns or sets the color to be used as a transparent color when overlaying the image. No transparent color will be used if this property is set to -1.
PenStyle 0, 1, 2 Sets or returns the pen style to be used when drawing a line with a width of 1. If the DrawWidth property  > 1 then the PenStyle property is assumed to be 1.
PenStyle Description
0 No Line
1 Solid Line
2 Dash Line
PenFillStyle 0, 1 Sets or returns the pen fill style to be used when manipulating an image in the PictureBox and the PenStyle property =  2.
PenFillStyle Description
0 Solid - Will be filled in the color in the BackColor property.
1 Transparent - the background will show through.
Picture string Set or Returns a string with name of image file.
Setting this property will cause the image to be loaded and displayed in the PictureBox.
Pixel(x, y) color Set or returns the color of the pixel in the image at the position specified by x and y. Note: The x and y are coordinates on the image which may or may not correspond to the coordinates of the PictureBox.
PlayingCard integer Sets or returns the numeric id of a playing card to display. Setting this property will cause the image to be loaded and displayed in the PictureBox.
PlayingCard Description AnimationAvailable HPC AnimationAvailable PPC
1-13 Ace through King of Clubs True (Jack, Queen, and King) False
14-26 Ace through King of Diamonds True (Jack, Queen, and King) False
27-39 Ace through King of Hearts True (Jack, Queen, and King) False
40-52 Ace through King of Spades True (Jack, Queen, and King) False
53 Joker True False
54 Blank card False False
55 Blank face card False False
56-59 Suit cards
(Clubs, Diamonds, Hearts, Spades)
False False
61 WIN32_WCE Horse card back (HPC)
Rocket Ship (HPC PRO)
Dragon card back (PPC)
False False
62 Haunted Castle card back (HPC)
Pyramid card back (PPC)
True True
63 Bubbling Fish card back (HPC)
? card back (PPC)
True True
64 Cheating Hand card back True True
65 Helpful Robot card back (HPC)
Clover card back (PPC)
True False
66 Sailboat card back False True
78 O card False False
79 X card False False
80 Ghost card False False
Resize True|False Sets or returns a value indicating the whether the image will be resized (stretched or shrunk) when loading the image with the hBitmap, Picture, PlayingCard, ResourceBitmapID properties.Used with the ResizeHeight and ResizeWidth properties.
ResizeHeight integer Sets or returns the number of pixels from top edge to bottom edge of the resized image.Used with the ResizeImage method, Resize and ResizeWidth properties.
ResizeWidth integer Set or returns the number of pixels from left edge to right edge of the resized image.Used with the ResizeImage method, Resize and ResizeHeight properties.
ResourceBitmapID integer Sets or returns the numeric resource id of a bitmap in an executable to display.
Set the ResourceFile property before setting this property. Setting this property will cause the image to be loaded and displayed in the PictureBox.
ResourceFile string Sets or returns a string with name of resource file (.dll, .ocx, .cpl, etc...) in which to get the bitmap resource from. Set the ResourceBitmapID property after setting this property.
ResourceFileLoaded True|False Returns a value indicating the whether a resource file has been successfully loaded. Set the ResourceBitmapID property before reading this property. (Read Only)
Rotate 0, 90, 180, 270 Sets or returns a value indicating the rotation of the picture in the PictureBox when loading the image with the hBitmap, Picture, PlayingCard, ResourceBitmapID properties or the RotateImage method.
Rotate Description
0 No rotation will be done
90 Rotate image 90 degrees clockwise
180 Rotate image 180 degrees clockwise
270 Rotate image 270 degrees clockwise
ScaleMode 3 Sets or returns a value indicating the Scale Mode of the PictureBox. Currently only Scale Mode 3 is supported..
ScreenBitsPerPixel integer Returns a value indicating the number of bit per pixel (color depth) of the physical screen. (Read Only)
Bits Per Pixel Number Of Colors
1 2
2 4
4 16
8 256
16 65,535
24 16,777,216
ScreenHeight integer Returns a value indicating the number of pixels from the top edge to the bottom edge of the physical screen. (Read Only)
ScreenLeft integer Returns the number of pixels from left edge of the physical screen to left edge of the PictureBox. (Read Only)
ScreenTop integer Returns the number of pixels from top edge of the physical screen to top edge of the PictureBox. (Read Only)
ScreenWidth integer Returns a value indicating the number of pixels from the left edge to the right edge of the physical screen.. (Read Only)
Scroll True|False Sets or returns a value indicating whether the image should be scrolled when it is loaded when used with the hBitmap, Picture, PlayingCard, ResourceBitmapID properties. Used with the ScrollX and ScrollY properties.
ScrollX integer Returns a value indicating the number of pixels to scroll the image horizontally.. Used with the Scroll and ScrollY properties and the ScrollImage method.
ScrollY integer Returns a value indicating the number of pixels to scroll the image vertically.. Used with the Scroll and ScrollX properties and the ScrollImage method.
Stretch True|False Sets or returns a value indicating whether the PictureBox will stretch (or shrink) the display of the image to the size of the PictureBox. This will not change the size of the image, but will strecth or shrink the display of it.
Tag variant User defined.
Top integer Set or returns the number of pixels from the top edge of the output window to the top edge of the PictureBox.
TransparentColor -1, color Returns or sets the color to be used as a transparent color when displaying the image. No transparent color will be used if this property is set to -1.
VersionMajor integer Returns the major version of the S309PictureBox (Read Only)
VersionMinor integer Returns the minor version of the S309PictureBox. (Read Only)
Visible True|False Sets or returns value indicating whether the PictureBox is visible.
WaitCursor True|False Set or returns a value indicating whether the PictureBox will display a Wait Cursor while loading, mirroring, saving, or rotating the image.
Width integer Set or returns the number of pixels from the left edge to the right edge of the PictureBox.
WildCard integer Sets or returns a value indicating whether a "WILD" indicator should appear on the image. This a intended to be used with the images displayed with the PlayingCard property. The indicator can be animated with the AnimationInterval property.
WildCard Description
0 No indicator
1 Horizontal Indicators
2 Vertical Indicators
3 Center Indicator
Events
Name   Description
Click   Standard Click event.
DblClick   Standard Double Click event.
GotFocus
GotFocusX
  Standard GotFocus event. Use GotFocusX in NS Basic
LostFocus
LostFocusX
  Standard LostFocus event.Use LostFocusX in NS Basic.
MouseDown button, shift, x, y PictureBox is contacted with stylus or input device.
MouseMove button, shift, x, y Stylus or input device is moved while in contact with the PictureBox.
MouseUp button, shift, x, y Stylus is lifted from PictureBox, or input device breaks contact with PictureBox.
VBCEAutoSize width, height Called when the PictureBox control needs to resize itself and VBCE container will not let it. The Width and Height properties of the PictureBox control should be set in this event.
Methods
Name Parameter(s) Description
AboutBox   Displays the About Box for the PictureBox control.
Animate   Does the animation of the image if the AnimationAvailable property is set to True..
CaptureScreen   Loads a copy of the physical screen into the image and displays it in the PictureBox.
ClipImage   Clips the image that is displayed in the PictureBox control using the ClipHeight, ClipLeft, ClipTop, ClipWidth, and FillColor properties.
Cls   Clears the image from the PictureBox control.
Copy   Copies the image from the PictureBox control to the clipboard. Returns True if an image was copied.
CreateImage width, height Creates an image of the specified size and of the color specified in the FillColor property.
DrawCircle x, y, radius, color, aspectratio Draws a circle centered on x, y with a radius of radius and the aspect ratio of aspectratio.  Set aspectratio to 1 for a normal circle. The circle is drawn with color color and filled in with the FillColor property. Used with FillStyle, FillColor, PenStyle, and PenFillStyle properties.
DrawLine fromX, fromY, toX, toY, color Draws a line from (fromX, fromY) to (toX, toY) with color. Use DrawRoundRect with arcwidth = 0 and archeight = 0 to draw a box.
DrawMouseMoveLine color Draws a line using the mouse move points with color.
DrawMouseMoveLineEx fromX, fromY, toX, toY, color Draws a line from (fromX, fromY) to the mouse move points stored to (toX, toY) with color.
DrawPoint x, y, color Draws a pixel at x, y with color color. This is the same as Pixel(x,y) = color
DrawPolygon points, color Draws a polygon of points vertices connected by straight lines. The polygon is drawn with color color and filled in with the FillColor property. The points can be from 2 to 20. The polygon is closed automatically by drawing a line from the last vertex to the first. Used with FillStyle, FillColor, PenStyle, and PenFillStyle properties and SetPointArray method.
DrawPolyLines points, color Draws a series of line by connecting the specified number of points. The lines are drawn with color color.  The points can be from 2 to 20. Used with FillStyle, FillColor, PenStyle, and PenFillStyle properties and SetPointArray method.
DrawRoundRect left, top, right, bottom, arcwidth, archeight, color Draws a rectangle with color color bounded by left, top and right, bottom with rounded corners of arcwidth width and archeight height. Setting arcwidth and archeight to 0 will draw a normal rectangle. The round rectangle is drawn with color color and filled in with the FillColor property. Used with FillStyle, FillColor, PenStyle, and PenFillStyle properties.
GetMouseMovePoint point, x, y Returns the x and y coordinates of point. Point can be from 0 to the value return from the MouseMovePoints property - 1.
IntensityBlue color Returns the blue intensity from a color.
IntensityGreen color Returns the green intensity from a color.
IntensityRed color Returns the red intensity from a color.
InvertImage   Inverts the colors of the image that is displayed in the PictureBox.
MirrorImage   Mirrors the image that is displayed in the PictureBox using the Mirror property setting.
Hide   Hides the PictureBox and sets the Visible property to False.
Move left, top, width, height Move the PictureBox to new left and top location and resizing to width and height..
Paste   Copies the image from the clipboard to the PictureBox control. Returns True if an image was pasted.
QBColor colorcode Returns a color based on the colorcode  used by earlier versions of Basic.
ColorCode Description
0 Black
1 Blue
2 Green
3 Cyan
4 Red
5 Magenta
6 Yellow
7 White
8 Gray
9 Light Blue
10 Light Green
11 Light Cyan
12 Light Red
13 Light Magenta
14 Light Yellow
15 Bright White
Refresh   Redraws the image in the PictureBox control..
RefreshDesktopWallpaper   Causes the Desktop to redraw the wallpaper.
ReleaseCapture   Deactivates the PictureBox to receive the all mouse input.
ResizeImage   Resizes the image in the PictureBox control using the ResizeHeight and ResizeWidth properties.
RGB red, green, blue Returns a color comprised of the red, green, and blue intensities.
RotateImage   Rotates the image that is displayed in the PictureBox using the Rotate property setting.
SaveImageToFile filename, filetype Save the image in the PictureBox as a .bmp file to the filename specified. Filename is a string, filetype is an integer. The path specified in the filename MUST already exist. Returns True if the file was saved, otherwise returns False.
filetype Description Extension That Should Be Used
0 Bitmap .bmp
ScrollImage   Scrolls the image in the PictureBox using the ScrollX and ScrollY properties.
SetCapture   Activates the PictureBox to receive the all mouse input.
SetFocus   Activates the PictureBox to receive the focus.
SetPointArray index, x, y Sets the pointarray index to x and y. Used with the DrawPolyLines and DrawPolygon methods. The index can be from 1 to 20.
Show   Makes the PictureBox visible and sets the Visible property to True.
ZOrder position Places the PictureBox control at the front or back of the z-order.
ZOrder Position 0 PictureBox will be placed at the front of the z-order
1 PictureBox will be placed at the back of the z-order.Unfortunately, using ZOrder 1 with NS Basic, the PictureBox is placed behind the output window.

Files Included

S309PictureBox.ocx - the ActiveX control

Files Included in the Documentation Zip file

S309PictureBox.html - the documentation (this file).

Files Included in the NS Basic Samples Zip file

S309PictureBox.nsb - sample program using S309PictureBox ActiveX control.
S309PictureBox Bitmap Resource.nsb - sample program using S309PictureBox ActiveX control to display bitmaps from resource files (some in ROM).
S309PictureBox Common Bitmap.nsb - sample program using S309PictureBox ActiveX control to display common bitmaps ( All in ROM).
S309PictureBox PlayingCard.nsb - sample program using S309PictureBox ActiveX control to display Playing Cards.
S309PictureBox Capture Control.nsb - sample program using S309PictureBox ActiveX control to capture the contents of another control.
S309PictureBox Drawing.nsb - sample program using some of the drawing methods.
S309 Pyramid Solitaire.nsb - a pyramid solitaire game.

Installation of PictureBox ActiveX control on Windows CE

Transfer the ocx file for your processor to the \Windows directory

Register the control on Windows CE by doing:

Start - Run - regsvrce \Windows\S309PictureBox.ocx

You should get "DllRegisterServer in \Windows\S309PictureBox.ocx Succeeded."

How to register objects on Palm-size devices:

- or -

Use NS Basic/CE's SHELLEXECUTE command. There's an example in the Handbook.

Installation of PictureBox ActiveX control on the Desktop

Transfer the desktop version of the S309Picturebox.ocx to the c:\Windows\system32 directory

Register the control on the desktop by doing:

Start - Run - regsvr32 c:\Windows\system32\S309PictureBox.ocx

You should get "DllRegisterServer in c:\Windows\system32\S309PictureBox.ocx Succeeded."

To use the desktop control with VBCE you need to do the following:

select "Control Manager" from "Windows CE" menu

select the correct device by clicking on it once

select "Add New Control" from the "control" menu

find the desktop control (c:\Windows\system32\S309PictureBox.ocx) and click on it.

Using the PictureBox ActiveX control in NS Basic

AddObject "S309.PictureBox.1", "picControl", xpos, ypos, width, height
picControl.Picture = "\Windows\Honey.2bp"

"picControl" can be any name
xpos is the x-coord
ypos is the y-coord
width is the width of the control
height is the height of the control

Using the PictureBox ActiveX control in NS Basic to do a screen capture and save it to a file.

AddObject "S309.PictureBox.1", "picControl", 0,0,0,0
picControl.CaptureScreen
picControl.SaveImageToFile "\Screen Capture.bmp",0

The latest version of the S309PictureBox ActiveX control can be found here.