|
That would still require the Microsoft.VisualBasic.Compatibility assembly, since whatever Type g_pPropSet seems to be from there (since everything else is defined in the BCL assemblies). He doesn't want to reference that assembly, even though it really doesn't matter.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
how do we get our column width auto adjusted to fit the length of the column header text when it's displayed in dataGrid.
Thanks
|
|
|
|
|
There is no automatic adjustment for the DataGrid like there is for the ListView (not data-bindable). You must either guess at design-time, or when the DataGrid is loading, enumerate the DataGrid.TableStyles collection property, and enumerate each's GridColumnStyles collection property. Get the text and use Graphics.MeasureString using the Font property of the DataGrid . Set the current column's Width accordingly.
This only works when 1) you're using explicitly defined table and column styles before data is bound, or 2) after data is bound to the DataGrid .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi everyone.
I have an add-in that saves Outlook messages in a customer database.
I've created a toolbar button that's loaded in the Word E-mail toolbar and in the Outlook Standard toolbar. Everything works great in Outlook, but when I open up a new message (Word, that is) I can't get the information from the mail fields, for example "to" and "bcc".
This code gives me the message content:
Word.Document doc = ((Word.Application)myApp).ActiveWindow.Document;
System.Windows.Forms.MessageBox.Show(doc.Content.Text);
So I thought that
Outlook.MailItemClass mail = (Outlook.MailItemClass)doc.MailEnvelope.Item;
should give the mail information I'm looking for, but nope.
How do I find the mail information?
Cheers,
Sven
|
|
|
|
|
Hi,
can anyone help me converting vb.net code given below into c#. also, if i have .dll project, how do i convert the .dll executable at the same time.. i appreciate ur help. Thanks...
vb.net code
-------------
Private Function GetSingleProperty(ByRef sElementName As String) As String
Dim vValues As Object
vValues = g_pPropSet.GetProperty(sElementName)
If IsNothing(vValues) Then
GetSingleProperty = ""
ElseIf VarType(vValues(LBound(vValues))) <> VariantType.String Then
GetSingleProperty = ""
Else
GetSingleProperty = vValues(LBound(vValues))
End If
End Function
vijju
|
|
|
|
|
Why bother? Are you forgetting that all managed languages compile down to Intermediate Language? The source language doesn't matter; the associated compilers compiles that to IL and assemblies it in a module, which then gets embedded into an assembly along with embedded resources (if any). So why bother redoing it in C#? Just have your C# project reference the VB.NET assembly and viola'! The BCL (base class library) assemblies are written in C#, but you can use them in VB.NET, MC++, J#, and all the other languages, can't you?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Help! Help! Help!
I have a usercontrol that have a collection contain of a class(or struct). I want the collection be save autamatically with form's code.
my code:
public class Struct1<br />
{<br />
private int m_x ;<br />
public int x <br />
{<br />
get{return m_x;}<br />
set{m_x=value;}<br />
}<br />
private string m_y ;<br />
public string y <br />
{<br />
get{return m_y;}<br />
set{m_y=value;}<br />
}<br />
}<br />
private Struct1 m_struct ;<br />
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]<br />
<br />
public Struct1 STRUCT<br />
{<br />
get{return m_struct ;}<br />
set{m_struct=value;}<br />
}<br />
<br />
public class MyCoulumnClollectionClass : CollectionBase<br />
{<br />
<br />
public Struct1 this[ int index ] <br />
{<br />
get <br />
{<br />
return( (Struct1) List[index] );<br />
}<br />
set <br />
{<br />
List[index] = value;<br />
}<br />
}<br />
public int Add( Struct1 value ) <br />
{<br />
return( List.Add( value ) );<br />
}<br />
<br />
public int IndexOf( Struct1 value ) <br />
{<br />
return( List.IndexOf( value ) );<br />
}<br />
<br />
public void Insert( int index, Struct1 value ) <br />
{<br />
List.Insert( index, value );<br />
}<br />
<br />
public void Remove( Struct1 value ) <br />
{<br />
List.Remove( value );<br />
}<br />
<br />
public bool Contains( Struct1 value ) <br />
{<br />
return( List.Contains( value ) );<br />
}<br />
}
|
|
|
|
|
How many more times must I say, that if the DesignerSerializationVisibilityAttribute isn't giving you the effect you want, you will have to derive your own CodeDomSerializer and reference your implementation in the DesignerSerializerAttribute that would attribute your collection property? Those are your only two options, the the one option obviously doesn't work. Do the math.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi.
Thank you.
But i try to using CodeDomSerializer , but it is failed.
|
|
|
|
|
Then you're doing something wrong, because it works for many classes in the BCL as well as many other third-party controls I've used that must use a CodeDomSerializer . But since you didn't say why it failed (exceptions, problems, don't know what you're doing, whatever), I can't really help you.
Learn to be specific when asking for help, because saying things like "it failed" doesn't help at all.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I create a group of radio buttons so the user can select the database they want.
When the user clicks one of the buttons, the event issues a detatch and re-attach to the proper database.
The problem I am having is that during the form load I read the registry to find the current selection and then set the radio buttons showing which one has been checked by issuing a xyz.Checked = true;
This then forces a click event which causes the db to detach/reattach.
I only want the db to detach/reattach when the radio button is cliked by the user not during load.
I get the same stuff using the CheckedChanged event and setting a bool first time pass doesn't seem to do the trick either.
Thanks,
Craig
|
|
|
|
|
The obvious solution is to use a state variable. While loading, this variable could be unset. Once the form is done loading (say, in the OnLoad override in your Form ), set this variable. In your client event handler, determine if the variable is set. Only then do you execute your code.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have developed a Windows service application running on my machine. I was trying to implement a screen capture utility for it. I have a working (at least in clasic Windows form application) screen capture class.
But when I try to capture screen from my service it saves a file and the content is all black.
Did anyone try to capture screen from Windows service application and manage to get it work? Any ideas?
Thank you. Milos.
"some people never go crazy
oh how trully horrible life they've lived" -- Charles Bukowski
|
|
|
|
|
The service has to be enabled for interaction with the desktop. After you install the service using the ServiceProcessInstaller and ServiceInstaller , go to your services control panel, double-click on the service to show its properties, then click the security tab. Select "Allow service to interact with desktop". If you don't, the service does not get it's own window station and the screen would be black (frankly, I'm surprised it work at all, meaning you must have caught an exception somewhere and continued drawing a background or something).
You could also enable this during installation, but you'll have to do so manually. In your own Installer class, override OnCommitting and use the registry classes in the Microsoft.Win32 namespace to change the registry key accordingly (bitwise OR the Type key under the service key - using the service name, not the display name - with 256, IIRC).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I'm trying to use PropertyGrid to set the props of a remote object. At first it looked ok, but then I complicated it by adding plugins. So now I got the following class tree:
Node : MarshalByRef
Handler : Node
[plugin] : Handler
The plugin object is instansiated by sending the class name to the server, who looks it up in the assebly, creates it and returns it.
// client call
private void NewHandler(object sender, EventArgs e)
{
MenuItem mi = sender as MenuItem;
Handler node = server.CreateHandler(mi.Text);
handlersNode.Nodes.Add(new NodeFacet(node));
propertyGrid1.SelectedObject = node;
// node.NodeChanged += new NodeChange(NodeChanged);
}
// server side
public Handler CreateHandler(string type)
{
Handler node = this.CreateNode(type, handlerTypes) as Handler;
Handlers.Add(node);
return node;
}
In debugger I can see that the node is of the correct subclass, but on the client side I only get the properties from my Handler and Node class.
Any suggestion?
|
|
|
|
|
Hi gurus,
Where can I find a C# sample code that shows how to send a class with DirectPlay? I can send text but I need to send binary data.
best regards.
There is no spoon.
|
|
|
|
|
Have you looked in the DirectX SDK documentation for Managed Languages? All you need is either a NetworkPacket or a GCHandle (which you can create using any type). To use a NetworkPacket , all you have to do is pass a ValueType , which is any primative, enum, or struct (they all derive from ValueType ).
So, to use a NetworkPackget :
using (NetworkPacket pkt = new NetworkPacket())
{
pkt.Write(new Point(8, 8));
client.Send(pkt, 0, SendFlags.Guaranteed);
} If you're looking for a good resource on Managed DirectX, I highly recommend Managed DirectX 9 Kick Start: Graphics and Game Programming[^]. It's a good read and includes several chapters on DirectPlay. Honestly, though, it's not too tuff, especially after reading that book. It's certainly a lot easier than many .NET Remoting applications I've designed and help write!
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Ah ok...
We can't send a complete class, but we can send simply a structure derived from ValueType...
in a class that handle DirectPlay, is it necessary to use trnasactions with
[Transaction(TransactionOption.Required)] ?
Or the flag SendFlags.Guaranteed is enough?
NB: thanks for the link, but the MSDN is largely enough. I just messed up with the parameters... they need to be a structure, not a class :P
There is no spoon.
|
|
|
|
|
The TransactionAttribute is for service components (i.e., COM+ services), not DirectPlay (or any DirectX). They have nothing to do with each other. You can't just mix and match APIs.
If you want to send a class, use the Client.Send overload that requires a GCHandle , as I mentioned before. Most importantly, read the docs. I know the DirectX SDK documentation sucks (NDoc[^] is free and does a better job), but at least you can see what classes and members are available; that's all I did to answer your question (since I knew the basics already).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have created a structure with basic data (bool & int) and the structure is not sent. there is an exception that tells "An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll
Additional information: Object contains non-primitive or non-blittable data."
while the strcuture looks like this:
public struct TetrionParams
{
#region Fields
public bool DrawGrid;
public bool Draw3D;
public bool ShowGhostPolymino;
public bool ShowNextPolymino;
public int Width, Height;
#endregion
}
There is no spoon.
|
|
|
|
|
How are you calling Client.Send with this struct? More information is required to help you.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi Heath,
that's okay, I've found a sample in the tutorials of DirectX that shows how to send binary data.
the data need to be transfered byte by byte in the NetworkPacket. the Tut10_ThreadPool tutorial in the ThreadPool.SendData() method.
There is no spoon.
|
|
|
|
|
Hi ..
I'm writting a video player in C# using DirectShow ..
I would like to play Quicktime movies and VR too .. i found the Interop.QTActiveXPlugin.dll .. but i have not been able to play a single movie ..
I hope some one can help me get a Quicktime movie to play in C# without using an embeded HTML page containing a Quicktime <object> ..
Thanx ..
|
|
|
|
|
buffer_k.st wrote:
i found the Interop.QTActiveXPlugin.dll .. but i have not been able to play a single movie ..
For one, you must have QuickTime installed on your machine. An interop assembly is an RCW (Runtime Callable Wrapper) that exposes an existing COM server to .NET. The QuickTime ActiveX control is installed on Windows when you install QuickTime. Second, you can make your own. By saying you "found" the interop assembly - do you trust the source? All you have to do to make one is, in VS.NET, right-click on your project, select Add Reference, click on the COM tab, and find the QuickTime library. Double-click to add it. This create an interop assembly.
However, you must also create an ActiveX wrapper. Do this by right-clicking on your toolbox and selecting "Customize" (it's a little different for different versions of VS.NET, but common sense should tell you want to click). Find the ActiveX control for QuickTime and double-click to add it. When you drag this to your form or user control, both the ActiveX interop assembly and the interop assembly you created above (if you haven't yet) are created automatically for you. It's this ActiveX control (AxHost derivative) that you use to display videos.
You cannot use DirectShow to play newer (like, within the last few years) QT files because they do not use a compatible codec (on purpose), just as RealNetworks doesn't.
Finally, if you're having a problem, please be specific. Saying something like "but i have not been able to play a single movie .." doesn't help. Are you getting any exceptions? Do you just not know what to do?
The last question shouldn't be a problem, though. Follow the instructions above, or search for existing articles. It's really quite easy.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Ok to be more specific ..
Quicktime was already installed .. i found the quicktime COM "QTPlugin.ocx" wich contain Interop.QTPlugin.dll .. but i can't find the axInterop (ActiveX) dll file ..
I downloaded the Quicktime 6 SDK but it is for JAVA and C++ .. I've been searching all over to find the quicktime ActiveX .. but can't find it .. please help ..
|
|
|
|
|