[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 756
  • Last Modified:

Ugly Picture on disabled button

Hello,

I have a problem with my icons(bmp format)  on the command buttons i made. I made xp style icons to put on my buttons. When the button is enabled they look great, but when they are disabled they look ugly. See link for example.
Url: http://home.kabelfoon.nl/~idrissi/Buttons/

I am using Acces 97.

I tried using .ico files instead .bmp but that did not work. Has anyone some suggestions how improve the looks of the disabled buttons.
I prefer not to work with swap images or external ocx controls. The best solution would be a solution that uses the resources that access standard provides. But if that's impossible i'm all ears for any other solution.

Thanks,
F.
0
wacko41
Asked:
wacko41
1 Solution
 
Shiju SasidharanCommented:
try to use another pictures for disabled purpose.
and NOT disable the buttons, instead write code to do nothing if Disabled mode is selected.
definitely u need to put some extra code to work it out.

;-)
Shiju
0
 
senthil_msvCommented:
try this one,

Use same picture for "DisabledPicture" Property.
 I used in normal button it will display clearly, Apply this property and check this one
0
 
edwardiiiCommented:
Hi, wacko41.

senthil_msv's method works for me using VB 6.  If you happen to be using VBA (Excel, for example) where there is no DisabledPicture property, you can build on shijusn's comment as follows:

Add to General Declarations:
   
     Dim buttonDisable As Boolean

Add to beginning of Command1's Click event:

     If buttonDisable = True Then
        Exit Sub
     End If

When you want Command1 to be "disabled" instead of using Command1.Enabled = False, use this code:

     buttonDisable = True

When you want Command1 to be "enabled" again:

     buttonDisable = False
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
wacko41Author Commented:
Hi,

thanks for the comments so far but is's not quite what i'm looking for. I don't want to write code to do nothing if Disabled mode is selected. That is not user-friendly. Because when a button looks enabled then it should be enabled and vice versawith disabled buttons. A button shoud do what the user expects it to do.

So what i'm looking for is a way to improve the looks of a disabled button. Oh by the way I'm using VB in acces 97 so there is no "DisabledPicture" Property".

it seems the problem is tougher then i thought.......

Wacko41
0
 
edwardiiiCommented:
Okay, here's another idea.  Add an Image ("Image1") to your Userform (anywhere), set its Picture to the same picture you've got for your CommandButton1, set the PictureSizeMode until it looks right (I had to use "fmPictureSizeModeStretch") and set its Visible property to "False". Add the following code to either a Procedure (if you've got multiple sources that set CommandButton1's Enabled property to "False") or to a Command button, etc. (if you have only one or two events that cause CommandButton1 to become disabled):

    CommandButton1.Enabled = False
    Image1.Top = CommandButton1.Top
    Image1.Left = CommandButton1.Left
    Image1.Width = CommandButton1.Width
    Image1.Visible = True

Then (same as above based on frequency of button disabling) to re-enable CommandButton1:

     CommandButton1.Enabled = True
     Image1.Visible = False

This will truly disable your command button when its Enabled property is set to "False" by painting over the entire surface of the command button with your Image1.Picture.

It's as nice a solution as being able to just set the DisabledPicture to the same picture, but it's close:)
0
 
wacko41Author Commented:
Hi,
Doesn't anyone kwnows a smart way to swap the enabled picture with another when the state of a button is changed. The image could be provided from a image list. But how can i catch the action when a button state is changed to enabled or disabled from a procedure. It has to be procedure beacuse i have a lot of buttons.

thanks,
F.
0
 
2AngelCommented:
Hi,

Try to change the pic format and/or color depth - I think it will work...
0
 
edwardiiiCommented:
I can't figure out any way to apply the following code to your CommandButton pictures; it should would be great:

   CommandButton1.Enabled = False  
   'No idea how to implement this:   PictureFormat.ColorType = msoPictureAutomatic


If there is no better way, you can use Select Case statements as follows to do what you wish.  If you were using Visual Basic 6 or higher there would be more options, but VBA is limited in many ways:

In General Declarations:

     Dim cmdId As Integer

Public Sub to Disable CommandButtons (1-5):

Public Sub CmdDisable(cmdId)

    Select Case cmdId
   
        Case 1
            CommandButton1.Enabled = False
            Image1.Top = CommandButton1.Top
            Image1.Left = CommandButton1.Left
            Image1.Width = CommandButton1.Width
            Image1.Height = CommandButton1.Height
            Image1.Visible = True
        Case 2
            CommandButton2.Enabled = False
            Image2.Top = CommandButton2.Top
            Image2.Left = CommandButton2.Left
            Image2.Width = CommandButton2.Width
            Image2.Height = CommandButton2.Height
            Image2.Visible = True
        Case 3
            CommandButton3.Enabled = False
            Image3.Top = CommandButton3.Top
            Image3.Left = CommandButton3.Left
            Image3.Width = CommandButton3.Width
            Image3.Height = CommandButton3.Height
            Image3.Visible = True
        Case 4
            CommandButton4.Enabled = False
            Image4.Top = CommandButton4.Top
            Image4.Left = CommandButton4.Left
            Image4.Width = CommandButton4.Width
            Image4.Height = CommandButton4.Height
            Image4.Visible = True
        Case 5
            CommandButton5.Enabled = False
            Image5.Top = CommandButton5.Top
            Image5.Left = CommandButton5.Left
            Image5.Width = CommandButton5.Width
            Image5.Height = CommandButton5.Height
            Image5.Visible = True
   
    End Select

End Sub


Routine to Enable CommandButtons (1-5):

     cmdId = Val(TextBox1.Text)
   
    Select Case cmdId
   
        Case 1
            CommandButton1.Enabled = True
            Image1.Visible = False
        Case 2
            CommandButton2.Enabled = True
            Image2.Visible = False
        Case 3
            CommandButton3.Enabled = True
            Image3.Visible = False
        Case 4
            CommandButton4.Enabled = True
            Image4.Visible = False
        Case 5
            CommandButton5.Enabled = True
            Image5.Visible = False
   
    End Select


My code is using the value of TextBox1 to determine which CommandButton to disable/enable; modify as desired:

     cmdId = Val(TextBox1.Text)
     Call CmdDisable(TextBox1.Text)
0
 
pjcrooks2000Commented:
As Shiju says create new images for diabled buttons, otherwise whatever the image is will be greyed out..

0
 
edwardiiiCommented:
Hi, GPrentice00. wacko41 is using Access VBA, so the comments posted above applicable to VB 6 aren't viable. I agree with him that a more elegant solution would be desirable, but I did present solutions that work in a VBA environment.
0
 
GPrentice00Commented:
yes, the irony of Visual Basic 6 being built ontop of the VBA engine.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now