|
|
|
|
|
Dicas
|
|
Visual Basic (Imagem/Som/Multimídia)
|
|
|
Título da Dica: Ajustar o tamanho de uma imagem bitmap num PictureBox
|
|
|
|
Postada em 17/12/2002 por Spidey
'Adicione um PictureBox no Form 'Ativar a referência DirectX7 For Visual Basic Type Library "DX7VB.DLL"
Option Explicit Private DX As New DirectX7 Private DDRAW As DirectDraw7 Private Primary As DirectDrawSurface7 Private SurfDesc As DDSURFACEDESC2 Private picBMP As DirectDrawSurface7 Private Clipper As DirectDrawClipper
Private Sub Form_Load() Set DDRAW = DX.DirectDrawCreate("") DDRAW.SetCooperativeLevel Me.hWnd, DDSCL_NORMAL SurfDesc.ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE Set Primary = DDRAW.CreateSurface(SurfDesc) SurfDesc.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN Set picBMP = DDRAW.CreateSurfaceFromFile(App.Path & "\figura.bmp", SurfDesc) Set Clipper = DDRAW.CreateClipper(0) Clipper.SetHWnd Picture1.hWnd Primary.SetClipper Clipper
End Sub
Private Sub Picture1_Paint() Dim destRect As RECT, srcRect As RECT DX.GetWindowRect Picture1.hWnd, destRect picBMP.GetSurfaceDesc SurfDesc srcRect.Right = SurfDesc.lWidth srcRect.Bottom = SurfDesc.lHeight Primary.Blt destRect, picBMP, srcRect, DDBLT_WAIT
End Sub
|
|
|
|
|