|
If you don't want to use DirectX you could also interop the joy* Win32 functions.
There are just a few and they're really easy to use. Basically you call joySetCapture and then start receiving MM_JOY1MOVE , MM_JOY1BUTTONDOWN and the other joystick messages in your overridden WndProc .
The only disadvantage is that WindowsXP messed up the joySetCapture /joyReleaseCapture functions. Trying to open a Joystick a second time in your application (after releasing it first, of course) fails with some obscure error, but only with WindowsXP.
Hope this helped,
mav
|
|
|
|
|
Couple of questions about ListView:
Is there a way to make column headers invisible?
Is there a way to increase the padding between rows?
I have long text inside of some cells. How do I make the text wrap around and the cell height grow to make all the text visible? (instead of having the text all in one line and having to resize the column to read all of it.)
Thanks,
Elena
|
|
|
|
|
The first is simple: set ListView.HeaderStyle to ColumnHeaderStyle.None .
For the latter, I urge you to search CodeProject for "ListView" or something simple and browse the results. There have been several articles detailing this. It's not an easy thing to handle, since you have to go back to handling windows messages, declaring structs, and interoperating with unmanaged code using P/Invoke for functions like SendMessage .
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Is there any way to access and delete cookies obtained by the Microsoft Web Browser Control?
|
|
|
|
|
You need to P/Invoke InternetGetCookie :
[DllImport("wininet.dll", CharSet=CharSet.Auto, SetLastError=true)]
static extern bool InternetGetCookie(string url, string name, [Out] string data,
ref int size); Do not declare the third param using out , be sure to use the OutAttribute as I've done above. A String (C# alias string ) is already a reference type, so you're already passing the address of a string variable. Double referencing will crash the CLR.
To call it, consider a wrapper method since P/Invoke methods should not generally be exposed as public members (depending on if you're writing a library or just using this in an app):
public string GetCookie(string url, string name)
{
int size = 0;
string data = null;
if (!InternetGetCookie(url, name, null, ref size))
{
if (Marshal.GetLastWin32Error() == 122)
{
data = new string('\0', size);
if (InternetGetCookie(url, name, data, ref size))
return data.Trim();
}
}
return null;
} You'll still need to parse the cookie string, though, but that should be simple.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Once I got the cookie, do you know what I would have to do to delete it? Also, let's say I wanted to return all cookies for a specific website. I understand I pass in the homepage of the website as "url", but what do I pass in for "name"? Thank you
|
|
|
|
|
I recommend you read about the WinInet Functions[^] on MSDN Online.
If you want to know more about InternetGetCookie , you should read[^] about it on MSDN Online as well, which is under the WinInet Functions that I posted a link to above.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
hi you all
im working on a paint project and i need some help with the rectangle select tool. id appreciate all the help i can get...
|
|
|
|
|
What help do you need ? I've got a paint program here on CP called Doodle which may have the tool you're looking for. I can't remember, but I suspect it's in C++. It would be dead easy to port tho.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
hi chtristian, thanx for replying .yes id really appreciate it if you send me the doodle program . thanx again
|
|
|
|
|
To reiterate - I have an article here on code project which creates a simple paint program called doodle, you should read the article and download the code, it will probably help you.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
First let me thank you guys, for sharing your knowledge and for responding.
I am a newbie learning .NET, so plz bear with me. my question is, how to bind a CheckedListBox control in a WinForm. I did the binding, but it is not showing any values, it's not giving any error either, I wanted the CheckedListBox control to be populated at the FormLoad Event.
my code is given below. I tried different ways, but still its not working.
lstFacilityType is a CheckedListBox control.
First, I tried this.
-------------------------------------------------------------------------
lstFacilityType.DataBindings.Add(new Binding("Text",ds,"FacilityType"));
-------------------------------------------------------------------------
Second, I tried the code given below, it is returning the table in the dataset.
------------------------------------------------------------------------
lstFacilityType.DataBindings.Add(new Binding("Text",ds.Tables[0],"FacilityType"));
------------------------------------------------------------------------
Thanks, for ur help.
abhi
|
|
|
|
|
If you're trying to bind the actual list, you need to need to fill the Items property manually. Binding the Text only binds the Text property.
You should read about the DataBindings property and the BindingManagerBase class in the .NET Framework SDK.
The code you're doing above needs to bind to the Text property of the control for which the Binding is added (i.e., lstFacilityType ). The rest of your expressions won't work, however, because the Binding only works for PropertyManager , not to bind to an IListSource or IList , of which DataSet and DataTable are (respectively). When you bind to a data-bound control like a DataGrid , it nows how to use the DataSource and, optionally, the DataMember to enumerate the collection and bind a UI element to that row. Binding how you're doing it is not the same. The results you're getting are to be expected since you're binding against an object, not its value.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
I have two treeviews in a windows application.(leftside and right side)
and there are some nodes in these two treeviews.I want to drag a node from the left treeview to another node in the right treeview.
When the user drag- drop it,a line will be drawed between these two nodes.How can I do this?Could you help me pls?
|
|
|
|
|
Dragging and dropping a TreeNode is rather simple. You first pack the TreeNode into a DataObject and call TreeView.DoDragDrop . If both TreeView s were to handle drag and drop, it'd look something like this example:
public class DragDropTreeView : TreeView
{
public DragDropTreeView()
{
AllowDrop = true;
}
protected override void OnItemDrag(ItemDragEventArgs e)
{
TreeNode node = e.Item as TreeNode;
if (node != null)
{
DataObject data = new DataObject("TreeNode", node);
DoDragDrop(data, DragDropEffects.Copy);
}
}
protected override void OnDragOver(DragEventArgs e)
{
if (e.Data.GetDataPresent("TreeNode") &&
(e.AllowedEffect & DragDropEffects.Copy) != 0)
e.Data.Effect = DragDropEffects.Copy;
}
protected override void OnDragDrop(DragEventArgs e)
{
TreeNode node = e.Data.GetData("TreeNode") as TreeNode;
if (node != null)
{
Point p = PointToClient(new Point(e.X, e.Y));
TreeNode parent = GetNodeAt(p);
if (parent != null) parent.Nodes.Add(node);
}
}
} Drawing lines in between is not so easy, but I'll set you on the right course. I don't have the code I once wrote to perform that, and it is definitely a long, drawn-out solution. I do recommend you try searching this site for examples.
Basically, you need to keep track of state. So in OnItemDrag set some bool variable to true . In any override that would stop dragging and dropping (including OnDragLeave for when the mouse moves outside your client area), reset that variable to false .
In an override to OnPaint , if this variable is set (i.e., true ), you convert the current mouse coordinates to client coordinates like I did above to get a nearby TreeNode . From that you offset your line coordinates and draw a line using PaintEventArgs.Graphics (do not call CreateGraphics since you already are given one for the current paint operation). There's a few problems you must handle, though. The offset should be between two nodes and there's lots of properties you have to take into account, otherwise the line may change positions slightly and that wouldn't look good.
Make sure you do this in OnPaint . If you do a one-trime draw using CreateGraphics to get a Graphics object (always dispose of them, except when in OnPaint since the base handler will when finished), then anything covering the screen (including a drag image if you implement one - also not easy) will cause the background to repaint and your line (or part of it) will not show. Also do not try to get around this by drawing a line every time the mouse is moved. That is a very expensive operation and will hog system resources.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
I am writing HTML documentation for a C# project. When I include <see cref="membername"> in the documentation it is rendered exactly that way in the HTLM generated by Visual Studio 2003 "Build Comment Web Pages ..." on the Tools menu. However it is not rendered at all by my IE 6 browser. Anyone have a clue about this?
Gary Hyslop
|
|
|
|
|
Without any specifics, no one can really help you.
If you believe this is a problem with the HTML, please post your questions in the Web Development[^] forum.
I also urge you to check out NDoc[^], a project I've had the pleasure to work on and that is used widely by the industry to generate many different formats from C# (and not VB.NET) comments.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Please anyone help me!! I am doing an Expression Tree Parser project and I would like to demonstrate a tree with nested nodes that holds the operands and operators, it is easy to implement in design time but I failed to implement it at run time please anyone reply to me and give me some hints.
Note: (they must be nested nodes and not separated nodes)
Koko Wawa
|
|
|
|
|
This is really simpler than it may appear.
Example:
preface
|____ adjective
|____ noun
verb
target noun
|_____adjective
|_____adjectiveCollection
|_____noun
|___connector
|___adjective
|___noun
So here is a possible tree of a sentance.
Programmatically you would do as follows:
Create treenode named preface.
Create treenodes named adjective and noun. add these nodes to the preface.Nodes .
Add preface to control.Nodes .
Create treenode named targetNoun.
Create treenodes for adjective, adjectiveCollection, and noun and add to targetNoun.Nodes .
Create connector, adjective, noun and add these treenodes to noun.Nodes .
Add targetNoun to control.Nodes .
Create verb and add verb to control.Nodes .
You can do this more randomly if you are populating from a database using the Find method. So you get a node that is a parent. You add that node to the control. When you read a child record, you Find the parent node, create the child, and add to the parent.Nodes collection.
This signature left intentionally blank
|
|
|
|
|
I need to set up an automated email system , which means users should
not be able to respond back to the emails but at the same time, we
need to track bounced emails. This is important as our customers are
paying for this service, so we need to track the bounced email Id's.
This is the code which I have tried:-
MailMessage msgRequest = new MailMessage();
msgRequest.BodyFormat = MailFormat.Text;
msgRequest.Subject = "Do Not reply to this email";
msgRequest.To = "Customer1@abc.com";
msgRequest.From = "automated@company.com";
msgRequest.Body = "Message Body";
msgRequest.Headers.Add("Return-Path", "validemailId@company.com");
//msgRequest.Headers.Add("Errors-To", "validemailId@company.com");
SmtpMail.SmtpServer = "SMTPServerName";
SmtpMail.Send(msgRequest);
I have tried both "Return-Path" and "Errors-to". But both of them
falied. The functionality that users cannot reply us back works fine
with this code but this code fails in tracking bounced emails. So for
invalid email id in "To", have no action reported to "return-path" or
"errors-to" valid Email Id.
I have also tried doing this:-
MailMessage msgRequest = new MailMessage();
msgRequest.BodyFormat = MailFormat.Text;
msgRequest.Subject = "Do Not reply to this email";
msgRequest.To = "Customer1@abc.com";
msgRequest.From = "validemailId@company.com";
msgRequest.Body = "Message Body";
msgRequest.Headers.Add("From", "automated@company.com");
SmtpMail.SmtpServer = "SMTPServerName";
SmtpMail.Send(msgRequest);
Using this code, user only sees automated@company.com and never sees
validemailId@company.com so they cannot reply us back. But again this
code fails for tracking bounced emails. It doesnt send me bounced
emails at validemailId@company.com.
Can somebody suggest me what is going wrong here?
Quick response will be really appreciated and Thanks in Advance for
any help.
Simran.
|
|
|
|
|
And what code do you have to track bounced emails? This is a function of the SMTP server. Since SmtpMail.Send uses CDO (provided by Microsoft SMTP Services or Microsoft Exchange), an exception may be thrown but it depends on the queue for the SMTP server.
It's the SMTP server that gets the bounces, not you, nor can you unless you are the SMTP server. You could always consider writing your own, but I don't recommend it. There's a lot more to do than you might realize, but most SMTP servers let you hook functionality (I know that Exchange and sendmail do).
One other option is to write your own SMTP client. Remember, SmtpMail uses CDO (a COM server), but SMTP clients only need a telnet connection to the MX host (mail exchanger), the communication is pretty easy.
I've posted code several times in this forum in the past for both MX-lookups as well as SMTP clients. I recommend you click "Search comments" directly above this message board and search for "SMTP" or something simple.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Thanks for replying, but the problem is that if I write this code without using any headers for return-path, I get bounced emails back immediately in the account which I mention in "From".
MailMessage msg=new Message();
msg.To="Some Invalid Email Id";
msg.From="validComapnyEmailId";
msg.Body="message";
.....
But the thing is I dont want to give valid Email id In "From" because we dont want our users to reply back but we still want to track bounced emails.
I have tried all options and Dont know, where I am doing wrong.
Simrang
|
|
|
|
|
Again, this is entirely a server feature. If you don't want a "valid" email address (i.e., a mailbox to where mail is delivered), the SMTP server has to queue bouces and deal with them appropriately. This is greatly specific to an SMTP server and has absolutely nothing to do with C#.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
In addition to what Heath said, depending on the server that your SMTP server is trying to send the mail to, it may take quite a while to get a bounce message back from the destination server. I've seen bounce messages take over 6 hours to come back telling me there was a problem.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for replying, but the problem is that if I write this code without using any headers for return-path, I get bounced emails back immediately in the account which I mention in "From".
MailMessage msg=new Message();
msg.To="Some Invalid Email Id";
msg.From="validComapnyEmailId";
msg.Body="message";
.....
But the thing is I dont want to give valid Email id In "From" because we dont want our users to reply back but we still want to track bounced emails.
I have tried all options and Dont know, where I am doing wrong.
|
|
|
|
|