|
Hi,
i used ControlPaint.DrawCheckbox() method, but the checkbox is not drawn with XP Theme (FlatStyle.System). Is it possible to use ControlPaint class with XP Styles?
.:[Greetz from Jerry Maguire]:.
|
|
|
|
|
It doesn't seem like it. You might want to use this[^] instead.
|
|
|
|
|
Try calling Application.EnableVisualStyles(); in Main before anything else. This mostly worked for me (I'm still having problems with my toolbars not looking right.)
When all else fails, there's always delusion.
- Conan O'Brien
|
|
|
|
|
Yep, you're right, my code is
Application.EnableVisualStyles();
Application.DoEvents();
Application.Run(new MyForm());
otherwise the styles are not set right, i guess it's a framework error that i have to call DoEvents().
I have found a solution do draw controls theme aware via xp theme api, thanks.
.:[Greetz from Jerry Maguire]:.
|
|
|
|
|
Hi, how do you minimize your app to system tray in C#/.NET?
norm
|
|
|
|
|
Add a NotifyIcon to your form and assign it an icon.
set visible = false if you do not want it to be there all the time.
In the event handler where you want the app to minimize to the tray do something like:
private void btn_MinimiseToTray_Click(object sender, System.EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
this.ShowInTaskbar = false;
this.notifyIcon1.Visible = true;
}
and reverse it all when the icon is clicked or on a context menu etc....
|
|
|
|
|
Thanks! I successfully send the app to system tray. But I am having some trouble trying to restore it from the tray.
private void NotifyIcon_Clicked(object sender, System.EventArgs e)
{ //None of this help, the form just disappeared, never to come back.
WindowState=FormWindowState.Normal;
ShowInTaskbar=true;
BringToFront();
Focus();
Visible=true;
return;
}
I just need one more tip for this.
norm
|
|
|
|
|
did you try Activate() ?
Free your mind...
|
|
|
|
|
Thanks. But, yes I did. Activate didn't work
norm
|
|
|
|
|
Hi Guillermo, I've got it working - well, the title bar didn't get repainted properly. Part/Chunk of it (Titlebar) appears dark. I called Invalidate(), which got rid of the problem in client area, not the title bar...
private void NotifyIcon_Clicked(object sender, System.EventArgs e)
{
WindowState=FormWindowState.Normal;
ShowInTaskbar=true;
BringToFront();
Focus();
Visible=true;
ClientSize = new System.Drawing.Size(292, 318);
Location = formLocation;
Invalidate();
return;
}
private void Form_Clicked(object sender, System.EventArgs e)
{
formLocation = this.Location;
WindowState = FormWindowState.Minimized;
ShowInTaskbar = false;
notifyIcon.Visible = true;
return;
}
norm
|
|
|
|
|
Good.
When I did it, I used Form.Hide() instead of changing the windowstate, so I didn't have the problem of repainting. When I clicked on the taskbar icon, I used Form.Show(). In that way, it did good for me..
Free your mind...
|
|
|
|
|
Thanks, it's working just fine now. I hide the form, as supposed to minimizing it.
norm
|
|
|
|
|
What i am doing is to generate a TrayIcon and use this code:
// Public Bool for Closing the app
bool boolAlowClose = false;
// Press the closing Button at the app
protected void frmMain_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (!boolAlowClose)
{
this.m_notifyicon.Visible = true;
this.Hide();
e.Cancel = true;
}
else { e.Cancel = false; }
}
// ContextMenu from Trayicon to view the app again
private void cmnu_View_Form_Click(object sender, System.EventArgs e)
{
this.m_notifyicon.Visible = false;
this.Show();
}
// This is the Menu "Close" hat close the application
private void cmnu_Menu_Close_Click(object sender, System.EventArgs e)
{
boolAlowClose = true;
this.Close();
}
Hope this will help!
Matthias
|
|
|
|
|
|
im writing a new control, and i need to pass information to the click event, how do i add data to then EventArgs so that when i create a new project and place this control in the form , the click even of that control will give me more data inside the EventArgs?
(i know i can create a class the inherits from EventArgs and add the info in there but what do i need to do, so that it will send that new class to the on_click event)
void on_click(object sender, System.EventArgs e)
|
|
|
|
|
Hi,
why you need to serve the data via the event? It's also possible to say:
void OnClick(object sender, EventArgs e)
{
((MyControlType)sender).MyDataProperty ...
}
you could read and write everything you need there.
.:[Greetz from Jerry Maguire]:.
|
|
|
|
|
You need to:
1) inherit from the System.EventArgs class with a new class eg:
public class MyControlEventArgs<br />
{<br />
private string AnExampleDataMember<br />
}
Then create a delegate for that type of event
public delegate void MyControlEventHandler(object sender, MyControlEventArgs e)
And then create the event using the newly created delegate.
Create data memebers in MyControlEventArgs for all the data you need to pass into the event. Pass an instance of the new args class into the new handler.
Cheers, James
James Simpson
Web Developer
imebgo@hotmail.com
|
|
|
|
|
|
hi , nice article but you are missing the point, maybe i didnt explain clearly. what i want to do is create a control, so that when i create a project and place the control in the form, i will look at the control's properties and press the events button, now if i double click on the event click in [action], it will create a new function like allways , but instream of getting a :
private void Control1_Click(object sender, System.EventArgs e)
{
}
i will get something like
private void Control1_Click(object sender, System.EventArgsWithExtraInfo e)
{
}
hope this is clearer now
|
|
|
|
|
What is your problem, just design your events as I explained in that article.
Also, for setting an event as an defult event, you should put (as I remember) below attribute above your event defenition in your event owner class:
[DefaultProperty]
Don't forget, that's Persian Gulf not Arabian gulf!
|
|
|
|
|
Hi, Currently I am using Excel 8.0 COM object to display information from C# to Excel. The codes i am using is from the net. However, there is always an error. I tried many different codes from different website, it still won't work. Would the different version of COM object be the reason of those errors? Does different version make a difference?
|
|
|
|
|
Hi, all,
Is it possible to set Enable(true /false) of all components inside group box once?
for example, I have 10 different components inside GroupBox, I just want to disable or enable them once , don't need to set them seperately.
Anyone can give me ideas?
|
|
|
|
|
I believe you can do:
myGroupBox.Enabled = false; and it will disable everything inside the groupbox.
When I can talk about 64 bit processors and attract girls with my computer not my car, I'll come out of the closet. Until that time...I'm like "What's the ENTER key?"
-Hockey on being a geek
|
|
|
|
|
Just for fun I'd like to be able to get an interface with a pc cam or a digital camera hooked up through usb. Like, for example I could write an app that does time-lapse photography on my cactus (which does move, btw), or claymation maybe. Like, I could save one frame every 10 minutes. Or of course for doing webcams..
I know there's software that comes with some pc cams that does some of that already, but, being a programmer, I'd like to get my hooks into it myself. Does directx do this, maybe? I'm worried that each cam will be non-standard about it's protocol, etc... anyone know?
thanks
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
|
|
|
|
|
I recently found out that you can actually declare a class within a class, like so:
public class Class1
{
public class Class2
{
....
}
}
My question is, why would you ever want to that, as opposed to declaring the class separately like so:
public class Class2
{
}
public class Class1
{
Class2 cls;
}
Is there some hidden advantage to doing it the former way that I'm not aware of?
|
|
|
|