opacity problem
-
Hi All, I am using C#. I have a empty Form. When i move mouse on the Form, i am displaying the x and y position of mouse using DrawString() method. Graphics grx = e.Graphics; string xy = "X: " + cursorPos.X.ToString() + "\nY: " + cursorPos.Y.ToString(); grx.DrawString(xy, font, brush, cursorPos.X, cursorPos.Y); The above code snippet is in Paint event. Hence the x and y values move along with cursor. My problem, When i change the opacity of Form from 100% to 10%, the Form becomes transparent. Even x and y values (displayed using DrawString) becomes transparent (faint). I want the x and y values to be displayed clearly even if Form is transparent. How can i achieve it? Thanks in advance.
-
Hi All, I am using C#. I have a empty Form. When i move mouse on the Form, i am displaying the x and y position of mouse using DrawString() method. Graphics grx = e.Graphics; string xy = "X: " + cursorPos.X.ToString() + "\nY: " + cursorPos.Y.ToString(); grx.DrawString(xy, font, brush, cursorPos.X, cursorPos.Y); The above code snippet is in Paint event. Hence the x and y values move along with cursor. My problem, When i change the opacity of Form from 100% to 10%, the Form becomes transparent. Even x and y values (displayed using DrawString) becomes transparent (faint). I want the x and y values to be displayed clearly even if Form is transparent. How can i achieve it? Thanks in advance.
Hmmm not sure if will work but try the following... Set the backcolor of your form to a color not used for you text, the set the tranparencykey to match. then put a panel on your form with backcolor as Transparent. then do your paint code to the panels Paint Event. hopefully it will work EDIT: just tested and works fine, just need to set the FormBorderStyle to None
Life goes very fast. Tomorrow, today is already yesterday.
-
Hmmm not sure if will work but try the following... Set the backcolor of your form to a color not used for you text, the set the tranparencykey to match. then put a panel on your form with backcolor as Transparent. then do your paint code to the panels Paint Event. hopefully it will work EDIT: just tested and works fine, just need to set the FormBorderStyle to None
Life goes very fast. Tomorrow, today is already yesterday.
-
Thank you very much for your help, but i am not getting the result. Will you please elaborate? Have you set panel dock to fill?
ok this is all i did... the form contains only one panel, simply drag and dropped to design, set
Panel1.BackColor = Color.Transparent;
and double clicked Paint event handler, thats all i did to the panel
public Form1()
{
InitializeComponent();
//i set these in design mode but have put here to show you the code
this.BackColor = Color.Red;
this.TransparencyKey = Color.Red;
this.FormBorderStyle = FormBorderStyle.None;}
void Panel1Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawString("SOME TEXT", Label.DefaultFont, Brushes.Blue, 0, 0);
}when the form loads all i can see is "SOME TEXT" in blue on my screen
Life goes very fast. Tomorrow, today is already yesterday.
-
ok this is all i did... the form contains only one panel, simply drag and dropped to design, set
Panel1.BackColor = Color.Transparent;
and double clicked Paint event handler, thats all i did to the panel
public Form1()
{
InitializeComponent();
//i set these in design mode but have put here to show you the code
this.BackColor = Color.Red;
this.TransparencyKey = Color.Red;
this.FormBorderStyle = FormBorderStyle.None;}
void Panel1Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawString("SOME TEXT", Label.DefaultFont, Brushes.Blue, 0, 0);
}when the form loads all i can see is "SOME TEXT" in blue on my screen
Life goes very fast. Tomorrow, today is already yesterday.