|
Hi,
I am trying to send a list of urls to the clipboard from my app which will be caught by a download manager. I have got it to work with a single url no problem, but when I select multiple items (in a ListView) the app crashes after the first URL has been sent to the clipboard.
This is the code I am using;
public void mnuDownloadItem_Click(object sender, System.EventArgs e)
{
// Some variable declarations
int i = 0;
String sCurrentURL = "";
// This stops it crashing when the listView is empty
if (listView1.SelectedItems.Count != 0)
{
for(i=0; i < listView1.SelectedItems.Count; i++)
{
sCurrentURL = listView1.SelectedItems[i].Tag.ToString(); Clipboard.SetDataObject(sCurrentURL);
}
}
}
Would appreciate any help with this.
Thanks
Paul Mason
|
|
|
|
|
What exception is being thrown?
I see nothing wrong with your code as is; so the exception would help diagnose the problem
James
Sonork ID: 100.11138 - Hasaki
"My words but a whisper -- your deafness a SHOUT.
I may make you feel but I can't make you think." - Thick as a Brick, Jethro Tull 1972
|
|
|
|
|
Hi,
First thanks for the reply! Secondly after some more experimenting I've found it isnt actually my application raising the exception, its external and is in the download manager (Flashget) which is catching the clipboard copies.
So Im wondering if its perhaps sending the copies too quickly for Flashget to catch them, would there be any way I can insert a short pause to test that?
Im sure its now pasting OK as I checked the last URL on the clipboard against my ListView and it matched.
Thanks Again
Paul Mason
|
|
|
|
|
Just need some advise:
I need to find possibility of converting existing pretty complicated MFC SDI Application, which is dynamic Control Container into C#?...
OK, it's enhanced version of MFC Application created by VisualStudio (MDI + Compound Document Both Container and Server + Active Document Server + Support for Compound Files + Automation + ActiveX Controls...
How and where should I start?...
Any recommendations or possibly samples??
Maybe it's wrong idea??...
Any views on that subject, please!!!
Thank you,
Igor
Happy Valentine
|
|
|
|
|
Hi guys, I'm trying to draw an icon onto the surface of a form. What I do is create the icon in the bitmap editor in VS.NET and then perform the following in my Form's code
private Icon myIcon
...
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
myIcon = ((System.Drawing.Icon)(resources.GetObject("icon1.ico")));
... myIcon however is always null
It's a simple matter I'm sure but I'm brain dead at the moment. How can I make sure that I have a valid icon instance in this case?
Regards
Senkwe
Just another wannabe code junky
|
|
|
|
|
Just looking at form designer generated code I get this:
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
I seems like it gets the icon out of the associated resx file.
--
Peter Stephens
|
|
|
|
|
Thans, I'll give that a try
Regards
Senkwe
Just another wannabe code junky
|
|
|
|
|
I have a P2P .Net Service that is connecting to another machines P2P .Net Service using Sockets. I would like both of these services to pass along a username and password so each P2P service can authenticate against the local security list. (win2k OS)
1) After getting the username and password from the other machine, what method/WIN API can I call to authenticate the remote user?
2) I’m apparently going to have to store the username and password somewhere on the remote machine. Any Ideas about the best (most secure) way of doing this.
a. Encrypt it to disk?
b. Registry?
Thanks in adance,
Brad Cooper
|
|
|
|
|
Hello there....
I am new to c# (and c like languages in general) and I am trying make a user defined control - essentially just a graphic with a few methods for moving it around and collision detection etc (guess what I am trying to write!).
So far I think I have got my head around overriding the onPaint method for my new control, and in this overridden method I construct a simple polygon out of an array of points. Now, I think I have conquered the collision detection (in a somewhat shoddy manner I am sure) but for can't work out how to make my control background transparent - the only part of the control I want displayed is the polygon, but instead I get the polygon and the control background (a grey rectangle or whatever colour I set it to).
My current investigations are leading me in the direction of Control.setStyle but can't quite get it right. Can anybody please help me?
Incidentally, I have tried setting the paintEventArgs.graphics.cliparea to be a region that matches the polygon, but I still get the graphics object background being displayed.
Write soon, and save me a headache.
Cheers,
Jason King
jason.king@profox.co.uk
Feel the love at www.profox.co.uk
|
|
|
|
|
I've just done a quick check and it seems user defined controls ie, anything derived from UserControl (or Control I think) cannot set it's BackColor property to transparent. Why not set the controls BackColor to be the same as the BackColor of the form containing the controls?
Regards
Senkwe
Just another wannabe code junky
|
|
|
|
|
Hi Senkwe,
Thanks for taking the time to help me. I have tried your idea but nfortunately your suggestion does not solve the problem.
My polygon represents an irregular shape - actually, an asteroid.
The foreground is, say, red - yes, a red asteroid (and why not?).
The background which c# paints it on is the same colour as the form (grey).
It is possible to change the background colour to black, green etc etc. When you do this, you get a red asteroid in a black (or whatever) rectangle.
When two asteroids overlap slightly the rectangle from one blocks out (is on top of) the other asteroid - this is my problem. All asteroid need to be drawn on a transparent rectangle so that their canvasses do not obscure each other.
If you look at control.settype, it seems there may be a way to make the background colour transparent, in fact I have managed this, however, the asteroid is redrawn very slowly.... here is some of the code from the constructor of asteroid:control
public asteroid(int startX, int startY, int incX, int incY, Form theForm)
{
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.backgroundColor = Color.FromArgb(1,Color.Gray);
...
I think I will tidy up my code and paste here for people to read. As an additional problem, when I am performing collision testing, I have a peculiar problem that seems to be inconsistent. When I create a rectangular region from my asteroid control, I can use region.isVisible(point) to test whether point is included in the region. This works. When I create an asteroid shaped region (instead of a rectangular shape), the call to region.isVisible(point) always seems to return false. Perhaps I am misunderstanding the region concept. Any ideas?
Jase
jason.king@profox.co.uk
Feel the love at www.profox.co.uk
|
|
|
|
|
One thing that might speed up your drawing code is to enable double buffering, then all of your graphics drawing is done in system memory; then copied to video memory once; by passing the system->video bottle neck.
Hope that helps a little,
James
Sonork ID: 100.11138 - Hasaki
"My words but a whisper -- your deafness a SHOUT.
I may make you feel but I can't make you think." - Thick as a Brick, Jethro Tull 1972
|
|
|
|
|
Thanks to the 2 people that helped me out. Neither solution really helped that much, but I did learn, so that's a good thing.
In the end, to remove background rectangles, I made one big background rectangle and drew everything on that, in other words, I painted everything on one canvas (instead of one canvas per game character). This seems to have done the job nicely.
If anyone wants to see the finished code, drop me a mail.
Jase
Jason King
jason.king@profox.co.uk
Feel the love at www.profox.co.uk
|
|
|
|
|
I want to buy two books:
One C# book, and one .NET book.
Which books should I choose?
|
|
|
|
|
Øyvind Bratland wrote:
C#
I have "Beginning C#" by "wrox".Thats average,not bad not excellent.
Mazy
Don't Marry a Person You Can Live With...
Marry Someone You Can Not Live Without
|
|
|
|
|
I want "the ultimate" books, not average ones
|
|
|
|
|
I'm holding out for the .NET book by Jeff Prosise. According to Amazon its coming out in May. You can read the daily progress in Jeff's BLOG.
I am also waiting for a good book on .NET remoting (esp. the internals).
As the language C# goes, I had no problem learning it through the MSDN docs. Aside from the .NET framework, C# is little more than syntax. If you know how to utilize the .NET framework you will understand how to program in C# (minus a few minor details).
--
Peter Stephens
|
|
|
|
|
I read Jeff's BLOG every day, but May.... it's so long!
Øyvind
|
|
|
|
|
Peter Stephens wrote:
I am also waiting for a good book on .NET remoting (esp. the internals).
Ingo Rammer is writing a book on remoting, titled Advanced .NET Remoting, but like Jeff's it will come out in May as well :-P
Ingo's site.
Judging from the contents it looks like it'll cover what you need
James
Sonork ID: 100.11138 - Hasaki
"My words but a whisper -- your deafness a SHOUT.
I may make you feel but I can't make you think." - Thick as a Brick, Jethro Tull 1972
|
|
|
|
|
Yes, that's the book I'm interested in (couldn't think of the author at the time.)
In the mean time, I am reading the source code for the .NET framework (also known as ILDASM) and hacking away.
--
Peter Stephens
|
|
|
|
|
I would recommend
Programming Windows in C# : Charles Petzold
Programming C# - Jesse Liberty
and Jeffery Richter has an excellent book out, i think, "Applied .Net Framework Programming" and the one I am holding out for as well is Prosise's book in April.
Check out this link Microsoft C# Books
I have read "Inside C#" : Archer, it is alright , but somewhat general with no in-depth examples.
Good luck !
=============================================
S liant - soliant@yahoo.com
|
|
|
|
|
>>>
I have read "Inside C#" : Archer, it is alright , but somewhat general with no in-depth examples
<<<
The first edition of Inside is a beginner-level book as it was released just a few months after the PDC and what was needed at the time. However, my second edition has much more internals information for the more intermediate to advanced programmer. I've listed the changes on my site if you care to check them out.
If you like Jeffrey's book then you'll also like mine as we both had the same editors and go to the same level of detail in our books.
Cheers,
Tom Archer
Author, Inside C#
|
|
|
|
|
When will the second edition of Inside C# be out, then?
|
|
|
|
|
It will be in book stores in May. Since Jeff, Jeffrey and I all write for the same publisher, the books are designed to compliment one another and come out in the same time frame. Jeffrey's just came out a bit earlier because it's much smaller than ours.
Cheers,
Tom Archer
Author, Inside C#
|
|
|
|
|
Hmm... Maybe I'll go for "C# and the .NET platform" by Andrew Troelsen now, and then "Inside C# SE" and the book from Prosise in May.
|
|
|
|