|
You are trying to pass a pointer to a C# (i.e. managed) struct as an unmanaged reference, which will not work. You need to look at the marshalling options to see how the C code can access your C# objects. I have a suspicion that you cannot do it this way, but would need to convert your struct to some sort of basic array for the unmanaged (i.e. C) code to be able to access it.
txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Hi,
two parameters using pointers, that is two potential problems. Try to split the job in halves, if you own the native code, experiment with a single parameter first.
For the struct pointer, I would opt for ref myStruct .
For the array of pointers, if the managed side does not NEED to know it is an array, just make it an IntPtr ; if it must operate on array elements, the only easy way I know of is by:
- somehow knowing the element count (if need be, add another method to obtain it from the native world);
- then allocate the array on the managed side;
- then pass its pointer to the native world, which I prefer to handle with a GCHandle, GCHandleType.Pinned, AddrOfPinnedObject.
Conclusion: you may not even need unsafe code.
|
|
|
|
|
hi i hava a groubox contain 5 textbox control and i want to empty the all textbox i'm having hard time to solve pls any idea..
|
|
|
|
|
And what have you tried? It's not that difficult.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Try this
foreach (Control ctl in groupBox1.Controls)
{
TextBox txt = ctl as TextBox;
if (txt != null)
{
txt.Text = string.Empty;
}
}
Life's Like a mirror. Smile at it & it smiles back at you.- P Pilgrim
So Smile Please
|
|
|
|
|
|
|
Sam205 wrote: force the worker thread to wait while each event gets processed
what do you mean by "the worker thread"?
The main thread (a.k.a. GUI thread) is the one executing event handlers such as a Button_Click() method. When you want extra threads, you create them by instantiating Thread class, or by calling ThreadPool methods, or by instantiating BackgroundWorker class. All of them are supposed to:
1. not interfere with the main thread
2. not touch GUI Controls, as only the main thread should be allowed to touch them.
Getting another thread to access the Controls anyway requires a special technique as described here[^] . When Control.Invoke gets called, the caller effectively will be blocked until the GUI thread has executed the invoked method.
I hipe that is what you need.
|
|
|
|
|
|
Sam205 wrote: so they are processed sequentially
Is that not happening?
|
|
|
|
|
If the event handler is in another thread, then no, it doesn't.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Yes and no. Don't they all start out on the GUI thread and if he chooses he can spin off threads to do other stuff? But the messages all come into the pump in order and the events fire in order, yes?
I don't see how things would happen out of order unless he did something he didn't mean to do.
As with your other response; why spin off a thread if you don't want asynchronous processing?
At any rate, I don't understand the question.
|
|
|
|
|
You could suspend the thread at the beginning of the event handler, and continue the thread at the end of the handler. But if you do that, you've essentially eliminated the benefit of using multithreading.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
is it possible to use XML file as data source for Microsoft Reports Viewer? How?
|
|
|
|
|
Creating Data Sources for a Report[^]
"Default data processing extensions are available for SQL Server, Analysis Services, SQL Server Integration Services, Oracle, SAP NetWeaver® Business Intelligence, XML, ODBC, and OLE DB."
Seriously, learning to use a search engine will help you a great deal
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I want to know how can I associate a file extension with my application? and when it's associated in Windows how can I make the file with that clickable so when the user clicks it then my application receives it? do I have to pass as arguments?!
|
|
|
|
|
Are you in China? Is Google restricted for you?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
hahaha.. nice
i already did google but i can only fine associating file during deployment and what i want is to have it part of my application in the Options form?
|
|
|
|
|
|
Is there any way to create a folder like My Pictures and My Music and My Data Sources in My Documents, I mean to have that folder has a special icon not the normal yellow folder icon?
|
|
|
|
|
To create the directory, get the My Documents path using Environment.GetFolderPath then create the directory. Like this,
Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Test Directory"));
The appearance of the folder is determined by the desktop.ini[^] file.
Eslam Afifi
|
|
|
|
|
I have MDI application and many MDI children openned. If user changed data in textboxes in many MDI then how can I detect is_changed and how to save the data of every MDI children before closing the application?
|
|
|
|
|
Each child should understand and monitor what state it is in. If you handle the Closing event for each child window, then each can determine if the data should be saved before closing.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Your data model has to expose a property that is set to some value (using a Boolean) to indicate whether the data is "dirty" or not an needs to be saved. The MDI forms should have nothing to do with it at all. When a property in the data model is changed (you ARE using a seperate class to store your data, right?), the property code can just set the flag to "dirty".
|
|
|
|
|
Hi all,
I've used the default .NET serialization for a class with a System.Drawing.Color member. The code is now in use by people, and I need to add an extra member to the class, but still deserialize older versions.
It uses the SoapFormatter, so can't use the [OptionalField] attribute.
So I added ISerializable to the class, which instantly caused a much bigger problem: Structs (like System.Drawing.Color) suddenly can no longer be deserialized; I get the exception message, "Top Object cannot be instantiated for element 'foreColor'".
Does anyone know how I can get the SoapFormatter to read both old and new versions, and still handle structs?
Thanks!
Alan
|
|
|
|