|
Christian Graus wrote: I am certain that there have been times that I've disposed of the image and it's still held onto the file
Yup - I've seen this. It seems to depend (to a certain extent) on how the image was opened in the first place.
|
|
|
|
|
Pete O'Hanlon wrote: It seems to depend (to a certain extent) on how the image was opened in the first place.
That makes sense. Disposing the Bitmap to make it release the file only works if it's actually the Bitmap that is holding on to the file.
The Bitmap should always be disposed, of course, even if it's not to release the file.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Yeah "Deja View" I know I have seen this issue before but after spending many hours with Google etc. to no avail I resorted to asking for help. Many thanks Code Project. I try not to ask questions unless I have exhausted all alternatives. Thanks for your help I now have greater insight into the issue than my simple problem required.
|
|
|
|
|
electriac wrote: I know I have seen this issue before but after spending many hours with Google etc
That's the spirit. BTW - don't think that Deja View referred to your problem. It's part of my sig.
|
|
|
|
|
I did think it was a cute reference to my inability to find the previous post about picture boxes.
|
|
|
|
|
No - if you look at my profile history, you'll see this in all my posts. I've been using it for 3 years now.
|
|
|
|
|
Yeah be very careful with anything that wraps GDI functionality. Even innocent looking things like Matrix implement IDisposable.
Check, double-check, etc.
|
|
|
|
|
I have the following code
public Download(string URL1)
{
Url = URL1;
WebClient client = new WebClient();
string[] s;
s = Url.Split(new Char[] { '/' });
client.DownloadFile(Url,@s[1]);
}
where s = url split by \
example www.yoururl.com\file.ext
short of sounding dumb, but to I have to fully qualify the save path or does it not assume to throw it in the folder when the file is executed...
|
|
|
|
|
EliottA wrote: where s = url split by \
example www.yoururl.com\file.ext
Isn't that supposed to be the name of the local file?
Why would you use another URL there?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
i thought it was clint.downloadfile(outsideurl,localfilename)
i used s[1] to keep the same file name
|
|
|
|
|
Ack - My bad
I suppose it goes to the process' current working directory
(System.IO.Directory.GetCurrentDirectory()), which you could set
with System.IO.Directory.SetCurrentDirectory().
Have you tried building an absolute pathname from the filename?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Why try it when you can ask here instead ? :P
I would feel sure if no path is given, it will use the working directory.
Christian Graus
Driven to the arms of OSX by Vista.
"Iam doing the browsing center project in vb.net using c# coding" - this is why I don't answer questions much anymore. Oh, and Microsoft doesn't want me to.
|
|
|
|
|
got it to somewhat work
"{System.Net.WebException: An exception occurred during a WebClient request. ---> System.UnauthorizedAccessException: Access to the path..." is an error i get now.
code being used
public Download(string URL1)
{
Url = URL1;
WebClient client = new WebClient();
string[] s;
s = Url.Split(new Char[] { '/' });
string l;
l = @System.IO.Directory.GetCurrentDirectory();
l = l + s[1];
client.DownloadFile(Url,l);
}
i *had* to specify path, and also use http://
|
|
|
|
|
got it working, sorry about that
|
|
|
|
|
Hello,
How do I convert from points (font) to world coordinates?
When I create a font as such: var font = new Font(family, size, style, GraphicsUnit.World),
it seems like font.Size is exactly 3/4 of font.SizeInPoints. Is this a constant, or does it depend on something else?
I thought world coordinates were like pixels, but I haven't supplied any dpi information to the font constructor. Does it default to 96? 96/72 = 4/3, as would be the case if I wanted to convert points to pixels.
Please help! This is all very confusing. I need this to create a string shaped GraphicsPath, and then draw it onto a Graphics.
|
|
|
|
|
Hi,
I don't know and never had a need to know either. Are you aware of Graphics.MeasureString()?
it calculates the size a Graphics.DrawString() action would require.
|
|
|
|
|
I have not said anything about measuring strings.
|
|
|
|
|
Hello,
I have an application that reads XML files containing coordinates of text and graphics objects (lines, arrows, etc...). The coordinates are in units equal to (font height) / 8. In my override of Control.OnPaint(), I include a line like this to change the PageScale property of the Graphics object passed in to the function.
float font_height = Font.GetHeight(e.Graphics);
e.Graphics.PageScale = font_height / 8;
This works as expected in that Graphics.PageScale is set to approximately 2.8 and all of the calls to the drawing and text ends up at the coordinates read from the XML files multiplied by 2.8.
The problem is in my override of OnMouseMove. I need to change the color of these lines and text as the user passes the mouse over them. Since there is not a Graphics object passed into OnMouseMove I create one using Control.CreateGraphics(). The problem is that even though I change the PageScale property to the same value as in OnPaint, the drawing functions do not recognize the new scaling factor. In the debugger I can see that the value of PageScale has been successfully changed.
Has anyone run into this problem or am I doing something wrong?
Thanks.
|
|
|
|
|
CreateGraphics is probably fine to use in a mouse event, as you don't want what is drawn to persist, but I tend to stick to calling Invalidate() to force a paint event.
Christian Graus
Driven to the arms of OSX by Vista.
"Iam doing the browsing center project in vb.net using c# coding" - this is why I don't answer questions much anymore. Oh, and Microsoft doesn't want me to.
|
|
|
|
|
I've a third party DLL that exports this function:
typedef UCHAR (__cdecl *RESPONSE_FUNC)(UCHAR eventID);
__declspec(dllimport) void SetCallback(RESPONSE_FUNC pfResponse, UCHAR* responseBuffer);
I must allocate the buffer, call the SetCallback function, and read the modified data when the callback function is called.
I tried with this code:
static byte[] responseBuffer = new byte[10];
delegate bool RESPONSE_FUNC(byte eventID);
[DllImport("mydll.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern void ANT_SetCallback (RESPONSE_FUNC callback, byte[] responseBuffer);
public void test
{
ANT_SetCallback (EventCallback, responseBuffer);
}
static bool EventCallback(byte eventID)
{
return true;
}
When the dll doesn't try to modify the buffer then the Callback function is called without errors(the first event doesn't access the buffer).
But when the DLL tries to modify the data in the buffer, the program crashes with a 0xc0000409 exception.
I'm stuck on this, any suggestion ?
modified on Sunday, November 9, 2008 1:01 PM
|
|
|
|
|
This
typedef UCHAR (__cdecl *RESPONSE_FUNC)(UCHAR eventID);
should be
typedef UCHAR (<code>__stdcall</code> *RESPONSE_FUNC)(UCHAR eventID);
Also, make sure you pass a buffer large enough to accomodate whatever
writing the DLL is doing in it
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: This
typedef UCHAR (__cdecl *RESPONSE_FUNC)(UCHAR eventID);
should be
typedef UCHAR (__stdcall *RESPONSE_FUNC)(UCHAR eventID);
It's a third party library, I'm not able to change it
And yes, I'm sure the buffer is bigh enough... it should be 3 bytes, I'm passing 10
|
|
|
|
|
Paolo Vernazza wrote: I'm not able to change it
Oops, sorry.
On the C# side...
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate bool RESPONSE_FUNC(byte eventID);
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
hi evryone
how can i send text from my C# program to external program ?
i need to send text where the cursor is at this moment
than'k alot for any help
|
|
|
|