home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / os / mswindo / programm / misc / 4726 < prev    next >
Encoding:
Text File  |  1993-01-07  |  2.0 KB  |  80 lines

  1. Newsgroups: comp.os.ms-windows.programmer.misc
  2. Path: sparky!uunet!munnari.oz.au!titan!tmp_ip_070.trl.OZ.AU!rgarner
  3. From: rgarner@TRL.OZ.AU (ROSS GARNER)
  4. Subject: VB2 bug?
  5. Message-ID: <rgarner.4.0@TRL.OZ.AU>
  6. Summary: Losing pen data
  7. Lines: 68
  8. Sender: root@trl.oz.au (System PRIVILEGED Account)
  9. Organization: Telecom Research
  10. Date: Fri, 8 Jan 1993 00:49:27 GMT
  11.  
  12. I have found a problem when using some API functions with VB2. The code is 
  13. included below, but this is what happens:
  14.  
  15. 1. I create a pen and brush indirect that I can reference anywhere in 
  16. the program by using the assigned handle.
  17.  
  18. 2. I then draw a rectangle
  19.  
  20. 3. I then draw another rectangle in a dirrent location
  21.  
  22. At this point everything is OK
  23.  
  24. 4. If I include the VB command ForeColor=stuff between drawing the 2 
  25. rectangles then the pen information is lost and the second rectangle 
  26. uses a different pen.
  27.  
  28. Questions:  Why does this happen????
  29.         How can the forecolor command destroy? my pen indirect?
  30.         Is it a bug?
  31.         Has anyone else come across this?
  32.         What else destroys? my pen indirect?
  33.  
  34. Ross Garner
  35. Telecom Research Laboratories
  36.  
  37.  
  38. The Code:
  39.  
  40. DefInt A-Z
  41. Dim lp As pointapi
  42. Dim Brush As LogBrush
  43. Dim pen As LogPen
  44.  
  45. Sub Command1_Click ()
  46.     Cls
  47.     scalemode = 3           'set Vb mode to pixels
  48.  
  49.     '*** make brush ****
  50.     Brush.lbstyle = BS_HATCHED
  51.     Brush.lbcolor = RGB(255, 255, 5)
  52.     Brush.lbhatch = HS_FDIAGONAL
  53.     
  54.     '****make pen******
  55.     lp.px = 4           'set width of line
  56.     pen.lopnstyle = PS_dash
  57.     pen.lopnwidth = lp
  58.     pen.lopncolor = RGB(0, 0, 0)
  59.     
  60.     '*********select brush and pen*******
  61.     hBrush = CreateBrushIndirect(Brush)
  62.     hPen = CreatePenIndirect(pen)
  63.     ok = selectobject(hDC, hBrush)
  64.     ok = selectobject(hDC, hPen)
  65.     
  66.     ok = rectangle(hDC, 10, 10, 100, 100)       'draw first rect
  67.  
  68.     forecolor = RGB(34, 34, 34)
  69.  
  70.     ok = rectangle(hDC, 200, 10, 300, 100)         'draw second rect
  71.     
  72.     '*********delete objects**********
  73.     ok = DeleteObject(hBrush)
  74.     ok = DeleteObject(hPen)
  75.  
  76. End Sub
  77.  
  78. The end.........
  79. Ross Garner
  80.