|
What is the C# equivalent of CMap?
I do not need super lookup speed but fast would be nice. A short example would be very cool, but a hint on what to look up would be perfectly cool.
Thanks
|
|
|
|
|
Try System.Collections.Hashtable
|
|
|
|
|
Dear gurus,
Does anyone know how to set column widths of DataGrid? I only see
dataGrid.ColumnHeadersVisible property.
Thanks in advance,
Khang Nguyen
|
|
|
|
|
Hi
You have to create a tablestyle. Lots of articles on this on the microsoft website.
Thanks
|
|
|
|
|
Thank you very much for the tip. Sorry, I don't know your name.
|
|
|
|
|
Does anyone know of any cases where the baseSerializationType argument to the DesignerSerializationAttribute constructor would be something other than CodeDomSerializer ? For instance anything other than the normal:
[DesignerSerializerAttribute(typeof(Design.ControlCodeDomSerializer), typeof(CodeDomSerializer))]
class Control {
...
Does the Visual Studio design framework allow for other types of serialization? Is that how resources are serialized into .resx files?
I'm curious and it's really just to help me better understand and utilize the designer capabilities of .NET (I'm dabbling on a managed DirectX engine which includes design-time support for 2D-GUI overlays).
Thanks for any info or references (I failed to find any in my searches .
|
|
|
|
|
|
Thanks for the tip. I was using ILDASM which was quite a bit slower than what I was able to do with Reflector. It was pretty easy to find the code in the VS assemblies that called the serializers. Turns out it only calls Serialize on objects of type CodeDomSerializer .
Now if only I can figure out what all of the serivces that DocumentDesigner creates do (the inheritance ones, InheritanceUI and IInheritanceService , have got me befuddled, an idea?).
|
|
|
|
|
Hello everyone.
I planned to migrate some C++ codes into C#. I know some basic syntax of c++, but recently i had huge problems on understanding it and how to convert it in c#?
All together 7 questions. I don't plan to pick up c++ at the moment! Hope you all don't mind helping me. Thanks.
1) Basically there will a header file called: haha.h
haha.h
=======
#ifdef HAHA_EXPORTS
#define HAHA __declspec(dllexport)
#else
#define HAHA __declspec(dllimport)
#endif
extern "C"
{
//some functions
// E.g.
extern HAHA int Unhook();
}
How do you convert such thing into c#? Any idea? Yeah i know that c# don't have header files.
2)
LRESULT CALLBACK MouseProc(int iCode, WPARAM wParam, LPARAM lParam)
{
//...
//...
return CallNextHookEx(hHook, iCode, wParam, lParam);
}
Basically in C#, how do we do callback like in c++? Delegates.. this is what i found from google. Any idea how to convert that callback functions in delegates?
I tried to seach CallNextHookEx(,,,) code in the C++ source code, can't find! There is no such function?
3) Hook and Unhook --> How do we hook and unhook in c#?
Just say, if i am using DirectInput, do i need to hook anymore or Directx can handle everything for me! If i use directx, do i need to store the keyboard or mouse into buffer or something!
4)
BOOL WINAPI DllMain(HINSTANCE hInst, DWORD dwReason, PVOID pvReserved)
{
if (dwReason == DLL_PROCESS_ATTACH)
hInstance = hInst;
return true;
}
Hmm.. is all these being done in c# automatically when i create a new project in vs.net?
5)
#define MAX_NUMBER 100
in C#, we replace const for #define? Can we use other better ways? I heard in C++, they had #define and const too!
6) int (*callback)(char*, char*) = NULL;
How to convert this in c#? I only manage to figure this out,
int (callback - not sure what to place here)(ref char, ref char) = null;
7) In C++, they had these few functions, not sure what is it in c#?
a. MapVirtualKey(key, 0)
b. KBDLLHOOKSTRUCT *keyinfo = (KBDLLHOOKSTRUCT *) lParam; // sounds related to keyboard
c. HC_ACTION
d. LLKHF_INJECTED
e. MSLLHOOKSTRUCT *mouseinfo = (MSLLHOOKSTRUCT *) lParam; // sounds related to mouse
Please help!
Thank you.
Regards,
Chua Wen Ching :p
|
|
|
|
|
Well, See if any of this helps.
1. It depends on what you mean by this question. Do you mean how do I write a function in C#, Or how do I export functions from C#? You can't export functions. You either set a reference to the dll from another .net project or you register it for COM interop and then you can get to it from any language that supports COM.
If you mean the function question then you just have one dec for it. No headers.
<br />
public int MyFunct()<br />
{<br />
return 1;<br />
}<br />
The whole function is declared and programed in one file.
2. Delegates are a little hard to get into in this thread. Many callbacks like you posted arn't needed anymore.
3. Don't know. I do know that direct x 9 has a .net wrapper around all the classes it has. Don't know how good it is as I have never used it.
4. Dll projects do all that for you. Exe projects still have a main function.
5. C# Eliminates #define. They decided it was not worth the headache it caused. Only have const now. The only thing #define is used for in C# is for true/false stuff. Like #define Debug. They you can use #if Debug etc.
6. I'm not sure. What is it used for? Most of the time you don't need anything like that. The framework will do everything for you. What are you trying to do?
7. I don't know what the direct equivalent is, but the framework is HUGE. There is a very very good chance that there is a class in there somewhere that does what you need it to if you can find it.
|
|
|
|
|
Hey Wen Ching,
Trying your luck here at CodeProject?
Nick Seng (the programmer formerly known as Notorious SMC)
God, I pity me! - Phoncible P. Bone
|
|
|
|
|
In the Visual Studio.NET, if I set the "Localizable" property of a Form
to true, then I can easily edit each localized Forms. Localizing button
texts, windows captions are easy, but what about strings?
I first tried to add string resources to the form's resx, such as
Form1.en.resx. It worked. However when any control of the form was
updated so the resx file was updated, the string resouce I added
was gone. It seems like VS.NET only allows entries added by itself.
I've searched the internet and found that I should add a new resx
file containing strings only. So I created StringResources.resx,
and StringResources.en.resx and it worked.
But the problem and question is, is this the most effective way?
If I have many forms in my application, should I keep each form's
string resources in a separate file like, Form1StringResources.resx,
Form2StringResources.resx and so on...? It surely looks very painful.
Or keep every form's strings in a single resx file? Then the resx file
gets very large, and strings for unused forms also be loaded at the
same time. Suppose I have 10000 entries in the StringResources.resx,
and current form only uses 100 of them and other 9900 entries are for
forms not used yet, but when I create a resource manager from that file, aren't the other 9900 entries loaded?
Do you have any suggestion? Please advise me.
|
|
|
|
|
Does anyone know how to indicate to the managed compiler that an included DLL should have copyLocal attribute set to false??? Currently I am executing this code:
parameters.ReferencedAssemblies.Add("system.dll");
parameters.ReferencedAssemblies.Add("system.data.dll");
parameters.ReferencedAssemblies.Add("system.xml.dll");
if (linkVersion2XM)
parameters.ReferencedAssemblies.Add
(@"D:\Apps\XM\XMDll.20\xm.dll");
else
parameters.ReferencedAssemblies.Add
(@"D:\Apps\XM\XMDll\xm.dll");
I want to be able to mark the xm.dll assembly as CopyLocal = false !! Is this just an additional part of the assembly string that I add, or is a parameter that I haven't discovered yet???
Any help would be appreciated. Thank you.
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
|
Okay, leppie, not so cryptic.
So are you saying that this can only be done in VS and is not an option exposed in the managed compiler?
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
|
Hi There !
I have downloaded the file printtemplates.exe from the VS.Net.
I want to use it, but would like to make some changes.
Does anyone knows how to get the source code ?
Is there another similar open source application ?
|
|
|
|
|
I have 2 sevices, they should be started at startup, but second must be started only after first one. For this reason I should use (I think) service depencies, but I cannot find how shoud I do it. Help me please.
|
|
|
|
|
In installer class:
[RunInstallerAttribute(true)]
public class ProjectInstaller: Installer
{
private ServiceInstaller serviceInstaller1;
private ServiceInstaller serviceInstaller2;
private ServiceProcessInstaller processInstaller;
public ProjectInstaller()
{
processInstaller = new ServiceProcessInstaller();
serviceInstaller1 = new ServiceInstaller();
serviceInstaller2 = new ServiceInstaller();
serviceInstaller1.ServiceName = NAME_OF_FIRST_SERVICE;
serviceInstaller2.ServiceName = NAME_OF_SECOND_SERVICE;
string[] a = { NAME_OF_FIRST_SERVICE};
serviceInstaller2.ServicesDependedOn = a;
...
}
|
|
|
|
|
Hi,
Does anyone know how to launch a script/exe on bulding a project within the IDE?
Thanks
Rich
|
|
|
|
|
You could write a macro that handles the build event. The macros in VS.NET are VB.NET so you have the full power of the .NET Framework to help build scripts for handling events in the IDE. Look up macros and the DTE object in the MSDN.
[Edit] Also, if you just want to call an exe or a batch file. Look at the properties of the Project. Right-Click on Project -> Properties -> Common Properties -> Build Events -> Edit these commandlines [/Edit]
Hope this helps,
Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
Thank for the reply. 'Build Events' is just what I am looking for, but it seems to be missing in the IDE - I am running Visual Studio 2002. Btw Can you save macros into A project.
Thanks Again
Richard
|
|
|
|
|
Yeah, sorry about that. The 'Build Events' must be part of VS.NET 2003. I just checked my copy of 2002 and they aren't there.
Anyway, you could still look into the macro stuff, but unfortunately I don't believe you can embed or save a macro inside of a particular project. From what I know and how I use them they are outside of projects as more utility type stuff. If anyone out there knows for sure, please tell me.
-Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
I'm trying to make a static ListView like this in VS.NET:
internal static System.Windows.Forms.ListView ListView1;
and changed all the "this.ListView1" into just "ListView1"
It compiles and runs fine, but every time i try to change something (like add a new button or change the property of the listview), VS.NET will remove the static keyword and replace "ListView1" with "this.ListView1" in InitializeComponent.
Is there a way around this apart from separating the listview code from initializecomponent as i may need to make changes to the listview directly at times.
|
|
|
|
|
As I see the Visual Studio recreates the code in the InitializeComponents Function every time it shows/changes the form. So I think you have to put it in a special function that you call in the Constructor after the InitializeComponents call.
I had to do this also, because i moved some eventhandler to another class and all changes in the InitializeComponents got lost when VisualStudio showed the Form the next Time an said it don't know the Class...
Also if you put a code line out with comments, VS.NET removes this line from the File...
Greets
Roland
|
|
|
|