|
My query is something as under:
1) I have a .ico file
2) Now I have a "System.Windows.Forms.Cursor" constructor which accepts a Stream object
containing a file of the type ".cur".
3) Now, putting the ".ico" file in a Stream and passing it to
the "System.Windows.Forms.Cursor" constructor
gives an argument exception.
So, is there is any way we can provide a ".ico" file to the "System.Windows.Forms.Cursor" constructor in a Stream?
|
|
|
|
|
No, not really. The problem is that there is information missing from an icon file that is needed to create a cursor, namely the click hotspot. You can't tell it exactly which pixel in the picture is used to determine where the user clicked.
|
|
|
|
|
|
thanks once again dave. the detailed scenario is as under:
My requirement description is as under:
1) I have a ".ico" file in the solution explorer that I created.
2) Now I have a "System.Windows.Forms.Cursor" constructor which accepts a Stream object. This is one of the ways we can instantiate a System.Windows.Forms.Cursor object by passing it a Stream object.
3) I also have a ".ico" file in the solution explorer with me. Now, putting the ".ico" file in a Stream and passing it to "System.Windows.Forms.Cursor" constructor gives an argument exception.
My queries are:
1) Does .Net support the process of providing ".ico" file to the
"System.Windows.Forms.Cursor" constructor in a Stream?
2) Does .net provide a way to take the ".ico" file in a MemoryStream
and convert it to some format acceptable by System.Windows.Forms.Cursor" constructor?
|
|
|
|
|
Hi,
it will not work.
read up MSDN on the Cursor Constructor (Stream)
and you will see the remark: The data stream specified by stream must contain a cursor (.cur) file.
So you can't just give it any stream you would like (ICO file, some image, whatever).
Conclusion: you must interactively create your cursor, I guess either using
Visual Studio or some other tool.
|
|
|
|
|
thanks a lot Luc. there is one last question I have in this context .
If I take the ".ico" file in a MemoryStream. Then can I convert this MemoryStream to contain the cursor result? I am sorry to bother you on this again and again . But your reply will really be useful. Then finally I can decide which way to select.
|
|
|
|
|
p_s_i_20070730 wrote: If I take the ".ico" file in a MemoryStream. Then can I convert this MemoryStream to contain the cursor result?
No.
I dont know ANY way to programmatically convert from or to cursor format.
|
|
|
|
|
The point your missing is that the data expected by the Stream constructor requires that it contains certion information and is formmated exactly how it expects as a stream of bytes. The data you're giving this constructor is not formatted for a cursor file and is not in the proper format. You simply cannot use the Stream constructor how you want.
You have to build an array of bytes, or write to a MemoryStream and write the data from the .ico file, massaged and reformatted for the .cur format. You must also place the bytes describing the click hotspot into this array in the place that the .cur file format expects. THen you can pass the MemoryStream to the Stream constructor of the Cursor class.
In order to do what you want, you have to be familiar with the file formats of both .ico and .cur files, down to the byte.
|
|
|
|
|
Hi Dave,
seems we are missing a Cursor constructor that takes an image
plus some extra parameters as arguments.
We can convert an image to an icon without knowing the icon format,
it takes say 5 lines of code using a stream. We would like to be able
to do something similar for image-to-cursor.
Do you have the code available to do it at the byte level ?
|
|
|
|
|
I don't have any code for it and don't know of any. I just posted how I would approach the problem.
|
|
|
|
|
thanks dave.
Can you please let me know if there is any code where the same has been implemented? it'll be of great help. some piece of code to convert the ico stream to cur stream
|
|
|
|
|
I don't have any code for it and don't know of any. I just posted how I would approach the problem.
|
|
|
|
|
You seem to have a very similar post just a minute back.
|
|
|
|
|
Hi,
I have a query. Can we convert a Memory Stream containing a ".ico" file to the Memory Stream acceptable by the System.Windows.Forms.Cursor constructor that accepts a stream containing ".cur" file?
|
|
|
|
|
hi
yes and no
the ico and cur have the same file structure.
two things are different:
1. in the header info the type is 1 (for ico is 2)
2. windows can only handle B/W cursors, therfore the lenght of the cursor file is smaller.
hier is a good example of manipulating icons in windows.
you also finde the file structure for icons
http://www.codeproject.com/cs/library/IconLib.asp
regards
|
|
|
|
|
I have a TreeView control that I have a set number of nodes in. How would I go about programmatically selecting a node with a known FullPath.
Thanks in advance for the help.
John 3:16: "For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life."
using Earth.Internet.WWW.CodeProject;
|
|
|
|
|
hi
i am new developer of Asp.net technology........
i am a student of B.E.Information technology ...........
i am trying to make project on onine gaming using c# .net and Asp.net....
so please give me suggetions of information for developing my project in betterway
thank you
purvi
|
|
|
|
|
purvi barot wrote: i am trying to make project on onine gaming using c# .net and Asp.net....
What kind of game are you thinking of?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I have not much more idea but i want to develope a game by using concepts of directX or OpenGL .... some what simple game for learning or say introductory game... If you have an idea suggest me game by which i can clear my concepts of my lannguage and this directX and OpenGL.....
puzzle type or some what logical ...........
my project target is uploading of game to website....... learning ASP.Net .... but i am somewhat interested in graphics so i want to develop a game so please give me idea and your suggetion
thank u for reply....
purvi
|
|
|
|
|
Hello purvi,
following are the points to speed up your execution
Avoids most of the If..Else..EndIf loops,
don't use goto
use "StringBuilder" class than "string"
Take the use of scripting(Mostly Javascript)
Use VisualStudio 2005 than VS 2003
Avoids unnecessary database connections and server trips
Best of Luck,
regards,
koolprasad2003
If the message is useful for U then please Rate This message...
Be a good listener...Because Opprtunity knoughts softly...N-Joy
|
|
|
|
|
Hi,
I am calling the FolderBrowserDialog.ShowDialog method and I am getting an intermittent SEHException - Control has raised an error, or something similar to that. I have Googled this, and have found some data saying that this may be a 64-bit windows problem (I'm running 64-bit Vista), and a suggested fix that says to use a static method to show the dialog. Both comments seemed to be from some poor soul like myself who has been struggling for a solution. Does anyone abouth this?
Cheers
SamM
|
|
|
|
|
What say you?
|
|
|
|
|
What?
--------------------------------
txtSignature
|
|
|
|
|
I think he wanted to know which would be better for enterprise development, WinForms or WPF...
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Have you seen the WPF articles that have been published here? They are all pretty slick and maybe the way to go soon
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|