How do you modify the appearance of a disabled button in vb.net? - vb.net

I'm disabling a button in vb.net and when I do, I cannot control the BackColor or ForeColor properties to change the appearance. I set new values for them but they don't get picked up. The disabled button looks almost exactly like my enabled buttons so you can't tell the difference. I'm using Flat Style buttons, but have tried changing this and it still doesn't seem to work. Is there some sort of trick to be able to do this?

I ran into a similar problem in VB.NET 2008.
When I set the background color of a textbox to something other than the default at design time, then when I disabled that textbox at runtime, it did not get that 'disabled' look; the background color remained unchanged.
To get around this, I had to override the OnEnabledChanged method and manually set the background to what I needed.
This is a little different than the problem you have, but I think that overriding the OnEnabledChanged method might help you out.

Related

NSTableView Layout issue with Highlight and Background Color

I am basically trying to recreate the popOver that exists in certain Xcode Settings, like this one in Build Settings:
I have tried both with and without using an NSArrayController to control the content but in each of the tests I ran in to different problems I haven't been able to solve.
Desired Result
Complete White Background
Multiple Selection and (Single) Editable Cells
No Reordering is required
When I press the + button I want the new cell to be selected and in edit mode
I want to get notification of when text changes while editing to be able to respond to that.
1. Using Delegate Methods.
When I had set up everything up I got this result:
That didn't look good, so I went and selected "Draws Background" for the NSTableViewCell, which resulted in this which looks nice when I edit a cell:
But when i just Highlight the cell, it looks like this:
It looks like the highlighting get's placed behind the cell background.
Here I'm stuck and don't know how to fix.
2. Using NSArrayController
When I reconfigure and bind this to an NSArrayController the highlighting looks great:
But when I edit a cell, the entire background changes to grey:
This is also not what I want, but can't figure out what to do about.
--
Notes
In Desired Result I listed some things like "When I press the + button I want the new cell to be selected and in edit mode" and "I want to get notification of when text changes while editing to be able to respond to that." To possibly influence the choice of what route to take, as there are more things about thins TableView I haven't figured out.
But this question Is all about how to fix the highlighting and selection so they stay white all the time, and just selecting a cell looks as expected.
Example Code
Example code for the Delegates Method version:
https://github.com/erikberglund/StackOverflow/tree/master/TableViewDelegates
Example code for the Bindings version:
https://github.com/erikberglund/StackOverflow/tree/master/TableViewBindings
Force the appearance to aqua. So instead of inherited select aqua. This solved the issues for me.

What secret things are happening to my NSButtonCell?

I'm writing an OS X app (target 10.10, Xcode 6.1) and I'm really confused by my custom NSButtonCell subclass. It seems like there are things going on here that shouldn't. I'm new to OS X programming, so I'm asking if anyone has insight into the inner workings of NSButtonCell.
First, what seems to be working?
I can set the button's image and title. The image appears normally.
The storyboard sets up the button to be Style: Textured and Type: Momentary Change. It's not Bordered, not Transparent, and doesn't allow Mixed State.
List of complaints:
I override -drawTitle:withFrame:inView: to draw the title in a custom color depending on the cell's highlighted. This color should be #cccccc when the cell is not highlighted, but it's actually #d6d6d6.
The button has both image and alternate image. The image that's drawn is never the alternate image, so I override -drawImage:withFrame:inView: to pick the correct image for cell's highlighted. This appears to work, but what the heck, NSButtonCell? How is on/off state different from highlighted? I've tried many of the Type options and none seem to change the fact that pressing the button will momentarily change highlighted, and toggle state.
Speaking of momentarily changing highlighted, it appears that its duration is about as short as possible, so I had to implement a sort of "debouncer" to prevent -drawWithFrame:inView: from being called more frequently than a specified threshold.
My button cell also has properties myBackgroundColor and myAlternateBackgroundColor. I'm not using backgroundColor because I need to be able to draw a custom background shape (filled rect, filled circle, etc). The alternate background color is used when highlighted. The problem here is that the alternate background color should be #93edbf but appears to be #a1eecb! In order to get it to look like #93edbf, I need to set the color to #84ecb2.
So far this has all been about one particular instance of this button cell. But in another instance, the alternate background isn't drawing at all! I've read through the storyboard code and the buttons are as identical as they can be. My view controller code likewise updates both button cells' properties at the same time. Why would one button behave differently from another?
I want the button to highlight on mouse down instead of "momentarily" after mouse up. I haven't yet implemented this in my custom cell. Man, NSButtonCell is really lacking some things. How does something like that happen? Don't the OS X and iOS teams ever talk to each other?
What could it be?
I've already verified that the cell's controlTint is set to NSClearControlTint. I've checked for background filters, compositing filters and content filters on the off chance they had anything to do with this.
I know Apple really wants us to use their native look and feel for UI elements, but I never thought they'd go so far as to force the use of some highlight tint.

Giving a custom color to a Toggle Switch when it is on mode in xaml?

I want to give a different color to my Toggle Switch when it is On mode.I was going through the Standard Style but couldn't find anything which i am looking for.
First, I'd check the default template again. You can bingoogle it to get this:
http://msdn.microsoft.com/en-us/library/windows/apps/xaml/jj709931.aspx
You might then want to change the "On" visual state Storyboard to update the Background of the "InnerBorder" element or add another background element and use a DoubleAnimation in the Storyboard to control its Opacity.
The easiest way to modify the template might be to use Blend. Similar to what I have done in my answer to this question:
Listview selection display with no padding and no checkmark

WP8 PhoneAccentBrush doesn't affect TextBox focus border

I'm trying to make my WP7 app work well on WP8 (by compiling it as a WP8 app).
In my app, I'm changing the PhoneAccentBrush's Color which seems to work fine still, however TextBox's in WP8 now seem to show a border around it when the textbox is in focus (this wasn't happening for me on WP7). This border seems to always use the System's accent color instead of using the changed color like every other control.
Any idea what's going on here and how to change it? The red accent (if that's what the user has chosen) really clashes with my app's colors!
I would call overriding the accent color a hack. I would avoid setting the accent color and create a template for your textBlock.
Blend makes this very easy by allowing you to copy the default template and make changes to it.
Right Click the textBox in the Objects and Timeline pane, then select Edit Template -> Edit Current. Then select the States tab and select the Focused FocusState, then edit the border brush. Save and reuse the template as needed.
I did notice the textBox control template has changed in 8 and now defines the focus state border brush, although it does default to the PhoneAccentBrush.

Winforms border style

I am trying to make a form with a border like the border on the Windows Vista volume control. The form would need to be resizeable as well.
Thanks, giodamelio
To be a little more clear about what I am looking for.
Here is a form with the ControlBox property set to false.
Here is a rough Photoshop of what I am looking for.
Set the forms .Controlbox=False
Set the forms .Text=""
Done.
You can enable in your Projectsettigs "enable XP-Visual Style".
If you launch your application now, you should have the default borderstyle of the launched OS
Try setting the FormBorderStyle to None or Fixed(3D|Single) and work from there, perhaps.
Alternatively, setting the ControlBox to False should also have the effect of hiding the title bar. However, beware that the form won’t update automatically:
If you set ControlBox to false, and also set the Location property, the Size property of Form will not update to reflect that the non-client area of the form has been hidden. To fix this problem, put the code which alters the Location property to the HandleCreated event.
One way achieve this by following steps:
Set FormBorderStyle of your Form to None.
Take a PictureBox, set its Dock Property to Fill.
Take a image containing Border, and set this Image to the PictureBox.