Here is some code for you. You will need a command button and a picture box with the default names.
Option Explicit
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
'-----------------------------------------------------------------------------------------------------------------------
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
'-----------------------------------------------------------------------------------------------------------------------
Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, _
ByVal crColor As Long) As Long
'-----------------------------------------------------------------------------------------------------------------------
Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, _
ByVal nHeight As Long) As Long
'-----------------------------------------------------------------------------------------------------------------------
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
'-----------------------------------------------------------------------------------------------------------------------
Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
'-----------------------------------------------------------------------------------------------------------------------
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth _
As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) _
As Long
'-----------------------------------------------------------------------------------------------------------------------
Private Sub Command1_Click()
Dim hBmp As Long
Dim hdc As Long
Dim iX As Long
Dim iY As Long
Dim iZ As Long
hBmp = CreateCompatibleBitmap(Picture1.hdc, Picture1.ScaleWidth, 256)
hdc = CreateCompatibleDC(Picture1.hdc)
SelectObject hdc, hBmp
For iY = 0 To 255 'This fills the backgroung
iZ = 255 - iY
For iX = 0 To Picture1.ScaleWidth
SetPixel hdc, iX, iY, RGB(iY, iY, iZ)
Next
Next
For iY = 100 To 104 'This draws 5 Horizontal lines
For iX = 0 To Picture1.ScaleWidth
SetPixel hdc, iX, iY, RGB(0, 0, 0)
Next
Next
For iX = 100 To 104 'This draws 5 Vertical lines
For iY = 0 To 255
SetPixel hdc, iX, iY, RGB(255, 255, 255)
Next
Next
BitBlt Picture1.hdc, 0, 0, Picture1.ScaleWidth, 256, hdc, 0, 0, &HCC0020
Call DeleteDC(hdc)
Call DeleteObject(hBmp)
End Sub
Hope this helps.
If you choose to battle wits with the witless be prepared to lose.
![[machinegun] [machinegun] [machinegun]](/data/assets/smilies/machinegun.gif)
![[hammer] [hammer] [hammer]](/data/assets/smilies/hammer.gif)