|
-
Jan 1st, 2012, 03:56 PM
#1
Thread Starter
PowerPoster
[RESOLVED] [VB6] - How use Paint event?
how can i use the Paint event on VB6?
i have tried used before but with some problems on showing the image.
i know that the Refresh method is for call the Paint event. but i never use the Paint event with sucess. can anyone advice me?
-
Jan 1st, 2012, 04:27 PM
#2
Re: [VB6] - How use Paint event?
Are you using something to loop, such as a Do...Loop, or a Timer? Or is it just to display one frame? Paint should fire no matter what, and gets fired after Form_Load() has taken place. Personally I don't like using Refresh cause it's very slow. I only use it if it's highly needed. If you can, could you post the code you currently have so I may see what you are trying to achieve?
-
Jan 1st, 2012, 04:32 PM
#3
Thread Starter
PowerPoster
Re: [VB6] - How use Paint event?
 Originally Posted by Jacob Roman
Are you using something to loop, such as a Do...Loop, or a Timer? Or is it just to display one frame? Paint should fire no matter what, and gets fired after Form_Load() has taken place. Personally I don't like using Refresh cause it's very slow. I only use it if it's highly needed. If you can, could you post the code you currently have so I may see what you are trying to achieve?
sorry.. these is about Graphics(not games). and in these case is a frame with some if's conditions. and that if's depends on commands.
i have 1 sub that must be called every time that we change 1 property, but i need the best choice for speed up my code
-
Jan 1st, 2012, 04:36 PM
#4
Re: [VB6] - How use Paint event?
I know it's not about games. 
Are you using Bitblt or TransparentBlt by any chance?
-
Jan 1st, 2012, 04:37 PM
#5
Thread Starter
PowerPoster
Re: [VB6] - How use Paint event?
 Originally Posted by Jacob Roman
I know it's not about games.
Are you using Bitblt or TransparentBlt by any chance?
TransparentBlt() is the best, because i need take off the backcolor
-
Jan 1st, 2012, 04:45 PM
#6
Re: [VB6] - How use Paint event?
Here ya go This assumes you loaded a pic already into Picture1
vb Code:
Option Explicit Private Declare Function TransparentBlt Lib "msimg32.dll" (ByVal hdc 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 nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal crTransparent As Long) As Boolean Private Sub Form_Load() 'Assuming you got a pic loaded Picture1.AutoSize = True Picture1.AutoRedraw = True Picture1.Visible = False Picture1.ScaleMode = vbPixels frmMain.ScaleMode = vbPixels End Sub Private Sub Form_Paint() DoEvents TransparentBlt frmMain.hdc, 0, 0, 200, 200, Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, RGB(0, 0, 0) End Sub
And it works without a hitch.
-
Jan 1st, 2012, 04:47 PM
#7
Thread Starter
PowerPoster
Re: [VB6] - How use Paint event?
 Originally Posted by Jacob Roman
Here ya go  This assumes you loaded a pic already into Picture1
vb Code:
Option Explicit Private Declare Function TransparentBlt Lib "msimg32.dll" (ByVal hdc 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 nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal crTransparent As Long) As Boolean Private Sub Form_Load() 'Assuming you got a pic loaded Picture1.AutoSize = True Picture1.AutoRedraw = True Picture1.Visible = False Picture1.ScaleMode = vbPixels frmMain.ScaleMode = vbPixels End Sub Private Sub Form_Paint() DoEvents TransparentBlt frmMain.hdc, 0, 0, 200, 200, Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, RGB(0, 0, 0) End Sub
And it works without a hitch.
now i see my problem: the DoEvents method
now i can change the properties allways and the image is showed updated
thanks
-
Jan 1st, 2012, 04:55 PM
#8
Re: [VB6] - How use Paint event?
Np
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|