|
In my application, I've created a zip where I store several pictures (256 colors gif)
When my application is loaded, I want to open the zip and load the gif in memory, but it doesn't work as I want, and I'd like some help.
Here is what I do( it's very simplified)
Method 1:
FileStream stream
// Read the contains of the zip with this stream,
// it create Foo.gif (this part works)
stream.Close();
Bitmap Picture = new Bitmap ("Foo.gif");
File.Delete("Foo.gif");
I don't want to keep the file on the hard drive, so I delete it once it is loaded. Pb : I got an error message at runtime "Foo.gif used by another process", and I cannot delete it. But the Stream is supposed to be closed. How can I delete this file?
Method 2:
Instead of using a FileStream to read the zip and save it, I use a MemoryStream, and I create the picture from this stream. It works. Almost. Instead of a 256 colors picture, It create a 32bppArgb picture, so it takes a lot of memory.
Any idea of how I can access the picture in my zip, use them as 256 colors gif, and still be able to delete the picture once I'm done loading it?
|
|
|
|
|
Hai ,
Iam new to C# programming.Iam having a problem when i try to develop a .NET component using COM+ Services. Iam calling a function in a dll
from my component.But it is giving a Build errror saying that the dll is missing the strong name file. I don't have the code for the dll to edit and give strong name file.That dll is developed using VC++.I will be thankful if anybody helps me.
Thanks in advance.
P Ranadheer
M.Tech(CSE)
|
|
|
|
|
hi Guys
how to save a picture in the datadabses , i would be greatfull if u ppl tell me how to load picture in a picture box by using file open dialog , i m looking forward for ur reply
thx
Work Hard and Test your Luck
|
|
|
|
|
Birdy wrote:
how to save a picture in the datadabses
Probably, you'd be best storing the filename in the DB, and storing the images themselves in a different folder. Just my 2c.
Birdy wrote:
i would be greatfull if u ppl tell me how to load picture in a picture box by using file open dialog
Here's for starters (not tested, but should work):
void OpenBitmap()
{
OpenFileDialog dlg=new OpenFileDialog();
ImageCodecInfo[] decoders=System.Drawing.Imaging.ImageCodecInfo.GetImageDecoders();
string allfiltersname="All Supported Bitmap Files (";
string allfilters="";
ArrayList filters=new ArrayList();
for(int i=0;i<decoders.GetUpperBound(0);i++)
{
allfilters+=(i==0?"":";")+decoders[i].FilenameExtension;
filters.Add(decoders[i].CodecName+
" (" + decoders[i].FilenameExtension + ")|" +
decoders[i].FilenameExtension);
}
dlg.Filter=allfiltersname+allfilters+"|"+allfilters+"|"+
String.Join("|",((string[])(filters.ToArray(typeof(string)))));
dlg.Title="Open a Bitmap";
dlg.ShowDialog((IWin32Window)this);
if(dlg.FileName!="")
{
Bitmap b=null;
try{b = new Bitmap(dlg.FileName);}
catch(Exception e)
{
MessageBox.Show(
"The bitmap could not be loaded, because there was an error:\r\n\r\n" +
e.ToString(),
"Error Loading Bitmap!",
MessageBoxButtons.OK,MessageBoxIcon.Error);
}
if(b!=null)
{
}
}
}
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
how can I copy a file to a server?
is it using file.copy???
Nisrine
|
|
|
|
|
Yes.
Using System.IO;
...
File.Copy(SOURCE,TARGET);
or
File.Copy(SOURCE,TARGET,OVERWRITE); where overwrite is true/false
|
|
|
|
|
Is there a way to trap a mouse click on your taskbar window button.
My application does not have the title bar. So am facing two problems.
1. I cannot restore my application by clicking on the taskbar window button, if it is minimized.
2. On Windows 2000 if I choose Minimize All, my app is not minimized along with the other apps.
Help wanted badly!!!
Thanks,
Blade
|
|
|
|
|
I have a ContextMenu with about a dozen MenuItems in it. I've assigned the ContextMenu property of several NumericUpDown controls. When the user right-clicks one of the NumericUpDown controls and then selects a MenuItem from the ContextMenu. This triggers the MenuItem's Click event.
Within the MenuItem's event handler, I need to determine which NumericUpDown control called the MenuItem so I can set the Value property of the NumericUpDown to the appropriate value.
The problem is, I cannot seem to make this happen. The SourceControl of the ContextMenu has a type of "UpDownBase+UpDownEdit". I've found UpDownBase in the docs, but I get casting errors whenever I try to get to the value of the NumericUpDown. Such as...
private void miProg010_Click(object sender, System.EventArgs e)<br />
{<br />
MenuItem mi = (MenuItem) sender;<br />
ContextMenu cm = mi.GetContextMenu();<br />
Control c = (Control) cm.SourceControl;<br />
UpDownBase udb = (UpDownBase) c;<br />
}
Any ideas?
-- James --
|
|
|
|
|
So I kept working on it and discovered the following: The NumericUpDown is a contol composed of other controls. If the user pulls up the context menu by right-clicking the TextBox area of the NumericUpDown, the the ContextMenu's SourceControl can be cast to a TextBox, or you can get the parent of the TextBox which will be the NumericUpDown I was originally seeking. If the user right-clicks the spinner portion, the ContextMenu's SourceContol is the NumericUpDown directly.
So the code that does what I was asking is here:
private void miProg010_Click(object sender, System.EventArgs e)<br />
{<br />
MenuItem mi = (MenuItem) sender;<br />
ContextMenu cm = mi.GetContextMenu();<br />
NumericUpDown nud = null;<br />
<br />
if (cm.SourceControl.GetType() != typeof(System.Windows.Forms.NumericUpDown))<br />
nud = (NumericUpDown) cm.SourceControl.Parent;<br />
else<br />
nud = (NumericUpDown) cm.SourceControl;<br />
<br />
nud.Value = 10;<br />
}
Hopefully this saves someone out there some grief.
-- James --
|
|
|
|
|
Is it possable to grab the Printer settings dialog and postion it where ever I want? I notice that when calling the printer settings dialog, it always goes to the centre of the screen, where I want it to go to the centre of my program
|
|
|
|
|
Since you can't derive PrintDialog , you're going to have to rely on owner messages, which hopefully should work (does in Win32, which the CommonDialog /PrintDialog classes use, but this is untested).
Override the WndProc method of your form (or add a message filter to the Application object, but this can be more difficult to implement). Assuming that the PrintDialog passes messages up the chain, you can access the dialog from the Message.HWnd property. You could run a little test to see if you're getting messages (like mouse messages, just insert a Debug.WriteLine in a test handler to see). If you are, you can handle the WM_INITDIALOG (0x0110) message and P/Invoke a call to SetWindowsPos , passing the HWND of the dialog along wit new site and position information.
See the PSDK docs for more details on SetWindowPos and messaging.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I can get my toolbar to work when clciking a button, but I want to be able to tell - is what button I right clicked on.
Has anyone any idea how to do this?
|
|
|
|
|
Other than overriding the Toolbar class and using Win32 messages to do some of this, or using a pre-canned and much-better toolbar out there (like from Magic controls), there is a completely managed way of doing this.
Hook-up an event handler for either the Click event, or the MouseUp or MouseDown events. Using the Click event does warrant some extra code, but gives you some things for free (like detecting if the user escaped and message before you handle the "up" event). You can get the screen coordinates using the Click event, then use Control.MousePosition to get the screen coordinates, then use Control.PointToClient to get the form coordinates. If you use one of the Mouse* events, you are given the form coordinates.
Then, pass the Point to a function like so:
private ToolbarButton GetButtonFromPoint(Point p)
{
foreach (ToolbarButton btn in myToolbar.Buttons)
{
Rectangle r = myToolbar.RectangleToClient(btn.Rectangle);
if (r.Contains(myToolbar.PointToClient(p)))
return btn;
}
return null;
} You might have to fiddle with the coordinate conversion a little to make sure it works. This code is untested but should give you the basic idea.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Does anyone know how I can draw a dashed or dotted line. I dont seem to be able to get amywhere using System.Drawing.Graphics short of drawing lots of little line. This can be right.
tia
gadget
www.FUXUP.com[^]
|
|
|
|
|
You set it in the Pen that you use to draw (the first parameter in all overloaded Graphics.DrawLine methods). There are many properties (mostly, DashStyle ) that you can set to do dashed lines, and dictate the frequency, length, etc. of those lines.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
If you still have any questions about what all the options are you can check the following article out on the MSDN.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdrawingpenclasstopic.asp
|
|
|
|
|
Thanks, I new there was a way - I just couldnt find it.
|
|
|
|
|
am trying to load JPEG2000 (J2k) image and make use of the scalability features provided by J2k
by showing the image while loading. The tutorials clearly show that there are two possible “modes”:
- Progressive by resolution (You load the picture and it becomes sharper while loading, something
like interlaced GIF)
- Progressive by accuracy (ROI – region of interest)
I am interested in the first: “Progressive by resolution”. So I want to show the image while loading
for example if you download a 2 MB image through Modem connection.
I am looking for a exemplary implementation - does not matter in which language or platform it is running.
I would be grateful for any help.
Regards,
gicio
|
|
|
|
|
Hello, Everyone!
This is my very first post here, and I'm hoping someone can help me out.
I'm not even a novice C# programmer (DBA by trade) but I have a small app I'm working on and need to import a CSV text file into an MS Access Database table using C#.
If anyone can help me out with some sample code I would be very grateful. (I'll even help ya out with SQL code if you need! =)
~Best Regards!
Ray Sotkiewicz
T-Mobile USA
raymond.sotkiewicz@t-mobile.com
|
|
|
|
|
The first thing you want to do is import that CSV file into a Dataset... Best shown here: http://www.codeproject.com/cs/database/asc2xxx.asp[^]
Then you can use that data set to create a table in the access database. Do you need help on that end also?
// Steve McLenithan
Family Guy: Season 2 - Episode 8
|
|
|
|
|
I'm trying to read the StandardOutput of a process while it is running, but I'm unable to read anything from the StandardOutput before the process actually finishes. Here's what I currently have. I was trying to multithread it in the hope that that would solve the problem but it still doesn't, although it doesn't hang up my whole application anymore The method PutFiles is called first:
<br />
public void PutFiles(string FilePath)<br />
{<br />
string args = "-r -pw " + m_Password + " " + FilePath + " " + m_UserID + "@" + m_Address + ":" + m_CalcPath;<br />
m_ProcessArgs = args;<br />
m_ProcessApp = "pscp.exe";<br />
Thread myThread = new Thread(new ThreadStart(TransferProcess));<br />
myThread.Start();<br />
}<br />
<br />
private void TransferProcess()<br />
{<br />
ProcessStartInfo pInfo = new ProcessStartInfo(m_ProcessApp,m_ProcessArgs);<br />
pInfo.UseShellExecute = false;<br />
pInfo.RedirectStandardOutput = true;<br />
pInfo.RedirectStandardError = true;<br />
pInfo.CreateNoWindow = true;<br />
m_Running = Process.Start(pInfo);<br />
m_StdOut = m_Running.StandardOutput;<br />
Thread InfoThread = new Thread(new ThreadStart(ProcessInfo));<br />
InfoThread.Start();<br />
m_Running.WaitForExit();<br />
MessageBox.Show("Transfer Thread Done");<br />
}<br />
<br />
private void ProcessInfo()<br />
{<br />
MessageBox.Show(m_StdOut.Read().ToString());<br />
}<br />
The MessageBox in the ProcessInfo thread will not be displayed until the process is actually finished. If I don't try reading the stream in the ProcessInfo method then it'll display a textbox immediately. I've tried Read, ReadLine and ReadToEnd, but they all do the same thing. What I'm trying to do is grab the StandardOutput while it is being produced so that I can echo it to the user and they'd know whats going on.
Anybody got any ideas on this one?
|
|
|
|
|
You have to grab the stdout before you start the process. This is even in the docs. Since it's a reference, the reference will be non-null when the loader allocates resources for the new process.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
What exactly do you mean? I tried this:
<br />
ProcessStartInfo pInfo = new ProcessStartInfo(m_ProcessApp,m_ProcessArgs);<br />
pInfo.UseShellExecute = false;<br />
pInfo.RedirectStandardOutput = true;<br />
pInfo.RedirectStandardError = true;<br />
pInfo.CreateNoWindow = true;<br />
m_Running = new Process();<br />
m_Running.StartInfo = pInfo;<br />
m_StdOut = m_Running.StandardOutput;<br />
m_Running.Start();<br />
But I get an exception saying that StandardOutput has not been redirected. What docs are you looking at? The only ones that I've found only mention that you should read the StandardOutput before you wait for the process to finish because otherwise the pipe can fill up and hang both processes (the one you started and the parent). I haven't seen any suggesting that you should try and read it before starting the process!
|
|
|
|
|
The docs I'm talking about are the .NET Framework SDK docs, specifically for Process.StandardOutput ; however, when I looked here at my newest MSDN Library at home, you're right - you can't read it until after the call to Process.Start . The documentation I have at work is an older version - looks like it's time to update!
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Okay, thats what I was looking at too. Thanks for trying to help.
I've looked everywhere I can think of, but I can't find any examples of doing this. I'm wondering if it might be the case that the process that I'm running has to fill the pipe before anything can be read out of the StandardOutput? Maybe it's the case that my process just isn't writting enough for the pipe to be flushed into the StandardOutput stream? Therefore, I have to wait until the process is complete before anything gets written to the stream. The process that I'm running can take a while to run, but it doesn't write all that much to the console while it's running. Does anybody know if this is likely and if there is a way around it?
|
|
|
|