|
Interesting, I never considered looking the registry for them.
You wouldnt happen to know if this would be backwards compatible to windows98?
|
|
|
|
|
No. In Windows 98 you set them in Autoexec.bat. Setting them in the registry applies to Windows ME, Windows NT4, Windows 2000 and Windows XP.
|
|
|
|
|
I want to give some controls a transparent background. Does anyone have a hint on how to accomplish this? I have found some examples that removes part of the area the control uses from the control's region. But since they check every pixel of the control they get very slow with large controls.
|
|
|
|
|
yourControl.BackColor = Color.Transparent;
Seriously, it should work.
|
|
|
|
|
It should work. Did you try? You'll be surprised!
Edit:
Seriously. For a UserControl, you cannot set the background to Transparent. If you try to set the background to Transparent on the standard Label, the label assumes the same color as the background, but if you place it on top of something else, that something else is hidden.
|
|
|
|
|
Before the edit, I was going to ask you exactly what you were trying to do. The "seriously" comment was just because the code otherwise looks like a snide comment on how to set transparency. I have used BackColor = Transparent with success before, but it does have the problem you mention. There's really no good way around it without doing a lot of fancy region work or drawing everything yourself (which is ok for informational controls such as labels but a pain for input controls). Depending on your exact needs, I've found that if all you're doing is non-input controls (labels, images, etc.), painting the whole thing yourself leads to far better results in terms of accuracy and speed.
Of course, if you just need to match a dynamically changing background color to the parent control, you can do yourControl.BackColor = yourControl.Parent.BackColor, but I don't think that's quite what you're after.
|
|
|
|
|
Exactly.
But if I paint the control myself, it will stil occupy the whole region. The areas that I do not paint are filled with noice. Or are there any tricks here?
Let say that I want to paint a simple textstring (like a label). Is there a way to set the region according to the text without looping through every pixel in the control, checking if it's changed or not?
I really hate this. I want my old VB labels back!
|
|
|
|
|
If it works for you, you could simply call Graphics.DrawString from the OnPaint method of control that's underneath to paint the text. That way, that "label" would really just be painted on and not a control. That might cause some flicker issues, but it all depends on how often your program redraws.
I don't quickly know of an easy way to set the region to the text.
|
|
|
|
|
Don't know if this can help you, but this article shows transparency in VB:
http://addressof.com/blog/articles/293.aspx
-spif2001
|
|
|
|
|
There is an excellent article on "Custom Shaped Forms" in the MSDN. That article deals with Forms taking non-rectangular shapes.
The first part describes masking the Form with a Bitmap (which is not what you are after).
In the second part, though, the author describes the creation of Forms with custom design not dependant on bitmaps, but using GraphicsPath instead.
I am not sure if this is applicable, but if it is, you should be able to "freeform" your controls.
As for painting the controls yourself and having noise on the non-painted areas: You obviously still USE the whole region. Since Windows does some real clever clipping calculations, the painting of these areas is left to the topmost control (which makes sense). If you do not repaint them, they will stay whatever they are.
Cheers
Sid
|
|
|
|
|
The MSDN article seems very helpful. I got some results right away. Not exactly what I wanted, but I think I'll be able to convert it to something useful.
Thanks!
|
|
|
|
|
Creating really transparent controls can be quite tricky because of the way controls are painted.
But basically you'll have to override your control's CreateParams to include the WS_EX_TRANSPARENT extended window style and override OnPaintBackground to do nothing. A transparent control would look like this:
public class TransparentControl : Control
{
public TransparentControl()
{
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
BackColor = Color.Transparent;
}
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x00000020;
return cp;
}
}
protected override void OnPaintBackground(PaintEventArgs pevent)
{
}
} You can add your own OnPaint() override, of course, to perform your foreground painting.
Regards,
mav
|
|
|
|
|
Even better! Thanks again for all your help!
|
|
|
|
|
I tried to inherit from Label instead of Control, but I'm a bit puzzled by the result. This results in a black box where I had a transparent box when inheriting from Control. I then try to override OnPaint() as well, but no there is no change in behaviour. I figured it would have something to do with the CreateParamas class returned, but I can't find very few differences between the Style and ExStyle properties when inheriting from Control versus inheriting from Label. The only difference is to the Style property where the Label does not set WS_TABSTOP, but sets CCS_TOP, CCS_NORESIZE and CCS_NOPARENTALIGN.
Any idéa to why I get this result?
|
|
|
|
|
Not really, I guess Label is performing its own PaintBackground actions.
mav
|
|
|
|
|
Ofcourse I'm overriding OnPaintBackground(). I've also looked into the code behind the Label control using Lutz Roeders Reflector. The Label does not contain an implementation for OnPaintBackground(). As I understand it, no painting should go on from the Label's point of view if I override all OnPaint* methods with empty ones?
|
|
|
|
|
Don't know why it behaves like this when inheriting from Label .
I've created my own TransparentLabel (drawing the text myself isn't too much work ) and it works well.
Also using the TransparentControl as base class for a semi-transparent aqua-bubble control works well...
mav
|
|
|
|
|
I'm just lazy. Even the most simple control like the label contains much functionality that you don't think about. Text alignment, auto size etc. If I am to implement all or most of it, it will have to do quite a bit of coding compared to inheriting and adding the custom functions I like.
And sadly my work doesn't stop with the Label. Other controls that I would like to be transparent that I can come up with on the top of my head is the Panel, RadioButton, CheckBox...
Thanks anyway. This has been an interesting experience.
|
|
|
|
|
Dear all experts ,
I need to do a Pocket PC application, a wireless management system,
basically liek this, person A use PocketPC (ipaq) OS: win mobile / win ppc 2002 or 2003.. access to wireless access point, and retrive data from a Server ( desktop).
Normally, it will retrieve some data like doc file, exel, picture... but he can upload the file to the server too.
beside this, once it access the server via Wifi, he can sync his inbox message, some announcement, or notes....
so basically, its a office management system...
So i have chosen C# .net for my application, but after reading 2 big books, i am still blur with everything .. i want to ask ..
1.how can i create "login page", basically a testbox for username and a testbox for password, then a button to "login", i think i will be using sql, so i need the coding to connect to sql CE server and verify the password..
can anyone show me the how can it be done ?
2. let say i at form 1, then supose i want to go to another form which is form2 , how i going to link it to form2 ? Onfocus ?
Thanks all, appreciate it !
|
|
|
|
|
can anyone help me on this ?
thanks !
|
|
|
|
|
hi all,
I am new to c# so please help me here...
I am tryin to build a HTML compare tool, which opens two htmls with the same name from diff folders. I am using two axwebbrowsers to view the htmls(both are present in the same form).
I now want to add synchronized scrolling to the axwebbrowsers(i.e when one window is scrolled the other is scrolled to the same extent to assit a visual caompare).
Can anyun please help me here? is my choice of axwebbrowser right? or can i use something else?
any help will be appreciated
|
|
|
|
|
Hi,
How do i change the color of the text in a treeview to a diff color ?
Saleem
|
|
|
|
|
Hi!
Exactly like everywhere else: set the node's appropriate ForeColor .
mav
|
|
|
|
|
Thanx,
It's very simple....
saleem
|
|
|
|
|
Hi friends....
I have a problem ,the code snippet is given below.
I have a mfc shared memrory dll class.I want to instanciate an object of this class in C# .Can you provide some code sample to achieve it.
#ifdef _FtpChannel
#define _EXPORT_IMPORT_FtpChannel __declspec(dllexport)
#else
#define _EXPORT_IMPORT_FtpChannel __declspec(dllimport)
#endif
class _EXPORT_IMPORT_FtpChannel CFtpMessage : public IConnection
{
private:
public:
CFtpMessage();
~CFtpMessage();
};
Sudhir Mangla
http://Programmerworld.net
(Free books , articles , Source Code and Programming Tools and Utilities)
|
|
|
|