G
Galen Somerville
The following code just shows a small portion of the overall Graphics on my
Sweep form. I set the Panel to
a medium Grey color so it stands out on a Windows Grey screen. The first
thing that should happen is it should be painted Black. It just stays medium
Grey !!!!
Any help would be appreciated.
GalenS
The Form_Load event just starts a short Timer1.
The Timer1 disables itself and does the following, among other stuff, before
things happen.
Form declares
Public PicDraw As Graphics
Public PictMap As Bitmap
PictDraw is a Panel and glngColors(1) is Black
With PictDraw
.Top = 0
.Left = 0
.Height = 450
.Width = gScreen.HorPixels '1024
End With
PictDraw.Visible = True
PicDraw = PictDraw.CreateGraphics
PictMap = New Bitmap(PictDraw.Width, PictDraw.Height, PicDraw)
PicDraw.Dispose()
PicDraw = Graphics.FromImage(PictMap)
Dim Sbrush As New
System.Drawing.SolidBrush(Color.FromArgb(glngColors(1)))
PicDraw.FillRectangle(Sbrush, 0, 0, PictDraw.Width, PictDraw.Height)
PictDraw.Invalidate()
bitmapflg = True
This is the Paint event, naturally.
Private Sub PictDraw_Paint(ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictDraw.Paint
If bitmapflg Then
e.Graphics.DrawImage(PictMap, e.ClipRectangle,
e.ClipRectangle, _
GraphicsUnit.Pixel)
End If
End Sub
This is a sub in a module. It stops at the AGAIN label so I can see what the
PictDraw panel looks like on screen. Then it draws tick marks at top and
bottom of panel.
It stops at the AGAIN1 label. Of course it doesn't work.
Public Sub SetIndex()
Dim X2, X1, Y1, Y2 As Short
Dim Incr As Single, p As New Pen(Color.Black)
Dim Index As Short, c As Color
Dim BackCol As Integer
Dim ForeCol As Integer
Dim Currfrm As Object
Dim CurrHgt As Integer
BackCol = glngColors(1)
ForeCol = glngColors(0)
Currfrm = frmSweep.PicDraw
CurrHgt = frmSweep.PictMap.Height
Incr = CSng(gScreen.HorPixels) / 16
gbut1flg = False
AGAIN:
System.Windows.Forms.Application.DoEvents()
If Not gbut1flg Then GoTo AGAIN 'Button1
Currfrm.clear(Color.FromArgb(BackCol))
p.Color = Color.FromArgb(ForeCol)
X1 = 0
Y1 = 0
X2 = X1
Y2 = Y1 + 10
For Index = 1 To 17 Step 1
Currfrm.DrawLine(p, X1, Y1, X2, Y2)
X1 = CSng(Index) * Incr
If Index = 16 Then X1 = gScreen.HorPixels - 1
X2 = X1
Next Index
X1 = 0
Y2 = CurrHgt
X2 = X1
Y1 = Y2 - 10
For Index = 1 To 17 Step 1
Currfrm.DrawLine(p, X1, Y1, X2, Y2)
X1 = CSng(Index) * Incr
If Index = 16 Then X1 = gScreen.HorPixels - 1
X2 = X1
Next Index
p.Dispose()
frmSweep.PictDraw.Invalidate()
gbut2flg = False
AGAIN1:
System.Windows.Forms.Application.DoEvents()
If Not gbut2flg Then GoTo AGAIN1 'Button2
End Sub
Sweep form. I set the Panel to
a medium Grey color so it stands out on a Windows Grey screen. The first
thing that should happen is it should be painted Black. It just stays medium
Grey !!!!
Any help would be appreciated.
GalenS
The Form_Load event just starts a short Timer1.
The Timer1 disables itself and does the following, among other stuff, before
things happen.
Form declares
Public PicDraw As Graphics
Public PictMap As Bitmap
PictDraw is a Panel and glngColors(1) is Black
With PictDraw
.Top = 0
.Left = 0
.Height = 450
.Width = gScreen.HorPixels '1024
End With
PictDraw.Visible = True
PicDraw = PictDraw.CreateGraphics
PictMap = New Bitmap(PictDraw.Width, PictDraw.Height, PicDraw)
PicDraw.Dispose()
PicDraw = Graphics.FromImage(PictMap)
Dim Sbrush As New
System.Drawing.SolidBrush(Color.FromArgb(glngColors(1)))
PicDraw.FillRectangle(Sbrush, 0, 0, PictDraw.Width, PictDraw.Height)
PictDraw.Invalidate()
bitmapflg = True
This is the Paint event, naturally.
Private Sub PictDraw_Paint(ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictDraw.Paint
If bitmapflg Then
e.Graphics.DrawImage(PictMap, e.ClipRectangle,
e.ClipRectangle, _
GraphicsUnit.Pixel)
End If
End Sub
This is a sub in a module. It stops at the AGAIN label so I can see what the
PictDraw panel looks like on screen. Then it draws tick marks at top and
bottom of panel.
It stops at the AGAIN1 label. Of course it doesn't work.
Public Sub SetIndex()
Dim X2, X1, Y1, Y2 As Short
Dim Incr As Single, p As New Pen(Color.Black)
Dim Index As Short, c As Color
Dim BackCol As Integer
Dim ForeCol As Integer
Dim Currfrm As Object
Dim CurrHgt As Integer
BackCol = glngColors(1)
ForeCol = glngColors(0)
Currfrm = frmSweep.PicDraw
CurrHgt = frmSweep.PictMap.Height
Incr = CSng(gScreen.HorPixels) / 16
gbut1flg = False
AGAIN:
System.Windows.Forms.Application.DoEvents()
If Not gbut1flg Then GoTo AGAIN 'Button1
Currfrm.clear(Color.FromArgb(BackCol))
p.Color = Color.FromArgb(ForeCol)
X1 = 0
Y1 = 0
X2 = X1
Y2 = Y1 + 10
For Index = 1 To 17 Step 1
Currfrm.DrawLine(p, X1, Y1, X2, Y2)
X1 = CSng(Index) * Incr
If Index = 16 Then X1 = gScreen.HorPixels - 1
X2 = X1
Next Index
X1 = 0
Y2 = CurrHgt
X2 = X1
Y1 = Y2 - 10
For Index = 1 To 17 Step 1
Currfrm.DrawLine(p, X1, Y1, X2, Y2)
X1 = CSng(Index) * Incr
If Index = 16 Then X1 = gScreen.HorPixels - 1
X2 = X1
Next Index
p.Dispose()
frmSweep.PictDraw.Invalidate()
gbut2flg = False
AGAIN1:
System.Windows.Forms.Application.DoEvents()
If Not gbut2flg Then GoTo AGAIN1 'Button2
End Sub