|
A "compound file" is an ActiveX document that serializes separate objects and distinct instances. Word, Excel, and PowerPoint are good examples. Compound documents are hosted in an ActiveX container that - if written correct - can aggregate toolbars and menus from the ActiveX document.
Technically, a compound document doesn't have to expose the necessary OLE interfaces for this, though. It's really just a hierarchical collection of objects serialized to a developer-defined format; I just mentioned what I did above because most modern compound documents to expose such interfaces.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
There is no help for creating compound documents using the .NET Framework Class Library, or FCL (C# is just one language that uses the .NET FCL and compiled to Intermediate Language, or IL).
You would have to redeclare all the necessary interfaces (a few are already declared in the System.Runtime.InteropServices namespace, like UCOMIPersistFile ) and P/Invoke any functions you need.
I do have plans to start on such a project when time allows, but it could be a while. I've worked a lot with compound documents and thought it would be fun.
One thing to keep in mind: while the underlying file system in Windows "Longhorn" (T.B.R. 2006...hopefully) will accept any file, WinFS (a database layer on top of NTFS) will take over storing the various distinct properties exposed in Office compound documents and I would imagine that Microsoft would recommend that other compound document formats would do so as well so the documents could be easily searched. This would only apply to properties exposed from the compound document, however, through interfaces like IPropertySetStorage and IPropertyStorage .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
In MSDN if i search for any interface which are used to make a compound file in VC, it says "Import and use the methods found in Ole32.dll.". can u please tell me the procedure in details how can i import Ole32.dll.
if i use "DllImport" attribute then how can i define the attribues of "StgCreateDocfile" method which is used to create a compound files in VC.
because it takes four parameters. the last parameter is "IStorage** ppstgOpen"
which i donot know how to write in C#.
Thanks for your answer
|
|
|
|
|
Read Interoperating with Unmanaged Code[^], especially the topics dealing with P/Invoke and marshaling.
An IStorage** would be declared as ref IStorage . IStorage is an interface which is a reference type, which is basically a managed pointer. Using ref (or out ) is like a pointer to that reference type. You would have to declare a managed equivalent of IStorage however, since you can't simply include it from the C/C++ headers. There are articles about portions of what you want here on CodeProject, but if you read through those sections and have a good understanding of COM programming and marshaling data types (like an unmanaged long is actually an int , or System.Int32 , in .NET/C#).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi, there an interface "IPersistFile interface" in C#, What do you think can i use that interface to make a coumpound file. because i think i cannot write an interface that provides me the functionality of IStorage interface unless i completely understand the code in IStorage. is there any other way.
Thanks for your answer
|
|
|
|
|
Sorry, but you need to understand compound documents and the interfaces used to access and create them, like IStorage or IPersistStorage .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
A compound file is a file that contains multiple streams. There is no native support for them in the .NET BCL, but there are open source projects that implement this kind of functionality. Try this project on SourceForge[^] for an example.
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Interesting. I never tried searching for an existing project, but I wanted to do this myself anyway using most of the interfaces already present for the best interoperability with existing applications, namely current ActiveX document containers like Word and Excel.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I wanna know if a C# Application can add options to others apps, like MSN. I run a C# App and when i run MSN, appears a new option, for example.
Thanks.
|
|
|
|
|
Yes, if the other application exposes hooks to do so. You'll seen to see documentation for the other application though and I know nothing about MSN Messanger so I don't know if it does or not.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
MSN, for example, uses COM plugins. You could write a component in C# (gets compiled to IL in an assembly module) that exposes a COM-Callable Wrapper, or CCW. See Nick's article, Creating a CCW for COM-enabled, non-.NET Applications[^]. You register this appropriately, which is defined in the MSN Messenger SDK on the MSN Messenger web site (if you can find the SDK - they moved it some time back).
Since regasm.exe that ships with the .NET Framework SDK only registers the necessary keys and you need to register additional keys so that you can register as an MSN plugin, you'll need to read about the ComRegisterFunctionAttribute and ComUnregisterFunctionAttribute in the .NET Framework SDK.
For some applications, creating a CCW is the only way. You can also use P/Invoke to call native functions and pass them data. You could hook an application that exports the necessary hook functions as well.
There's lots of ways - provided that the application/library allows for it - and you can learn more by reading through the .NET Framework SDK, especially the section, Interoperating with Unmanaged Code[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am writing the chat program in LAN that is similar to the mIRC. When the user connect to server, it will activate the chat form that connected to server in port 9999, and when the user want to chat private, it will active the private chat form that connected to server in port 9998. In my program, I use the "privatechatform.ShowDialog()" to activate the private chat form, but it does not allow to chat in multi-users. but if I use the "privatechatform.Show()", my program is crashed. Please! Help me!!
|
|
|
|
|
What was the exception? What error happened? Where did it happen? What did the stack trace look like?
You need to provide more information if we are to help you. The most obvious thing is contention of resources. When you only have on chat session there is only one thing using one resource, when you have two or more chat windows open they are sharing the same resource.
When you use ShowDialog() dialog opens and as you see the application ignores the user in everything but the dialog. This is the correct behaviour. So, while this dialog is open other events are not firing. If you use Show() the application will continue to receive events. Perhaps some event in another part of the application is interfering with your dialog.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
I'm trying to put a picturebox on a form but I've already done showDialog on the form. I try to refresh the form but it doesn't do anything. The picturebox is already instantiated and I just want to a dd a picture to it at run time.
|
|
|
|
|
You didn't post any code or really explain exactly what the problem is, but this is how you would add a control at run-time:
PictureBox pb = new PictureBox();
pb.Image = Image.FromFile(fileName);
this.Controls.Add(pb);
If that doesn't solve your problem, you should post again, being more specific about what you need done and what you've got so far.
Charlie
if(!curlies){ return; }
|
|
|
|
|
Yeah your probably right. This time I'll give code. I'm just a beginner but I'm working on a poker game and have a picturBox on my table that displays the players cards face down. I want to redraw this picture to show one card then a card on top of that card like if a person was dealt one card then another. I've got the two bitmaps that I want to interchange but if I use showdialog I get a little flicker before the other bitmap comes up.I can't have the flicker cause it has to look like it just appeared onscreen and not redraw form1.
this is my player class and under that is my main method where I use AddCard
public class Player : Form1
{
PictureBox bust = new PictureBox();
PictureBox playerCard1 = new PictureBox();
PictureBox playerCard2 = new PictureBox();
PictureBox tableCards = new PictureBox();
PictureBox tableChip = new PictureBox();
TextBox playerMoney = new TextBox();
TextBox betAmount = new TextBox();
PictureBox button = new PictureBox();
public Player()
{
}
public Player(int cardLoc1, int cardLoc2, int cardSize1, int cardSize2, Form1 surface)
{
this.tableCards.Location = new System.Drawing.Point(cardLoc1, cardLoc2);
this.tableCards.Size = new System.Drawing.Size(cardSize1, cardSize2);
this.tableCards.BackColor = System.Drawing.Color.Black;
surface.Controls.Add(tableCards);
}
public void AddCard1(Form1 surface)
{
//surface.Controls.Add(tableCards);
this.tableCards.Image = Image.FromFile(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyPictures)+ @"\1card.bmp");
surface.Controls.Add(this.tableCards);
}
}
}
[STAThread]
static void Main()
{
Form1 Game = new Form1();
Form2 Begin = new Form2();
Form1 Game = new Form1();
if(Begin.ShowDialog() != DialogResult.Abort)
{
Player seat1 = new Player(656, 272, 27, 44,
624, 280, 28, 22,
616, 152, 80, 32,
616, 184, 40, 56,
656, 184, 40, 56,
616, 240, 80, 13,
624, 304, 40, 13,
576, 120, 33, 33,
Game);
Game.ShowDialog();
seat1.AddCard1(Game);
Game.ShowDialog();
}
}
I hope this isn't confusing. If anyone can help I would greatly apprecciate it.
|
|
|
|
|
Well, you instantiate six separate PictureBox controls in the Player class, but only one (tableCards) is ever actually added to the Controls collection of the form.
An instantiated control will exist in memory, but it will never show up on the surface of the form until it is added to the Controls collection.
Charlie
if(!curlies){ return; }
|
|
|
|
|
the picturebox tableCards is already added with a black box background. I just want it to add the image and show up on scrren. Is there any way to do this without using ShowDialog twice. It works if I do a showdialog, then add the image, then do a showdialog again, but the form flickers before it changes.
|
|
|
|
|
Why are you even calling ShowDialog anyway? If you actually read about it in the SDK documentation, you'd see that it's a synchronous call (i.e., the executing thread waits until the method returns) so you can't change anything about the form from your calling thread after calling ShowDialog , but you can before:
using (MyForm form = new MyForm())
{
form.tableCards.Image = someImage;
form.ShowDialog();
} This is enclosed in a using statement because also in the SDK documentation for ShowDialog is a remark that states that a modal dialog should be disposed when you're finished using it to free native, unmanaged resources. Using using makes sure that - even in the case when an exception is thrown - the form variable is disposed.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Is their any other way to get my form on the screen without using showdialog.
Also I think the dispose is what is giving me the flicker.
|
|
|
|
|
Yes, .Show() instead of ShowDialog(). But, your really shouldn't be calling this anyway. Your form should not have to show itself again and again every time you want to change the image. Also, your use of many different pictureboxes is probably what is giving you your flickering. If your pictureboxes are on top of each other, a repaint of the form will repaint each picturebox. Each box will repaint and invalidate an area of another picturebox, which will repaint and invalidate another area of another picturebox, which will repaint, ...
Like Heath told you before, and I'll say it again, your should be using only a single picturebox and painting all of your images into that one box yourself. That way you have MUCH greater control over what gets painted when and you will eliminate nearly all possible causes of flickering.
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I just tried your method in my Player class to show the new picture but it still flashes when the ShowDialog is called again. I'm thining I'm just picking a really bad way to do this.
|
|
|
|
|
the picturebox tableCards is already added with a black box background. I just want it to change the tablecard image and refresh the form to show the change. Is there any way to do this without using ShowDialog twice. It works if I do a showdialog, then add the image, then do a showdialog again, but the form flickers before it changes.
|
|
|
|
|
Heath already described a MUCH easier method of doing this than using many many pictureboxes. Part of the problem with using dynamically generated picture boxes is making sure they show up on the form in the correct order. If you have two pictures boxes, one at least partially on top of the other, you will have a difficult time making sure which one will actually display on top.
Painting the images onto ONE picturebox is MUCH easier and MUCH easier to control the order in which images are painted.
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
I am trying to write a custom user control which is a "On screen keyboard" used for touch screen monitor. So when user press a key on the "On screen keyboard", the program knows as if the key on the keyboard is pressed. What should I have in KeyPress event for each keyboard character? or there are some other ways to do it? Also, how to loop through all key chars on keyboard?
Thank!!!!
|
|
|
|
|