Article View: comp.os.ms-windows.programmer.misc
Article #2584VB2 bug?
From: ROSS GARNER
Date: Fri, 08 Jan 1993 00:49
Date: Fri, 08 Jan 1993 00:49
68 lines
2142 bytes
2142 bytes
I have found a problem when using some API functions with VB2. The code is
included below, but this is what happens:
1. I create a pen and brush indirect that I can reference anywhere in
the program by using the assigned handle.
2. I then draw a rectangle
3. I then draw another rectangle in a dirrent location
At this point everything is OK
4. If I include the VB command ForeColor=stuff between drawing the 2
rectangles then the pen information is lost and the second rectangle
uses a different pen.
Questions: Why does this happen????
How can the forecolor command destroy? my pen indirect?
Is it a bug?
Has anyone else come across this?
What else destroys? my pen indirect?
Ross Garner
Telecom Research Laboratories
The Code:
DefInt A-Z
Dim lp As pointapi
Dim Brush As LogBrush
Dim pen As LogPen
Sub Command1_Click ()
Cls
scalemode = 3 'set Vb mode to pixels
'*** make brush ****
Brush.lbstyle = BS_HATCHED
Brush.lbcolor = RGB(255, 255, 5)
Brush.lbhatch = HS_FDIAGONAL
'****make pen******
lp.px = 4 'set width of line
pen.lopnstyle = PS_dash
pen.lopnwidth = lp
pen.lopncolor = RGB(0, 0, 0)
'*********select brush and pen*******
hBrush = CreateBrushIndirect(Brush)
hPen = CreatePenIndirect(pen)
ok = selectobject(hDC, hBrush)
ok = selectobject(hDC, hPen)
ok = rectangle(hDC, 10, 10, 100, 100) 'draw first rect
forecolor = RGB(34, 34, 34)
ok = rectangle(hDC, 200, 10, 300, 100) 'draw second rect
'*********delete objects**********
ok = DeleteObject(hBrush)
ok = DeleteObject(hPen)
End Sub
The end.........
Ross Garner
Technical Details
Message-ID:
<rgarner.4.0@TRL.OZ.AU>Path:
arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!titan!tmp_ip_070.trl.OZ.AU!rgarnerShow Full Headers
Complete Article Headers
Newsgroups: comp.os.ms-windows.programmer.misc Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!titan!tmp_ip_070.trl.OZ.AU!rgarner From: rgarner@TRL.OZ.AU (ROSS GARNER) Subject: VB2 bug? Message-ID: <rgarner.4.0@TRL.OZ.AU> Summary: Losing pen data Lines: 68 Sender: root@trl.oz.au (System PRIVILEGED Account) Organization: Telecom Research Date: Fri, 8 Jan 1993 00:49:27 GMT