Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command Button with graphic disappears

Status
Not open for further replies.

RobHVB6Sql

Programmer
May 20, 2002
77
AU
I have looked at several posts here but no answer.

I have a simple 8 bit BMP image on a command button that works fine on some forms, but not others. Initial forms are OK, but once the user has navigated via SSTab and this code it shows the image behind it, but it works fine. Is the code here causing this? Properties of the CommandButton? or Form? How can I show the image /button again.

PS A PictureBox works fine, but I would rather use a CommandButton.

Code:
    Dim cx As CCreateHook
    Set cx = New CCreateHook
    
    'Create the Teebo ComboBoxes and make changes
    Load frmGDiagnosis
    
    ' We are done hooking. Because the form is modal, we will remove the hook before we show the form.
    Set cx = Nothing
    
    'display procedures add/edit screen
    frmGDiagnosis.Show vbModal

Rob Hasard
Data Manager -Genetic Services
(VB6 /SQL 7.0)
 

try forcing a redraw of the control or form.

you can use

control.redraw = false
control.redraw = true

or

control.visible = false
control.visible = true

or substitue form for control above.
 
No sorry this has no effect, the hooking that is being done is causing the problem. Any further ideas?

Rob Hasard
Data Manager -Genetic Services
(VB6 /SQL 7.0)
 
Store your images in an imagelist, and load them into the picture property of each button.

This will get around your problem after hooking the window.

Hope this helps.
 
Great, thanks I can create an ImageList control and add images to it, but not add an image to a CommandButton.
I'm trying many syntaxes ie
Code:
command1.Picture = iml.ListImages.Item.Picture
command1.Picture = iml.ListImages.Item.1
command1.Picture = iml.ListImages.Item.1
command1.Picture = iml.ListImages.Index.1
command1.Picture = iml.ListImages.Item("Help")
No success, and I found a website stating "this has to be another Common Control, ie TreeView, ListView, Toolbar etc)..". I hope this is not true as I wish to keep my command buttons and their associated code.

I have also tried a simple load picture which is not working ie
Code:
command1.Picture = LoadPicture("C:\help.bmp")
Can I have a ImageControl globally accessible ie used throughout many forms?

Rob Hasard
Data Manager -Genetic Services
(VB6 /SQL 7.0)
 
you need to use the extracticon method of the image control using img.extracticon to get the icon for the commandbutton.

To store a global image repository, either use a form that is always loaded but never visible to store resources, and reference that, or use a resource file to store your images.

Hope you have some luck now!
 
Sorry guys, tried all these and nothing works.

I've decided to give up on this 'nice to have'.
Thanks anyway.

Rob Hasard
Data Manager -Genetic Services
(VB6 /SQL 7.0)
 
Um...silly question, but you do have the command button's style set to Graphical, don't you?
 
Yes.

Rob Hasard
Data Manager -Genetic Services
(VB6 /SQL 7.0)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top