|
Hi,
There is a very usefull property called 'DesignMode'
It returns true if the control is loaded in design mode and false if the controls is
created at runtime.
Using this you can let the control change his behavior when being created in or out the IDE.
I have encoutered the same problem when using none default constructors for a control.
Hope that this will lead to a soulution for you
codito ergo sum
|
|
|
|
|
I have solution for VS'05!!!
Not the general remedium, but it works for me...
The myclass was a Component here,
it is enough, to be plain class for me... and it works that way
(what doesn't solve problem, if someone would need to have it as a Component )
|
|
|
|
|
Instead of re-inventing the wheel and roll my own class set, i thought i would ask if anyone at codeproject has created a basic set of win32 api classes that one can use in C# programs. I was only able to find bits and pieces on the internet.
|
|
|
|
|
www.pinvoke.net will shouw you how to call API functions you need. You're calling the Win32 API everytime you use C# tho, you realise that, right ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I use www.pinvoke.net often. It will just take some time cut-n-pasting all this stuff and organize it into a modular library. I think i will build a Win32 library as i go, adding functions as i use them, refactoring as needed. Reinventing the wheel is not all bad if it does not take too much time. Appreciate the help.
|
|
|
|
|
|
Hello there,
I'm developping a graphic interface for a sniffer library, and I'm actually stuck. When I want to start sniffing, I have to call that unmanaged function :
HANDLE PeekCreateCaptureContext(HANDLE, void*, int, int, void *)
When that function is successfully called, the library creates a thread listening for packets, and will call a user function each time a packet is captured. The second parameter (void*) of PeekCreateCaptureContext has to be a handler pointing to that function.
The user defined function signature must be (in a C version) :
int WINAPI on_capture( unsigned char *data, int len, int caplen, __int64 timestamp, int flags, int arg7 )
So I want to use PeekCreateCaptureContext in my C# code, but :
- How can I get my IntPtr custom function handle ?
- Is it possible to convert the unsigned char * (array of bytes, but unknown size) parameter to a managed type, because I won't be able to use the data in my external-threaded function if it's unsafe.
Thanks in advance for any idea or clue...
|
|
|
|
|
Oh my god, nobody knows ? That was an interestning project
I swear I'll post an article if I succeed !
|
|
|
|
|
I need help keeping track of the textbox cursor (in order to allow selection, and the entering of special chars).
any ideas?
|
|
|
|
|
You can use the TextBox.SelectionStart to get the caret position in your textbox (I think you mean caret by writing "cursor" ?). If you need to know when that position changes, I think handling the KeyDown and Mouse Down events should cover any caret move possibility.
|
|
|
|
|
Here goes my question. I would like to know how to select files from a window dialog, display the files selected in a grid.
From there have an option to either add more files (eg notepad.exe) so you can add or remove them.
From there when you are done selecting files Have another button that will compress all the files you selected and compress them using rar and the filename you designate.
Any ideas and help would be greatly appreciated.
Many thanks
-- modified at 16:51 Sunday 8th January, 2006
|
|
|
|
|
The first part is not very tricky - just use an OpenFileDialog to browse for the files. When OpenFileDialog.ShowDialog() returns DialogResult.OK , you can add the selected filename or filenames to your list (for example, an ArrayList ).
Creating a rar file from the files selected cannot be achieved with the base class library classes. I don't know a library that creates rar, but you should definitely have a look at SharpZipLib (google for it), it can create zip, bzip, gzip and some other formats.
Regards,
mav
|
|
|
|
|
I'm trying to add binary serialization to this set of classes.
Saving seems to work ok (file is created and seems tocontain the relevant data). However, Deserialize fails (even for an empty file) with:
Exception has been thrown by the target of an invocation.
InnerException: Object must implement IConvertible
I've implemented ISerializable myself on the DTreeNode class and on the DTReeRoot class (for the latter, it currently serializes nothing). DTreeNodeCollection uses default serialization.
relevant part of the call stack:
<small>System.Reflection.TargetInvocationException was unhandled<br />
Message="Exception has been thrown by the target of an invocation."<br />
Source="mscorlib"<br />
StackTrace:<br />
at System.RuntimeMethodHandle._SerializationInvoke(Object target, SignatureStruct& declaringTypeSig, SerializationInfo info, StreamingContext context)<br />
at System.RuntimeMethodHandle.SerializationInvoke(Object target, SignatureStruct declaringTypeSig, SerializationInfo info, StreamingContext context)<br />
at System.Reflection.RuntimeConstructorInfo.SerializationInvoke(Object target, SerializationInfo info, StreamingContext context)<br />
at System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context)<br />
at System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder holder)<br />
at System.Runtime.Serialization.ObjectManager.DoFixups()<br />
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)<br />
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)<br />
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)<br />
at XTree.Form1.openToolStripMenuItem_Click(Object sender, EventArgs e) in D:\Development\C#express\phlib\phtree\XTree\Form1.cs:line 187<br />
</small>
We say "get a life" to each other, disappointed or jokingly. What we forget, though, is that this is possibly the most destructive advice you can give to a geek.
boost your code || Fold With Us! || sighist
|
|
|
|
|
I have to design a library of classes. They are to inherit from a common base class. However I want to be able to call members of the class without making a distinction of which class it particularly is. I was thinking of an interface for the last point I mentioned.
Question : Would I'll be able to make my classes inherit this interface without directly inheriting the base class (i.e. the base class is inherited by interface)??
|
|
|
|
|
An interface is just a contract of members, that a class that inherits the interface has to implement. An interface can not inherit from a class.
What do you mean by calling a member without making a distinction of which class it is? You have to specify in what class a method is, or the compiler won't know where to look for it. What are you trying to do really?
---
b { font-weight: normal; }
|
|
|
|
|
XeoN-Kc wrote: They are to inherit from a common base class. However I want to be able to call members of the class without making a distinction of which class it particularly is.
Surely, this already does what you want?
Kevin
|
|
|
|
|
XeoN-Kc wrote: They are to inherit from a common base class. However I want to be able to call members of the class without making a distinction of which class it particularly is.
Well if you have a set of classes like this:
public class A
{
public virtual void SomeMethod()
{
Console.WriteLine("Method from A");
}
}
class B : A
{
public override void SomeMethod()
{
Console.WriteLine("Method from B");
}
}
class C : A
{
public override void SomeMethod()
{
Console.WriteLine("Method from C");
}
} Now, if run this little program:
static void Main()
{
A actuallyB = new B();
A actuallyC = new C();
A actiallyD = new D();
actuallyB.SomeMethod();
actuallyC.SomeMethod();
actuallyD.SomeMethod();
} Then the output is:
Method from B
Method from C You are referencing all as a reference of type A.
XeoN-Kc wrote: Would I'll be able to make my classes inherit this interface without directly inheriting the base class
If you are going to do it by interfaces then the base class no longer matters as you can reference it with the interface type instead. They can share the same base class, or have completely different base classes. Look at methods that implement the IDisposable interface. What do they have in common? Nothing, except for the IDisposable interface.
Does this help?
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
Hi, im new to C# and I've been reading books and what not. Well I started to build a simple app for my self and just created a form and some components. Well I compiled it and the exe came out to 183k but when I execute the app it grabs 13megs of ram. I think this kind of excecive. I'm using VS 2005, am I missing something here or this is normal? What happens when I start adding threads and so on?
|
|
|
|
|
fabriciom wrote: execute the app it grabs 13megs of ram.
Where did you see it? Task Manager? The most accurate way to see .NET memory usage is "Bytes in All Heaps" performance counter under the ".NET CLR Memory" performance object in Perfmon.
You might still see high values, but that's because of the .NET Garbage Collector. For performance reasons, the collector might not return all free memory back to the OS, unless it's absolutely necessary.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
how can i catch the "delete button" on key press event on DataGrid
i had catches all Keys pressed on Grid , but Only the Delete Button i Cant
Thanks.
Mohamad A. Flefel
C#.net Developer
|
|
|
|
|
Let me see If I'm getting this right. Is this the scenario You are facing:
1. The user selects the entire datagrid row by clicking on the gray field to the left on the datagrids row.
2. You want to do something else besides the automated action taking place upon delete-button pressed?
If this is right take a look at the datatable datarow delete event.
Hope this was helpfull
Cheers
Harry.
HarryS - Norway
Developer/Referee
|
|
|
|
|
the datatable datarow delete event doesnt work
i had catch the delete event and reject changes but it changes in the grid
and the row still deleted
Mohamad A. Flefel
C#.net Developer
|
|
|
|
|
the character of Delete kyepress is 127, like others keypressed wirte and for delete key
down below is table of ASCII Characters
http://web.cs.mun.ca/~michael/c/ascii-table.html
|
|
|
|
|
i had make a keypress event on the datagrid that display a message box that show the e.keychar
it show all the keys but not 'Tab' & 'Delete'
Mohamad A. Flefel
C#.net Developer
|
|
|
|
|
How can I create a screen saver using C#?
Arup
|
|
|
|