See Also Example
Action
Sets a point on an object to a specified color.
Syntax
[object.]PSet [Step](x, y)[,color]
Remarks
The PSet method has these parts:
Part Description
object Object (non-MDI form, picture box, or Printer object) on which point is to be drawn.
Step Keyword that specifies that the coordinates are relative to the current graphics position given by the CurrentX and CurrentY properties.
x, y Single-precision values indicating the horizontal and vertical coordinates of the point to set.
color RGB color specified for point. If omitted, the current foreground color is used. You can use the RGB function or QBColor function to specify the color.
The size of the point drawn depends on the DrawWidth property. When DrawWidth is 1, PSet sets a single pixel to the specified color. When DrawWidth is greater than 1, the point is centered on the specified coordinates.
The way the point is drawn depends on the setting of the DrawMode and DrawStyle properties.
When PSet executes, CurrentX and CurrentY are set to the point specified by the arguments.
Clear a single pixel with the PSet method by specifying the coordinates of the pixel and using BackColor as the color argument.
BackColor, ForeColor Properties
CurrentX, CurrentY Properties
DrawMode Property
DrawStyle Property
DrawWidth Property
RGB Function
QBColor Function
The PSet method example draws confetti on a form. To try this example, paste the code into the Declarations section of a form. Then press F5 and click the form.
Sub Form_Click ()
Dim CX, CY, Msg, XPos, YPos ' Declare variables.
ScaleMode = 3 ' Set ScaleMode to pixels.
DrawWidth = 5 ' Set DrawWidth.
ForeColor = QBColor(4) ' Set background to red.
FontSize = 24 ' Set point size.
CX = ScaleWidth / 2 ' Get horizontal center.
CY = ScaleHeight / 2 ' Get vertical center.
Cls ' Clear form.
Msg = "Happy New Year!"
CurrentX = CX - TextWidth(Msg) / 2 ' Horizontal position.
CurrentY = CY - TextHeight(Msg) ' Vertical position.
Print Msg ' Print message.
Do
XPos = Rnd * ScaleWidth ' Get horizontal position.
YPos = Rnd * ScaleHeight ' Get vertical position.
PSet (XPos, YPos), QBColor(Rnd * 15) ' Draw confetti.
DoEvents ' Yield for other processing.
Loop
End Sub