开发者

Form Opacity windows xp .net 2

Do anyone knows why this function doesnt work in Windows XP. works fine under win7

public Form1()开发者_如何学编程
{
    InitializeComponent();
    double flt = double.Parse("0,55");
    ShowOpacity(flt);
}


private void ShowOpacity(double flt)
{
    this.Opacity = flt;
}


if I just type this.Opacity = .55; it works ok.

Your virtual machine is running with the wrong system locale, not the Netherlands. Which is where I think you're from. Unfortunately, "0,55" is a valid value for a string in locations like the USA, the comma is treated like a thousands separator. The result of the Parse statement is 55, a value that the Opacity property silently truncates to 1 without raising an exception.

Control Panel + Regional and Language Options, switch your machine to your home country. Check the "Decimal Symbol" setting in the Formats tab, Advanced afterwards to verify it is a comma and not a period. Also check the type for the Setting, you want a double, not a string.


From MSDN - Form.Opacity:

Windows 2000, Windows 2000 Professional, Windows 2000 Server, Windows 2000 Advanced Server, Windows XP Home Edition, Windows XP Professional x64 Edition, Windows Server 2003 Platform Note: Supports the Layered Windows API. This property has no effect on platforms that cannot display layered windows. In addition, some display drivers do not support layering.

So, the issue may very well be with your display driver.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜