473,387 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

ImageList for Console Application

I am experimenting with a concept the engineers want.

I want to create an app that runs in the console. When an event happens, I
want to display an image.

Can I do this without having a form?

Right now, my app compiles, but crashes with an unhandled exception at this
part:
//
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)
resources.GetObject("imageList1.ImageStream")));
//
It is erroring because I do not have anything called "imageList1.ImageStream".

How would I define something like this?

I included a Resources.resx file, and loaded several images into it. I just
don't know how to access them.

Can anyone help?
Mar 18 '08 #1
1 1458

I guess one off the wall idea is to write out the the TEMP folder. And pop
the default application.

I don't know if this will work with a stream from the resource..but here is
my crappy string/file version.

It should convey the idea.

If you swap out to an image file extension
fileName = fileName.Replace(".tmp", ".jpg");
and work out the details of the stream writing..maybe its a poor man's fix
for showing images with a console application.

public void Test1()

string fileName = WriteToTempFile("Hi There");
System.Diagnostics.Process.Start(fileName);
}

public string WriteToTempFile(string toWrite)
{

System.IO.StreamWriter writer = null;
System.IO.FileStream fs = null;
string fileName = string.Empty;
try
{

// Writes text to a temporary file and returns path
fileName = System.IO.Path.GetTempFileName();
fileName = fileName.Replace(".tmp", ".txt");
fs = new System.IO.FileStream(fileName,
System.IO.FileMode.Append, System.IO.FileAccess.Write);
// Opens stream and begins writing
writer = new System.IO.StreamWriter(fs);
writer.BaseStream.Seek(0, System.IO.SeekOrigin.End);
writer.WriteLine(toWrite);
writer.Flush();

}
finally
{
if (null != writer)
{
writer.Close();
}
if (null != fs)
{
fs.Close();
}
}
return fileName;

}



"jp2msft" <jp*****@discussions.microsoft.comwrote in message
news:1F**********************************@microsof t.com...
>I am experimenting with a concept the engineers want.

I want to create an app that runs in the console. When an event happens, I
want to display an image.

Can I do this without having a form?

Right now, my app compiles, but crashes with an unhandled exception at
this
part:
//
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)
resources.GetObject("imageList1.ImageStream")));
//
It is erroring because I do not have anything called
"imageList1.ImageStream".

How would I define something like this?

I included a Resources.resx file, and loaded several images into it. I
just
don't know how to access them.

Can anyone help?

Mar 18 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Chuck | last post by:
When ever I try to implement an ImageList, I always get an exception when the application runs. The ImageList doesn't even have to be used by anything. An empty ImageList doesn't throw! The...
3
by: Ian | last post by:
Hi, I've been trying to create a listview and treeview with icons. You would think it's a pretty straight forward task. API documentation states you simply assign an ImageList - that's been...
0
by: Friedhelm Drecktrah | last post by:
Hello, I filled an ImageList with some images (jpg, size 320 x 320) and usd a ListView to display them (View = LargeIcon). When I RemoveAt the Images, for one remove 2 Images will be deleted,...
2
by: Sanjeeva Reddy | last post by:
hai Anti Keskinen, i have used the following code MyListView->LargeImageList->ImageSize = gcnew System::Drawing::Size(100, 100); // Sets large image size to 100, 100 here i am getting error...
7
by: Andrew Christiansen | last post by:
Hey everyone. I have Visual Basic .NET 2003 and am trying to show images on a treeview control. I have the imagelist on the form filled with images, and have the ImageList property of the...
6
by: henrycortezwu | last post by:
Hi, I have a WinXPSP2, P4 3.2GHZ, 1GIG RAM on my dev machine using VS2005 VB.NET. I did the following procedure: 1. Added 82 icons (128x128 in size & 32bit Depth) in an imagelist control 2....
0
by: wolffy | last post by:
okay heres my problem; i want to add image K to a imagelist, thats easy. The hard part is that the imagelist was made in Application Settings. **I made the imagelist in application settings so i...
10
by: Paul E Collins | last post by:
I want to fill an ImageList with bitmaps for a ListView from another thread, because it's a time-consuming process. I expect the ListViewItems' images to "load" one by one, as in a Web browser. ...
2
by: =?Utf-8?B?S2VuTg==?= | last post by:
We're using a System.Windows.Forms.ImageList to store a bunch of Images that I've loaded, and rendering each image in the ImageList during a draw loop. The process was running unusually slow and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.