|
The MenuItem Class has no Bounds property. The only thing I can think of is the OnDrawItem() override. I've used this to draw stuff to the menuitem. HOwever setting the control to use the System.Windows.Forms.DrawItemEventArgs.Bounds property doesn't seem to cut it.
<br />
public class ControlMenu : System.Windows.Forms.MenuItem<br />
{<br />
<br />
public TrackBar track;<br />
<br />
<br />
public ControlMenu()<br />
{<br />
<br />
track = new TrackBar();<br />
this.track.Name = "trackBar1";<br />
<br />
this.track.Orientation = System.Windows.Forms.Orientation.Vertical;<br />
this.track.Size = new System.Drawing.Size(42, 144);<br />
this.track.TabIndex = 13;<br />
this.track.Value = 10; <br />
<br />
} <br />
protected override void OnDrawItem(System.Windows.Forms.DrawItemEventArgs e)<br />
{<br />
base.OnDrawItem(e);<br />
<br />
track.Bounds = e.Bounds;<br />
track.Visible = true;<br />
track.BringToFront();<br />
track.Focus();<br />
}<br />
I've tried having base.OnDrawItem(e); before and after the bounds setting code, without any luck.
Any Ideas?
"Where would you rather be today?"
|
|
|
|
|
You may need to have the trackbar as a child to the hosting form rather than your menu item, and reference it with public properties.
I'll have a play with it later if you like.
|
|
|
|
|
Furty wrote:
You may need to have the trackbar as a child to the hosting form rather than your menu item, and reference it with public properties.
Eventually its gonna be used on the Notify Icon context menu for an app i'm working on, but for now i'm just having it as a form menu item. Thus, the Trackbar will need to be independant of the form as the NotifyIcon is not related to the form.
I'm leaving it for today and going to watch some TV like the couch potatoe I am. If you find anything out in the mean time I'll be glad to hear
"Where would you rather be today?"
|
|
|
|
|
OK, I've done a little testing and the major problem seems to be the fact that Menu and MenuItem do not derive from System.Windows.Forms.Control. Form what I can see, the only way to acheive your goal would be to override the OnDrawItem and OnMeasureItem methods, and paint the control yourself. Naturally you would also need to handle mouse events etc for user interaction.
The bottom line is that it's a big task, you might be better off using one of notify icon ballon implementations here on CP, as they derive from forms, and therefore can host controls no problem.
Hope this has helped..
|
|
|
|
|
possibly (maybe) the magiclibrary may have what you are looking for ?
The Code Project Is Your Friend...
|
|
|
|
|
Dear Sirs,
Please guide me how I can send Mails in .NET via an SMTP Server which requires SMTP Authentication.
Regards,
Sassan Komeili Zadeh
|
|
|
|
|
Hmm...
There have been umpteen articles on this topic in C#.
MailMessage msg = new MailMessage();
msg.From = "crawler@deepak.portland.co.uk";
msg.To = "crawler@deepak.portland.co.uk";
msg.Subject = "Test";
msg.Body = "Hi! Hello" +"\nSent Via MailMessage and SmtpMail Class";
SmtpMail.SmtpServer = "smtp.yourmailserver.yourisp.com";
SmtpMail.Send(msg);
SmtpMail.Send("crawler@deepak.portland.co.uk","crawler@deepak.portland.co.uk","Test","Hi! Hello\nSent Via SmtpMail class");
Include System.Web.Mail namespace for the above methods to be visible to the compiler.
Deepak Kumar Vasudevan
http://deepak.portland.co.uk/
|
|
|
|
|
Deepak Kumar Vasudevan wrote:
There have been umpteen articles on this topic in C#.
But he was asking about SMTP with authentication....;P
MyDUMeter: a .NET DUMeter clone
|
|
|
|
|
Try adding the username and password to the front of the URl of the SMTP server. eg
user:pass@smtp.isp.net
Not sure if it will work though.
MyDUMeter: a .NET DUMeter clone
|
|
|
|
|
Thanks.
My Mail Server POP3 account username is: info@xyz.com
and when I try what you suggested, I get no answer.
Would you suggest another solution?
Regards,
Sassan
|
|
|
|
|
You may use this class and add the following code to authenticate, just after sending the HELO command:
<br />
buf.Append("HELO ");<br />
buf.Append(host);<br />
con.SendCommand(buf.ToString());<br />
con.GetReply(out response, out code);<br />
buf.Length = 0;<br />
<br />
if(!AuthLoginPlain(con, user, password)) {<br />
con.Close();<br />
throw ....
}<br />
<br />
...<br />
<br />
<br />
private bool AuthLoginPlain(SmtpConnection con, string user, string pass)<br />
{<br />
StringBuilder buf = new StringBuilder();<br />
byte [] b_user = System.Text.Encoding.ASCII.GetBytes(user);<br />
byte [] b_pass = System.Text.Encoding.ASCII.GetBytes(pass);<br />
string response;<br />
string res;<br />
string data;<br />
int code;<br />
buf.Append("AUTH LOGIN");<br />
con.SendCommand(buf.ToString());<br />
con.GetReply(out response, out code);<br />
buf.Length = 0;<br />
if(code == 334) <br />
{<br />
response = response.Substring(4);<br />
res = System.Text.Encoding.ASCII.GetString(Convert.FromBase64String(response));<br />
if(res == "Username:") <br />
{<br />
data = Convert.ToBase64String(b_user);<br />
buf.Append(data);<br />
con.SendCommand(buf.ToString());<br />
con.GetReply(out response, out code);<br />
buf.Length = 0;<br />
}<br />
if(code != 334) <br />
{<br />
return false;<br />
}<br />
response = response.Substring(4);<br />
res = System.Text.Encoding.ASCII.GetString(Convert.FromBase64String(response));<br />
if(res == "Password:") <br />
{<br />
data = Convert.ToBase64String(b_pass);<br />
buf.Append(data);<br />
con.SendCommand(buf.ToString());<br />
con.GetReply(out response, out code);<br />
if(code != 235) <br />
{<br />
return false;<br />
}<br />
return true;<br />
}<br />
}<br />
return false;<br />
}<br />
Cheers,
John
|
|
|
|
|
Hello all,
Can someone suggest components for the following:
1. PDF generation
2. Spell checker
Smitha
Whenever I see an old lady slip and fall on a wet sidewalk, my first instinct is to laugh. But then I think, what if I was an ant, and she fell on me. Then it wouldn't seem quite so funny.
|
|
|
|
|
i have a spell checker program that uses the internet i didnt write it.. but i have used it and it works. i can email it too you if you like. im trying to find the site i downloaded it from. but i cant remeber where.
The Code Project Is Your Friend...
|
|
|
|
|
|
Guys,
How can create a C# file splitter program to slice large files to multiple pieces?
Jassim Rahma
|
|
|
|
|
|
can someone direct me to some good coding style guides..other then whats at msdn... thank you.
jesse M
The Code Project Is Your Friend...
|
|
|
|
|
|
|
I WANT make it clear that i dont want the highlighted code to run but it does, can make someone tell me why?
the permissions (intersecting all policy levels) for the assembly are unrestricted access to reflection. I checked it myself. I'm sure there is no mistake in the policy configurations
using System;
using System.Reflection;
using System.Security;
using System.Security.Permissions;
[assembly:ReflectionPermissionAttribute(SecurityAction.RequestRefuse,Unrestricted=true, Flags = ReflectionPermissionFlag.AllFlags)]
namespace reflectsecuritytest
{
public class mo
{
public static void met( int i )
{
}
public static void met( float f )
{
}
public static void met( string s )
{
}
public static int met( decimal d )
{
return 1;
}
public static void met( object o )
{
}
public int i = 9;
public static int x = 2;
private int pr
{
get
{
return 2;
}
}
}
[
ReflectionPermissionAttribute(
SecurityAction.Deny,
Flags = ReflectionPermissionFlag.AllFlags,
Unrestricted = true
)
]
class Class1
{
public static void PermisosReflect()
{
ReflectionPermission sec =
new ReflectionPermission(
ReflectionPermissionFlag.AllFlags
);
try {
sec.Deny();
//*************************
//*************************
// *********************************
// the next code is supposed not to execute, but it does
//*************************
//*************************
//*************************
Type t = typeof( mo );
BindingFlags bf = BindingFlags.NonPublic | BindingFlags.Public |
BindingFlags.Instance | BindingFlags.Static;
foreach( MemberInfo mi in t.GetMembers( bf ) )
{
Console.WriteLine( mi );
};
} catch( SecurityException e ){
Console.WriteLine( e );
}
}
public static void Deny()
{
Console.WriteLine("before calling");
ReflectionPermission sec =
new ReflectionPermission(
ReflectionPermissionFlag.AllFlags
);
sec.Deny();
PermisosReflect();
Console.WriteLine("after calling");
}
[STAThread]
static void Main(string[] args)
{
Deny();
Console.ReadLine();
}
}
}
|
|
|
|
|
Sorry i am new heer and didnt know how to post a message...so im just trying it out so Greetings all
|
|
|
|
|
Ρhoenix wrote:
Sorry i am new heer and didnt know how to post a message...so im just trying it out so Greetings all
You picked a bad spot to test if the site works ( which it obviously does, or there messages would not be here ), but welcome nevertheless.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
It'd probably be fairly easy to make a bot that'd post random stupid VB questions, and nobody would probably ever notice - benjymous - 21-Jan-2003
|
|
|
|
|
Hi Phoenix,
You are welcome to try sending greetings and other test messages. But perhaps you are just out of the track. CodeProject has forums like Lounge etc, where you can post messages, that do not fit into Programming environments.
Deepak Kumar Vasudevan
http://deepak.portland.co.uk/
|
|
|
|
|
IS there any clean solution to do that ? If you only use Windows Forms, the solution is 50% Clean by switching Language Property of Form ( much work...)
but what's about the text you use in your code, in your classes etc ? which way does microsoft provide, prefer ?
Any hints ?
.:Greets from Jerry Maguire:.
|
|
|
|
|
The probably easiest way to handle strings is to add Assembly Resource Files (for each supported language 1) to your application. Then use a System.Resources.ResourceManager to read strings from the Resource file. When getting a string, the CurrentCulture is checked and the correct string is retrieved. Let me know if this helps or you need further assistence.
Matthias
You'll never master any language, except maybe VB, because there's nothing to it. (Lounge/Christian Graus)
www.mattbart.org Sonork ID: 100.32002
|
|
|
|