|
I have no idea if this would work, but possibly the Image abstract class has its default constructor as private and that is what you are calling, so it may require that you use one of its defined constructors, and I noticed the Bitmap class does not use a default contructor either. I think this would work... if it doesn't, then i have no idea.
notice this line:
public EnhancedImage(string imageFilename) : base( imageFileName )
<br />
using System;<br />
using System.Drawing;<br />
<br />
namespace WindowsApplication1<br />
{<br />
public class EnhancedImage : Image<br />
{<br />
public EnhancedImage(string imageFilename) : base( imageFileName )<br />
{<br />
FromFile(imageFilename);<br />
}<br />
}<br />
}<br />
|
|
|
|
|
I have an unusual situation, which I am unsure of how to tackle. I have an old c api that I need to access in a c#.net web application. My initial thoughts are to build a c dll with functions that I can call from c# using ATL or COM. But that is a big (and intimidating) leap on how to accomplish it. Does anyone have suggestions on a better architecture or how I can get there? Simple examples would be a big plus. Thanks.
Courtney
|
|
|
|
|
Its either what you suggested or build a wrapper around your C code using MC++. I dont think there are other options.
|
|
|
|
|
You have three choices from what I can tell:
1. Wrap it in com and do the calling from C#
2. Wrap it with Managed C++
3. Use DllImport to do it directly in C#
Choice #3 would be my first choice. Check out the System.Runtime.Interopservices namespaces. How complicated of a C api? Are you passing structs and unions and tons of pointers? Or just ints and doubles?
-Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
Option 3 sounds the simplest, I was unsure if that was possible.
My c api is not very complicated, just not very portable. The api relies on a properly setup application environment to function correctly. Mostly environment variables and an oracle client.
Here is a dll I created to perform a simple query. I can easily call this from another c/cpp console app and everything works fine. Jut not sure how to get it into a c#.net app.
Code Example:
#include <prointlnk.h>
#include <string.h>
#include <stdlib.h>
__declspec(dllexport) char* query(char*);
char* query(char* instring)
{
static char outstring[256];
char buff[20];
HPDMPDM pdm;
PTCERROR err = PDM_SUCCESS;
HPDMPI pi_handle = NULL_HPDMPI;
HPDMBRANCH branch_handle = NULL_HPDMBRANCH;
HPDMPIV piv_handle = NULL_HPDMPIV;
PTCSTRING piv_rev = NULL, part_name = NULL;
PTCINTEGER piv_ver = 0;
err = PDMConnectToPDM("username", "password", &pdm);
err = PDMPIGetByName( instring, &pi_handle );
if ( PDM_HANDLE_IS_NULL( pi_handle ))
{
strcpy( outstring, "Object Not Found" );
return outstring;
}
// Get the main branch handle.
err = PDMPIGetMainBranch( pi_handle, &branch_handle );
// Get the latest PIV handle.
err = PDMBranchGetLatestPIV( branch_handle, &piv_handle );
// Get the revision and version.
err = PDMPIVGetRevision( piv_handle, &piv_rev );
err = PDMPIVGetVersion( piv_handle, &piv_ver );
// Construct the output string. Longterm goal is XML string
strcpy( outstring, "name = '" );
strcat( outstring, instring );
strcat( outstring, "';" );
strcat( outstring, "rev = '" );
strcat( outstring, piv_rev );
strcat( outstring, "';" );
_itoa (piv_ver,buff,20);
strcat( outstring, "ver = '" );
strcat( outstring, buff );
strcat( outstring, "'" );
return outstring;
}
|
|
|
|
|
I believe you would just declare the function as:
[System.Runtime.Interopservices.DllImport("MyDll.dll")]<br />
private extern static string query(string instring);
That is a simple example. You might need to look at the strings a little bit more (ie use a StringBuilder or something instead). I am not a guru of interop. But this should get you started.
-Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
My company wants to extend the XML comments feature of C# with some extra tags.
I was wondering if anyone knows how to add extra tags to intellisense, so that they appear alongside the likes of , <example> etc.. within the comment are above a member / class.
Thanks in advance
Donald
|
|
|
|
|
Hi !
I have an owner draw panel in my forms application. It works well but it's not perfect with standard control (like labels, or checkbox) with transparency background activated. Transparency works fine but controls is a bit slower to be displayed. Is there a way to double bufferize controls drawing inside the panel ? (am i clear ? )
Anyone has any suggestion ?
Thanks for help.
--
F.Julian
|
|
|
|
|
Is there anyway to find out all the available drives to the PC on which a program is running? If so how?
|
|
|
|
|
System.IO.Directory.GetLogicalDrives
Rocky Moore <><
|
|
|
|
|
I have one crystal report, where I show all tables T fields. What I need is that those fields should look like a table with borders, like normal Excels table with black borders.
First problem is that, I need to move those fields together by hand (or does crystal rep. have features something like access has?)
And the biggest porblem that I do not know is: how to make fields with no data show? I made a single borders for all fields, but if the current field is empty, the crystal report suppreses it (no borders are shown)???
Does anyone knows how to make those borders be veasible all the time?
Thanx
|
|
|
|
|
Hi,
I'm trying to copy data from File to File,
and having some problem...
I've just created the two File, using:
File.create(file1);
File.create(file2);
and now trying to copy from one to another, using:
File.copy(file1, file2, true);
File.delete(file1);
I can compile it, but on ruuning time- it falls in the "copy" command, with the excaption the file2 is in use.
what should I do???
|
|
|
|
|
Make sure you close the files before attempting to copy.
Cheers,
Kannan
|
|
|
|
|
:-OThank you for your response, but...
I don't know any command in C#/File
(such as File.close)
that closes the file.
how do I do that???
Thanks again,
Iris
|
|
|
|
|
:-OThank you for your response, Kannan, BUT...
I'm not femiliar with any command to close the file, such as File.close...
Can you please let me know how to do that???
Thanks again,
Iris.
|
|
|
|
|
I'm sorry, I just assumed there would be a Close method you can call.
Seems like Close method is present only for stream derived classes.
Do you write to the file using the Stream class, if so try to close them before you copy.
Also try using FileInfo's CopyTo method (I doubt it would help, but just give it a try).
Kannan
|
|
|
|
|
Hi,I'm trying to rename a lot of files,how to implement this function.
|
|
|
|
|
I think you might be looking for System.IO.File.Move() or System.IO.FileInfo.MoveTo(). That moves the file which is the same as renaming. You move it to the same directory but under a different name.
Rocky Moore <><
|
|
|
|
|
|
Hi Friends!! If I draw a black color vector Graphic in a white DC, how can I know any pixel in DC is black or white ? thx !
|
|
|
|
|
Image.GetPixel
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Dear !
I know you are the best programmer and very famous on Codeproject website. I read your profiles and I was proud of you. I think you are so good. In the past time, I though that I would depend on your help. But I don't know whether you have free time or not and whether you are ready to help me ... so I didn't do ... Now , the time is not enough. There is only about 6 days to me complete my project but there are some problems that I can not do because I know my knowledge is so bad. This is attachment for my project, that is a C# Project and compressed into zip fie. It only compiles and run it ...
There are some problems :
- I can't use V-H scrollbar ...
- I can't use Serializable to save and load binary file.
- I can't perfom cut/copy/paste object.
Here link Download here or Download here[^]
Best regards !
|
|
|
|
|
Hi there for my learning purposes I created a .exe from Visual.net . I gave that program to my friend to use it but it said that certain dlls were missing. IS there a way after creating the exe on my machine it will work on his machine if he donesnt have the .NET frame work ?
wud appreicate ur help
|
|
|
|
|
Afraid not. Your friend will have to DL the .NET framework for it to work.
There are only 10 types of people in this world....those that understand binary, and those that do not.
|
|
|
|
|
Absolutely correct but you should remember that it DOESN'T mean your user has to have Visual Studio .net or the .NET Framework SDK installed. All they need is the .NET Framework Redistributable which should be on your VS.NET installation.
I have seen this misconception surface quite a bit!!!
If you are deploying your code on CD you can include it on there... otherwise as has been said they will have to download it...
|
|
|
|