Newbie having trouble with brush1.New1()

mjcoon

Well-Known Member
Licensed User
I grabbed a coding example from the forum that includes the line

brush1.New1(cBlue)

But whatever I do with the parameter (using a varable or RGB()) I get a pop-up saying that the "parameter is not valid".

What could be causing this, please?

(I am a complete newbie with Basic4PPC trial edition, hoping to make enough progress to justify a purchase. But I have decades of programming experience in multiple languages.)

Mike.
 

Cableguy

Expert
Licensed User
Longtime User
Hi Mike,

Could you post your code?
What version of Basic4Ppc are you using?
Is the error relative specificaly to that code line?
Did You had the necessary DLL in the components, and the apropiate object?

Cheers
 
Last edited:

klaus

Expert
Licensed User
Longtime User
After having installed the library and added a brush object, you must initialize the object with:
brush1.New1(cBlue) or
brush1.New1(RGB (100,124,55))

Afterwards you can modify it's color whenever you want with:
brush1.Color = cRed or
brush1.Color = RGB (100,100,100)

Best regards.
 

mjcoon

Well-Known Member
Licensed User
Thanks for your prompt replies.

The code isn't "mine"; as I said I just got it from a tutorial so I had to work out how to create the matching objects.

Sub Button1_Click
bitmap1.New2(100,100)
rect1.New1(0,0,bitmap1.Width,bitmap1.Height)
drawer.New2(bitmap1.Value, B4PObject(5)) 'The drawer will draw on bitmap1
brush1.New1(cBlue)
drawer.FillRectangle(brush1.Value,rect1.Value)
brush1.Color = cBlue
rect1.Width = 40
drawer.FillEllipse(brush1.Value,rect1.Value)
form1.DrawImage(bitmap1.Value,10,10) 'Draws bitmap1 on form1
End Sub​

If I try retyping the offending line, the hint I get does not include any NewX() with a color parameter. Example: New2(width, height) instead. If I change the code then I get past the problematic line to the next one (which also fails).

I cannot believe that you-all would publish sample code that does not work, so what is happening?

Cheers, Mike.
 

mjcoon

Well-Known Member
Licensed User
Thank you Erel, I have tried your ImageLib.zip and it works just as you say. Also when I alter the "brush1.New1()" line the hint says that the parameter is just "color", which fits the code. I shall just have to go back and try to repeat what I was doing before more carefully!

Cheers, Mike.
 

mjcoon

Well-Known Member
Licensed User
Yes, I eventually verified that I had created my brush1 as the wrong type of object. In the desktop that could easily be seen but I don't know how to see it on the device. I just checked the hint list of methods which didn't match Brush. Could the object type be displayed somehow, perhaps in the Delete-object list?
 
Top