|
-
Sep 6th, 2010, 01:16 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] [HELP!] Stupid Run Time error 91....
I searched the forums, and Si's sig about errors with vb6. But didn't help. I have this code:
Moduel:
Code:
Option Explicit
Public Declare Function BitBlt Lib "gdi32" (ByVal hDestDC 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 dwRop As Long) As Long
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Public picRedBrick As PictureBox
Form1:
Code:
Private Sub Command_Click()
picRedBrick.Picture = VB.LoadPicture(App.Path & "\Brick_Red.bmp")
Set picRedBrick.ScaleMode = "3"
BitBlt Form1.hDC, 0, 0, esta.ScaleWidth, esta.ScaleHeight, esta.hDC, 0, 0, vbSrcCopy
End Sub
It isn't working, and it highlights both lines that i try to set the scalemode, AND load the picture. Am i doing something wrong?
-
Sep 6th, 2010, 01:25 AM
#2
Re: [HELP!] Stupid Run Time error 91....
 Originally Posted by Gamemaster1494
Am i doing something wrong?
Yes
Code:
picRedBrick.Picture = LoadPicture(App.Path & "\Brick_Red.bmp")
picRedBrick.ScaleMode = 3
'Set' is used to initialise objects, here you just want to assign a value to a Property of an object, the ScaleMode property is an Integer not string, so "3" would be incorrect.
Last edited by Doogle; Sep 6th, 2010 at 01:28 AM.
-
Sep 6th, 2010, 01:38 AM
#3
Thread Starter
Fanatic Member
Re: [HELP!] Stupid Run Time error 91....
Okay. I did that and it still highlights it and says the same thing.
-
Sep 6th, 2010, 01:48 AM
#4
Re: [HELP!] Stupid Run Time error 91....
Ok, I see the problem. You're trying to dynamically create a PictureBox, which , as far as I know you can't do (ie attempting to do: Set picRedBrick = New PictureBox, will not work - you'll get an Invalid use of New Keyword)
What exactly are you trying to do ?
-
Sep 6th, 2010, 01:52 AM
#5
Thread Starter
Fanatic Member
Re: [HELP!] Stupid Run Time error 91....
Well, just load a picture from a file, and use it with bitblt.
-
Sep 6th, 2010, 02:01 AM
#6
Re: [HELP!] Stupid Run Time error 91....
Is there any reason why you can't draw picRedBrick on the Form at design time ? That would be a common way of creating a PictureBox which you can subsequently 'play' with in your code.
-
Sep 6th, 2010, 02:09 AM
#7
Thread Starter
Fanatic Member
Re: [HELP!] Stupid Run Time error 91....
Yeah... But i just thought it would be more profesional to use files from the computer and such. and wouldn't doing that take up more space than just the lone file?
-
Sep 6th, 2010, 02:13 AM
#8
Re: [HELP!] Stupid Run Time error 91....
Not too sure what you mean, in order to display a picture you need a container, like a PictureBox. The easiest way to achieve that is to draw it at design time. Once that's established you can load a Picture into it using LoadPicture and then BitBlt and 'play' with it to your hearts content.
-
Sep 6th, 2010, 02:17 AM
#9
Thread Starter
Fanatic Member
Re: [HELP!] Stupid Run Time error 91....
Yeah. I have done bitblt that way before. But with the form1.frx(stores images), would that be bigger than the actual images themselfs?
-
Sep 6th, 2010, 04:20 AM
#10
Re: [HELP!] Stupid Run Time error 91....
It might be... try it and see.
Note however that it is irrelevant to whether or not the picturebox exists at design time - there is nothing forcing you to add a picture to a picturebox.
-
Sep 6th, 2010, 02:49 PM
#11
Thread Starter
Fanatic Member
Re: [RESOLVED] [HELP!] Stupid Run Time error 91....
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
|