I'm looking for speed here, and I need to refresh a picturebox as fast as possible.
Please post any alternatives to the .Refresh property!! :)
Thanks,
Jordan
Printable View
I'm looking for speed here, and I need to refresh a picturebox as fast as possible.
Please post any alternatives to the .Refresh property!! :)
Thanks,
Jordan
anything?
there's the redraw window API, it may be slightly fasterI've never bothered using it before so I don't know exactly how, I recon you can Ignore hRgnUpdate and fuRedraw, and that hWnd is the hWnd of the picture box you need to refresh and lprcUpdate is the rectangle you want to update (so you don't have to refresh the whole thing) if you set lprcUpdate to 0 then it'll probably do the whole thing.Code:Declare Function RedrawWindow Lib "user32" Alias (ByVal hwnd As Long, lprcUpdate As RECT, ByVal hrgnUpdate As Long, ByVal fuRedraw As Long) As Long
Yeah, If you set lprcUpdate to vbNull, hrgnUpdate to vbNull and fuRedraw to 0, it redraws the entire client area. It might be faster to update just a rectangle (in lprcUpdate), but this depends on what you are doing.
Send the WM_PAINT message. It's 3-4 times faster.
Code:Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_PAINT = &HF
Private Sub Command1_Click()
SendMessage Picture1.hwnd, WM_PAINT, Picture1.hDC, 0
End Sub