|
How do i get information about the Share folders in my computer
|
|
|
|
|
Does anyone know the correct way of marshalling inline multi-dimensional arrays?
I have the following structure that I want to reproduce in C#:
typedef struct tagMyStruct {
WORD Version;
char szName[3][256];
} MyStruct, *MyStruct;
Now if this was just an inline array:
typedef struct tagMyStruct {
WORD Version;
char szName[256];
} MyStruct, *MyStruct;
You do this:
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] public struct MyStruct {
public int Version;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=257)]
public string szName;
}
But it is not, so it is not that easy. I have tried, without success:
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] public struct MyStruct {
public int Version;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=257)]
public string name1;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=257)]
public string name2;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=257)]
public string name3;
}
Any ideas?
David M. Kean
My Blog: Managed from Down Under
|
|
|
|
|
How can I use a c# com object in c++? I've tried an example but everytime I call this" Edcont::Edcont_InterfacePtr p(__uuidof(Edcont::EdconClass)); " in the c++ .cpp file, the app just closes. Does anyone have another example that I can use? This is the place where got the example that I used
http://www.csharphelp.com/archives/archive281.html[^]
|
|
|
|
|
Create your C# component as a System.EnterpriseServices.ServicedComponent, register it with regsvcs, and call it as you would call any other COM component from C++.
Best Regards.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
|
Hi
Type of enum member is underlying type for the containing enum, then why casting is necessary on enum member?
DF
|
|
|
|
|
Diana Fernandez wrote:
Type of enum member is underlying type for the containing enum, then why casting is necessary on enum member?
Because it isn't the underlying type (even though the value might be physically stored as such), it is the type defined in your enum.
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
It so happens that I have a class named Poetic which is the rootelement. When SERIALIZED --using the XMLSerializer--the outcome should be:
<Poetic xmlns:xsi="http//www.w3.org/2001/XMLSchema-instance" xsi:noNameSpaceSchemaLocation="http://poetic.publisher.com/xmlcomm/poetic.xsd">
My Class declaration is:
[System.Xml.Serialization.XmlRootAttribute("Poetic")]
public class Poetic
{
// properties, methods and the like in here
}
When I serialize it comes out:
<Poetic xmlns:xsd="http://http://www.w3.org/2001/XMLSchema" xmlns:xsi="http//www.w3.org/2001/XMLSchema-instance">
So...
1. How do I get the xsi:noNamespaceSchemaLocation into the element using SERIALIZATION. I know the noName.. is part of the w3 spec.
2. How do I get rid of the xmlns:xsd="http://http://www.w3.org/2001/XMLSchema".
Thanks,
Guillermo Jimenez
|
|
|
|
|
Try the following:
[XmlRootAttribute("Poetic", Namespace="http://YourNameSpaceHere")]
class Poetic
{
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
Hi,
I need to display Dynamic Report.For Ex,
Report Fromat is
S.no No of % Due to
Test1 TEST2 TEST3 TEST4 Total
Section1 10 1 5 6
Section2 15 3 6 9
Section3 20 5 7 12
In 'x' table ,
Group Section is there.Ex Group Section1,Group Section2,Group Section3.User will select the Group Section.
Ex they selected Group Section1.
Under Group Section1,we need to display Sections.For ex Section1,Section2 and Section3.
Depending on Section1 need to display Columns Test1,test2,test3 like that.
Now there is no value test2 and test5.So no need to display.
Depending on user Selection,It will be different.Now it's displaying all.Can u help me to do.
radsgr
|
|
|
|
|
Hello,
I have a DateTimePicker control with check boxes on a form (well, several, but the behavior is the same for all.)
In design time, I set the Checked property to false. And they appear without the check.
When I run the app, the control is drawn checked, altough looking in the debugger, the Checked property is false. Once I start clicking on the checkbox, it checks and unchecks correctly.
So, we have it with Checked==false and check drawn. If I click on the checkbox, the check is cleared, Checked is still false, and I get no ValueChanged event. If I click again, everything works as expected (Checked set to true , and ValueChanged event).
Is it a bug? or am I missing something?
Thanks!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Hi all,
Is Window messaging by using the RegisterWindow MEssage API in C# a good way
to perform messaging between IPC ? How is it compared to IPC by MSMQ and .net remoting ? Is RegisteredWindow Message supported on Window 98 and Window ME also ?
Thanks
Patrick
|
|
|
|
|
pyhtang1 wrote:
Is RegisteredWindow Message supported on Window 98 and Window ME also ?
Check out the documentation for the function in the MSDN Library[^] for questions like these. In this case - if you understand what RegisterWindowMessage does - the answer should be obvious. You can't send unique messages without registering them.
What's best? Whatever is best for your situation. If you're communicating between two managed applications, I would not recommend Windows messaging. Use .NET Remoting with a TcpChannel . In .NET 2.0 they are also adding an IpcChannel which, IIRC, uses named pipes. Both are pretty fast, though there's a little extra overhead for using a TcpChannel . You could even create your own channel like the IpcChannel now - .NET Remoting is extensible enough.
If this was a named application, you could use Windows messaging, global memory, DDE, and anything else you can think of (you can use these in .NET, but often the overhead of P/Invoking what's required and marshaling isn't worth the trouble; .NET Remoting provides a rich RPC experience, too).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
|
How do I pass a form-controller instantiated in my form to a user-defined control?
|
|
|
|
|
What is a form controller? Maybe you should clarify your question a little bit.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Hi,
I would like to know in C# : how to detect that I have a break or connection with the network?
Best Regards
youssef
|
|
|
|
|
As we've discussed in this board before, you should P/Invoke any one of various native functions like InternetCheckConnection :
public bool Connected
{
get { return InternetCheckConnection("http://www.codeproject.com", 0, 0); }
}
[DllImport("wininet.dll", CharSet=CharSet.Auto, SetLastError=true)]
static extern bool InternetCheckConnection(string url, int flags, int reserved); You can also use this and similar functions defined in the WinInet library to force connections.
Look-up that function in the MSDN Library[^] and you'll find more options with other similar functions.
The pure .NET-way is just to request a network resource and handle SocketException or WebException (often times the SocketException is an inner-exception).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I would like to change the UK langage by FRENCH langage.
How can I do that ?
Best Regards
youssef
|
|
|
|
|
youssef wrote:
I would like to change the UK langage by FRENCH langage.
How can I do that ?
While there are articles here on Code Project, I would suggest you read Globalizing and Localizing Applications[^] within MSDN. This should get you started, if you have further questions, post again.
- Nick Parker My Blog | My Articles
|
|
|
|
|
I have an usercontrol with some controls and a hosting windows-form application which includes that usercontrol.
I know how to handle the events in the usercontrol from the hosting application. I want to know if there is any way to handle events in the hosting application from the usercontrol?
Please let me know
|
|
|
|
|
Not unless the parent container hosting your control forwards you the events. Your user control should not know anything about the container that holds it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
I am trying to write a user control and I need to capture the arrow keys. The form I am testing on does not have KeyPreview on, but when my control has focus and I press the arrow keys it changes focus to the appropriate control on the form.
How can I capture the arrow keys?
After further investigation, if I press the key twice the control "sees" the keyboard press ???!!!!???
Thanks,
Richard
|
|
|
|
|
OK, I have a control, Foo. This class has an object, FooOptions, as a property (named Options). On FooOptions there is a integer property, Number.
I want to make FooOptions editable from the designer, when a Foo control is planted on a form. In particular, I want to pop up a dialog box when the user double-clicks on Options. So I wrote a form, FooOptionsUIEditor, which holds a PropertyGrid (which gets an instance of FooOptions), and gets launched from FooOptionsEditor, which is derived from UITypeEditor. I set the Editor attribute on the Foo.Options property. I also wrote FooOptionsSerializer, which is devired from CodeDomSerializer, and used that for FooOptions's DesignerSerializer attribute. Finally, on Foo.Options, I set the DesignerSerializationVisibility attribute to Content.
What this should do, I expect, is give me a form when I double click on Options in the designer, where I can edit Number. When I close the dialog, it should mark the parent form (which holds an instance of Foo) as editted, and allow me to Save, which would trigger the serializer and place some code in the Windows Forms Designer generated code area on said parent form.
And in fact, everything works-- except that the parent form is not getting marked as editted. My Foo.ShouldSerializeOptions() method is getting called (a lot), and I'm returning true. If I change some other property, either on Foo or on the parent form containing Foo, then the parent form is marked as editted, and I can save, and my serializer works perfectly. My changes are lost if I just edit the FooOptions and close the form in the designer. However, if I edit the FooOptions twice from the designer, the first changes show up, so it's persisted in memory alright.
I thought that maybe there was some trouble with the fact that I was editting FooOptions in a modal form, so I rewrote it to edit with a drop-down. That didn't work. I tested a drop-down with a simple string property on Foo, and that worked. So then I tested a simple string property on Foo, editted with a form, and that worked to. I have to conclude that the fact that FooOptions is an object is causing some kind of trouble.
Incidently, on Foo, Options only has a getter, no setter. But if I add a setter, the behavior doesn't seem to change.
How do I get the parent form to be marked as editted?
This is the first time I've worked with designers and customizing designer behavior, so please, any tips are welcome, no matter how simple. I've been banging my head against the wall for 3 days now.
|
|
|
|
|
object88 wrote:
This is the first time I've worked with designers and customizing designer behavior, so please, any tips are welcome, no matter how simple.
You've obviously done your research.
While it may not make a difference, be sure that you're calling GetService on the IServiceProvider instance passed to your UITypeEditor.EditValue override, and get the IWindowsFormsEditorService in order to call ShowDialog to open your form. That ensures that your dialog is parented properly with the designer and may trigger the results you're looking for. I haven't spent a lot of time in this area of the component designer IL (which you can view with ildasm.exe straight from the SDK, or use a decompiler like .NET Reflector), so I'm not totally sure.
Typically when you want to edit "sub-options", one would either extend ExpandableObjectConverter or just derive from TypeConverter and implement the GetProperties and GetPropertiesSupported . In this case - if you're using a struct - you'll also want to implement CreateInstance and GetCreateInstanceSupported so that you're struct gets recreated the CodeDomSerializer picks up the change.
I'm guess that in your case, such a simple option editor isn't desireable. It would seem that the problem is that the serializer isn't signaling to the designer host (VS.NET) that the file has changed. You may want to query for the IComponentChangeService (as you should with the IWindowsFormsEditorService as I mentioned above) and call OnComponentChanged with the necessary parameters when you're finished. This will signal the designer host that your component has changed (or perhaps that a single property has changed, depending on how you call OnComponentChanged ) and it should then serialize your code correctly.
The specially named ShouldSerializerPropertyNames are really for when non-default values are assigned to a property. It really wasn't designed for changes in the component model like this.
HTH
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|