473,657 Members | 2,567 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

form becoming black while increasing opacity from 0 to 1

153 New Member
I am ShowDialoging one form in which the activate event increases the opacity from 0 to 1. I set the opacity to 0 in it's constructor.The problem is that during the showing of the form it becomes black.
And after it's opacity becomes one it becoems the normal color (Control).
The code is as follows

Expand|Select|Wrap|Line Numbers
  1.          public Form1()
  2.         {
  3.             InitializeComponent();
  4.             this.Opacity = 0;
  5.         }
  6.  
  7.         private void Form1_Activated(object sender, EventArgs e)
  8.         {
  9.             while (this.Opacity < 1)
  10.             {
  11.                 this.Opacity += .01;
  12.                 Thread.Sleep(100);
  13.             }
  14.         }

I wanted to show the screenshot but when i print-screen while it is black and paste it in MS Paint it shows the normal way !
Tha's weird.How to get around this ?

EDIT:I found the solution.The thread is Sleeping so how would it display the opacity changed form !
I used this.Refresh(); before the sleep and it worked.
Jan 6 '09 #1
1 2022
Plater
7,872 Recognized Expert Expert
Yup you are correct. That loop is also known as a "busy loop" as it keeps the thread busy and does not allow it to process the windows messages (which by calling Refresh() you are forcing it to do.) Application.DoE vents() should also work.
Jan 6 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3006
by: Carsten Klotz | last post by:
Hi, I've set the TransparencyKey of a form to black. That means, all black pixel will be shown transparent within the drawing content of that form. If I set the background to black, I can see the underlying window (ie. Desktop or IE). But when I want to draw with the mouse inside that transparent area, my form/window lost its focus (TopMost=true). Even when I'm just moving the mouse, I can see, that I'm "touching" the underlying content...
2
1703
by: john wright | last post by:
My program requires users to login before use. Using the following code in the login form: Me.Opacity = Me.Opacity - 0.2 If Me.Opacity <= 0 Then Timer1.Enabled = False If boolExit = False Then
14
2012
by: James | last post by:
I am trying to a add a method to a helper class library I built that will fade out the current form. My code is this: public void fade(object currentForm) { int z = 0; for(double i=1.0; i> 0; i-=.1) { currentForm.Opacity = i; while(z<10000)
2
2343
by: reidarT | last post by:
I want a windows form to act like the one in Outlook when you get a new message and it is visible for about a couple of seconds and then the opacity decreases and the form dissapears in the end I have tried with Dim p As Integer Dim Vent As Integer For p = 100 To 0 Step -1 Me.Opacity = p For Vent = 1 To 100000
0
6178
by: josephkorn | last post by:
Hi all. I have a problem in my website in trying to prevent a user from double submitting the form. I am calling a subroutine from my page_load event that passes in the commandbutton that I want to prevent users from being able to click twice. Everything is working great, except for one small detail. When my client-side validation fires, and is invalid, I see the red text that displays the error message, but the problem is that something is...
3
4286
by: Boki | last post by:
Hi All, I saw the paint.net program, when mouse hover, the color palette become 100% opacity. I try the code below, the issue is I also have some other controls ( textbox/button ) in my form, it should be a better way to do it in fewer codes, right ? ( set all hover function to the same as form ? )
1
15095
by: metaphysics | last post by:
I can't seem to find this anywhere on the web, so I figured I'd post the question here. I'd like to be able to define an image class in CSS to make all posted images black and white. For example, I would use this code if I wanted to change Opcaity of all of them to 50%: img { filter:alpha(opacity=50); -moz-opacity: 0.5; opacity: 0.5; Is their a code in css or javascript that will do something similar, but instead make the images black...
5
2252
by: MC | last post by:
Hi, I have been looking around for a way to apply the filter that grays out a form or div. I found some examples but the code is pretty complex. Any simple ways to gray that out so I can highlight another form or div? Thanks, Mica PS. I looked at several of the 'easy' examples and they did not work when I applied them.
3
5011
by: Sin Jeong-hun | last post by:
As far as I know if I change the form's opacity, every control on the form also inherits that opacity. But in many real applications (not application programs), we see opaque text (100% opacity) on a traslucent background, for example text messages on TV. Or look at the title bar text of Aero. Background is translucent but the text is opaque. Is it possible to use 100% opaque text on a traslucent form?
0
8397
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8827
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6167
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4315
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2731
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1957
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.