Article View: alt.lang.basic
Article #19Re: a Visual Basic Question
From: Galen Raben
Date: Mon, 02 Nov 1992 18:39
Date: Mon, 02 Nov 1992 18:39
41 lines
2099 bytes
2099 bytes
In alt.lang.basic, bdwheele@silver.ucs.indiana.edu (Brian Wheeler) writes: >Is there anyway for VB to simulate sprites? I tried using a picture box on >top of another picture box, but the unpainted portion of the top box blocks >out the background picture. The reason why I'm wanting this is so I can write >a game...and its no fun if everything has to be rectangular! > Thanks in advance > Brian Wheeler >-- You can either use "oddpicture" a control from MicroHelp (1-800-922-3383 or 404/594-1185) or create your own "transparent pictures" using a BitBlt call to the Windows API: The API declarations are: Declare Function BitBlt Lib "Gdi" (ByVal HDestDC As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hSrcDC As Integer, ByVal Xsrc As Integer, ByVal Ysrc As Integer, ByVal dwRop As Long) As Integer '****NOTE: all on one line!!!! **** Global Const SRCCOPY = &HCC0020 Global Const SRCAND = &H8800C6 Global Const SRCINVERT = &H660046 The idea here is to create two picture controls- one with your icon (see thru areas are black), the other a "mask" of your icon (see thru areas white, all others black). Set the visibility property of the "mask" to false. You then You then BitBlt the form (or "background") area covered by the "icon" and the and the "mask" to your "icon" picture control. This makes the picture control essentially transparent. In your program the code looks something like: Done% = BitBlt(Mask1.Hdc,0,0,32,32,Form1.Hdc,Icon1.Left,Icon1.Top,SRCAND) Done% = BitBlt(Icon1.Hdc,0,0,32,32,Mask1.Hdc,0,0,SRCINVERT) Have fun... - Galen -
Technical Details
Message-ID:
<33680006@hpgrla.gr.hp.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!walter!bellcore!rutgers!ucla-cs!elroy.jpl.nasa.gov!sdd.hp.com!scd.hp.com!hpscdm!hplextra!hpfcso!hpgrla!galenrReferences:
<Bwxw81.8w4@usenet.ucs.indiana.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!walter!bellcore!rutgers!ucla-cs!elroy.jpl.nasa.gov!sdd.hp.com!scd.hp.com!hpscdm!hplextra!hpfcso!hpgrla!galenr From: galenr@hpgrla.gr.hp.com (Galen Raben) Newsgroups: alt.lang.basic Subject: Re: a Visual Basic Question Message-ID: <33680006@hpgrla.gr.hp.com> Date: 2 Nov 92 18:39:47 GMT References: <Bwxw81.8w4@usenet.ucs.indiana.edu> Organization: Hewlett-Packard, Greeley, CO Lines: 41