Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21237

[VB6] - 1 error that i don't know how fix it:(

$
0
0
heres my ShowImage sub:
Code:

Private Sub ShowImage()
    Dim x As Long
    Dim y As Long
    Dim lngImageWidth As Long
    Dim lngImageHeight As Long
    Dim TempPosX As Long
    Dim TempPosY As Long
    Dim rec As RECT
   
    'On Error Resume Next
    If blnShowed = False Then Exit Sub
   
   
    If strFileName = "" Or UserControl.hdc = 0 Then Exit Sub
    Set GRP = New Class1
    'the auto size
    lngImageWidth = PicAnimation(lngActualSubImage).ScaleWidth
    lngImageHeight = PicAnimation(lngActualSubImage).ScaleHeight

    If blnAutoSize = True Then
        UserControl.Width = (lngImageWidth + IFF(BorderStyle = BorderFixed, 4, 0)) * Screen.TwipsPerPixelX
        UserControl.Height = (lngImageHeight + IFF(BorderStyle = BorderFixed, 4, 0)) * Screen.TwipsPerPixelY
        If ColisionObjectList <> ObjectListColisionNone Then
            If ColisionDetectType = ColisionDetectionManualy Then
                L1 = Extender.left + LimColLeft
                T1 = Extender.top + LimColTop
                W1 = LimColWidth
                H1 = LimColHeight
            Else
                L1 = lngOldPosX
                T1 = lngOldPosY
                W1 = Extender.Width
                H1 = Extender.Height
            End If
        End If
    End If
    picGraphicsEffects.Picture = Nothing
    'clean the image and show it
    picGraphicsEffects.BackColor = lngBackColor
    picGraphicsEffects.Width = lngImageWidth
    picGraphicsEffects.Height = lngImageHeight
   
   
    If blnCenterImage = True Then
        BitBlt picGraphicsEffects.hdc, lngImageWidth / 2 - PicAnimation(lngActualSubImage).ScaleWidth / 2, lngImageHeight / 2 - PicAnimation(lngActualSubImage).ScaleHeight / 2, PicAnimation(lngActualSubImage).ScaleWidth, PicAnimation(lngActualSubImage).ScaleHeight, PicAnimation(lngActualSubImage).hdc, 0, 0, vbSrcCopy
    Else
        BitBlt picGraphicsEffects.hdc, lngImageX, lngImageY, PicAnimation(lngActualSubImage).ScaleWidth, PicAnimation(lngActualSubImage).ScaleHeight, PicAnimation(lngActualSubImage).hdc, 0, 0, vbSrcCopy
    End If
   
    picGraphicsEffects.Picture = picGraphicsEffects.Image
   
   
   
    GRP.GetImageData picGraphicsEffects
    GRP.BackColor = lngBackColor
   
   
    GRP.Mirror = Mirror
    GRP.OldColor = lngOldColor
    GRP.NewColor = lngNewColor
    GRP.BlackAndWhite = blnBlackAndWhite
    GRP.Rotate = lngRotate
    GRP.ShadowColor = lngShadowColor
    GRP.ShadowX = lngShadowX
    GRP.ShadowY = lngShadowY
    GRP.SelectionColor = lngBorderSelectionColor
    GRP.SelectionWidth = lngBorderSelectionWidth
    picGraphicsEffects.Width = Extender.Width
    picGraphicsEffects.Height = Extender.Height
    picGraphicsEffects.Picture = Nothing
   
    GRP.DrawImage picGraphicsEffects, 0, 0, , , dwDraw
    Set GRP = Nothing
    UserControl.Picture = picGraphicsEffects.Image
   
   
   
    UserControl.MaskPicture = UserControl.Image
............................

and heres my class for see the picGraphicsEffects size:
Code:

Public Sub GetImageData(Picture As Object)
   
    inWidth = Picture.ScaleWidth
    inHeight = Picture.ScaleHeight
   
    ReDim OriginalImage(inWidth - 1, inHeight - 1)
    With bi32BitInfo.bmiHeader
        .biBitCount = 32
        .biPlanes = 1
        .biSize = Len(bi32BitInfo.bmiHeader)
        .biWidth = inWidth
        .biHeight = inHeight
        .biSizeImage = 4 * inWidth * inHeight
    End With
   
    GetDIBits Picture.hdc, Picture.Image.Handle, 0, inHeight, OriginalImage(0, 0), bi32BitInfo, 0
    lngBackColor = OriginalImage(0, 0)
    lngOldBackColor = OriginalImage(0, 0)
    lngTransparentColor = OriginalImage(0, 0)
End Sub

by defauld i have the AutoSize true. but if i put it false and resize the usercontrol and then put AutoSize true, i get these error on these line:
Code:

GRP.DrawImage picGraphicsEffects, 0, 0, , , dwDraw
error message: "run-time error '91': object variable or width block variable not set"
if i close the form(in IDE) and then open it, the message error isn't showed and the image is showed normaly. if i uncoment the 'On Error Resume Next', the error message ins't showed and the image isn't too(only after close the form(continue be in IDE) and then open it). can anyone advice me?

Viewing all articles
Browse latest Browse all 21237

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>