Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

Loading a picture in button.

This is from the help file:
'Load a picture into the OffImage of the CWButton
Set CWButton1.OffImage.CWImage.Picture = LoadPicture("c:\winnt\Maple Trails.bmp")

I get an error message when I try this in VB:
Run time error '61837'
Unable to write read-only property

Any suggestions?
Paul
0 Kudos
Message 1 of 6
(11,483 Views)

Hi Paul,

I was unable to replicate your error. I created a command button in VB6 which uses the following code

Set CWButton1.OffImage.CWImage.Picture = LoadPicture("C:\WINDOWS\Coffee Bean.bmp")

I had to use a different picture since the other one doesn't exist on my system.

What version of the CWUI.OCX control do you have? You can check this by right-clicking on your CWButton, select Properties, and look at the "About" tab. If you have Measurement Studio 6.0, you can get the latest version 7.0.0 (343) from the following link:

Measurement Studio 6.0 Updater 


David McClelland
NI Applications Engineer

0 Kudos
Message 2 of 6
(11,483 Views)
Hi David,

Thanks for taking time to answer my question.
The problem was that I forgot the "Set" instruction. Duh!

But my problem is not completely solved yet.
I want to use a resource file to store the images and icons. But that doesn't seem to work.
Here is the instruction I am using.
Set cwbSave.OnImage.CWImage.Picture = LoadResPicture("SAVETOCD", vbResIcon)

I am guessing at this point that the value returned by LoadResPicture is different and not compatible in some way. Any ideas?

Paul
0 Kudos
Message 3 of 6
(11,483 Views)
David,

I had version 6.0. I upgraded to version 7.0 and that didn't make any difference.

Paul
0 Kudos
Message 4 of 6
(11,483 Views)
Paul,

I tried that command that you mentioned above and it seemed to work correctly. I did notice that the command you are using above will only affect the picture of the button in the "ON" state. When I tried this, the picture only appeared when I clicked and held down the mouse on the button. You can have the picture appear during the off state as well using "CWButton1.OffImage.CWImage.Picture" instead of "OnImage".

Also, make sure you are using the Bitmap button style for your CWButton. Otherwise the button will not have an image property that you can write to.

Another suggestion is to make sure that there is not a problem reading in the picture from the resource file. You could try modifying one of the example programs that com
e with Visual Basic and use the resource file. There is an example called atm.vbp that loads pictures from a resource file. It might be a good idea to add in a CWButton and see if you can add one of the pictures from the resource file to the CWButton.

I hope that helps. If you continue to see this problem, please let us know. A small sample program may help.

Regards,
Shannon R
Applications Engineer
National Instruments
0 Kudos
Message 5 of 6
(11,483 Views)
The problem was that I was loading in the Onimage instead of the OffImage.

It doesn't have to be a bitmap button to work.

Thanks for your help.
Paul
0 Kudos
Message 6 of 6
(11,483 Views)