|
You could try enabling double-buffering so that the image is drawn to a compatible off-screen bitmap and then swapped to the screen's device context. To do this, see the ControlStyles enumeration, specifically the DoubleBuffer member. Use Control.SetStyle in your contructor to enable the three necessary styles along with true as the second parameter. This should help.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hey All,
I am looking for some advice. I am pretty new to C# with a little experience making form based windows applications that are pretty quick and dirty just to get them done (such as my psudeo translator that allows me to replace characters in a resource file with Japanese characters to test localization of products.) However I am trying to do something new which is to create an application that has multiple forms, however I am not a big fan of having several different windows open on the screen free floating when they could be wrapped in a single window. I would like a cleaner solution than closing one window with form1 and opening a new window with form2 on it.
After looking at my options I came up with several ways of doing this:
1) Instead of creating several forms, just use several panels that hide the controls based on a view switch. This seems cumbersome to do with the form designer, but seems possible if I hand write everything. I think this would work the way I want it to. Also I am a little afraid that this might mean all the code is in the form1 class which would be hard to maintain.
2) Not sure if I could just create a custom control that mimics the functionality that I looking for and then hide and show these based on views. This would allow me to create different elements of each control and re-use some other external controls such as listviews for displaying drag and drop elements. Not sure what I just said or if I can accurately express what I was thinking.
3) Rewrite the MFC Formview architecture in C#. Sounds like a lot of work but it may be worth it in the long run. Then I can feel like I accomplished something. Just not sure that it would be any better than a simplier idea though....
Any advice from someone that knows a bit more... Am I missing something (other than my own sanity)?
Thanks,
Brian
If you start a fire for a man, he will be warm for a day. If you start that same man on fire, he will be warm for the rest of his life.
|
|
|
|
|
If you just don't want for your other forms to show in task bar, then set ShowInTaskbar property to false.
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
Thanks for the suggestion.
My biggest problem with multiple windows is the flow and controlling the user experience. I know that I often get frustrated with the amount of free floating windows in some applications and trying to get them positioned just right so I feel like I can use them. I don't mind dockable windows but only within the context of the view. I also don't really like a completely dialog based application with a stagnant main window. Sometimes I wish I was just plain satisfied but no I have to have this critical streak in me....
If I show and hide each window but it is not in the task bar then how do they get back to the correct window? I guess I could mimic switching by having the previous form size the next form to its own size, then tell the previous form to hide itself (both minimized and remove itself the taskbar). It seems lit a bit of a hack but I think it might work. Not sure what the performance would be like.. Is there a way of sharing menus and toolbars between forms?
Any other ideas or opinions?
Thanks,
Brian
If you start a fire for a man, he will be warm for a day. If you start that same man on fire, he will be warm for the rest of his life.
|
|
|
|
|
I've written an export type C# application which formats and saves an excel spreadsheet. I added a reference to excel using the .net ide and all seems to work fine on my pc. When I copy the exe (including Excel, VBIDE and Office dlls) to the target pc the application seems to run (and create the target file), but the file it creates contains about 10 characters, all of which are jibberish. The target PC contains the same version of excel as mine, does anyone knowwhat I need to do to make the app work? Do I need to register any of the dlls?
Thanks for any help
Jason
|
|
|
|
|
No, you do not need to register the DLLs (the only assemblies you would register are those that contain CCWs, or COM-Callable Wrappers - the interop assemblies you're using are RCW, or Runtime-Callable Wrappers, to COM servers already registered).
Instead of create the interop assemblies yourself, use the PIAs (Primary Interop Assemblies) from Microsoft - the official assemblies created by them. You can download them for Office XP (just search for Office PIAs on http://msdn.microsoft.com[^]) or install them with Office 2003 Professional as ".NET Framework Support" or something like that.
Make sure that these assemblies are either deployed to the same directory as the assemblies you've created (and pay attention to code access security policies if they're not running on the local machine), or install them into the GAC (Global Assembly Cache) using gacutil.exe, ngen.exe (also pre-JITs the IL), drag and drop them to %WINDIR%\assembly, or using an installer like Windows Installer (for which VS.NET has basic installer projects).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks for the advice, I just about managed to follow it all! (maybe one day i'll increase from newbie status!) The version of office I am using is 2000, so I can't go down the PIA route. I think i'll create an installer for the app as I don't have direct access to the machine, it's an end user performing the install.
|
|
|
|
|
ok i have 2 question how do i select a printer and second how to i print a .tiff file code somebody give me a code sample
thanks
chad
|
|
|
|
|
cmarmr wrote:
how do i select a printer
PrintDocument.PrinterSettings
cmarmr wrote:
how to i print a .tiff file code
See PrintDocument class in MSDN and there is an exmaple of printing there. In the PrintPage event use DrawImage instead of DrawString in that example.
Mazy
"I think that only daring speculation can lead us further and not accumulation of facts." - Albert Einstein
|
|
|
|
|
I was wondering what would be the best way to encrypt text data to a file. At the moment, I am basically serializing my class object that holds all the data, and storing the data via a BinaryFormatter (to a text file).
I was just wondering if there would be a better way to do this?
Here is my code:
Stream stream = File.Open( filePathString, FileMode.Create );
BinaryFormatter bformatter = new BinaryFormatter();
bformatter.Serialize(stream, Organizer.activeProfile); //activeProfile is my object
stream.Close();
Thanks in advance,
Jon
|
|
|
|
|
If you want to encrypt it, use the System.Security.Cryptography classes. You can chain whatever encryption method you want with the ToBase64Transform class to output base64-encoded data (most common) to a text file. Read the class documentation for various classes. There's a lot of example code.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am involved in the redesign of a large project which is expected to take approx 5 years to complete. I need to find out (if possible) where MS GUI designs are going, i.e. what Microsoft intend to do with their GUI's will they be sticking with Office 2003 theme?
Can someone guide me to a suitable URL where I can read up on where MS are going with their GUI designs.
|
|
|
|
|
The Office 2003 scheme? Every Office has introduced a new scheme which has pretty much set the standard for products until the next Office is released. With a release schedule 5 years away (at least), basing your product on Office is probably not a good idea. Just go with the typical flat style which is still the basic scheme of the newer variants.
Another option is to use a third-party library that keeps up-to-date with the Office scheme. Even before the new Office comes out, the company should update their UI and release new assemblies, which - if they are backward compatible - you could simply add a publisher policy to the GAC or using binding redirection in your app's .config file to use the new versions even without recompiling (if it's already deployed, for example, and isn't ready for a rebuild). That'd probably be your best option, unless you want to maintain your own UI toolkit in a similar fashion. Just make it as abstract as possible, perhaps even supporting whatever theme a user wants.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
5 years down the road we may very well be using Avalon instead of System.Windows.Forms. That would pretty much throw away all your UI work.
---------------------------
He who knows that enough is enough will always have enough.
-Lao Tsu
|
|
|
|
|
Longhorn and Avalon[^] is the way MS are going. However they still haven't released any information about the actual look and feel of the new presentation layer.
It might be worth looking into using something like MyXaml[^] as this will help keep your presentation layer seperate from the rest of your application logic. Allowing you to change the UI without having to recompile your application code.
Michael
But you know when the truth is told,
That you can get what you want or you can just get old,
Your're going to kick off before you even get halfway through.
When will you realise... Vienna waits for you? - "The Stranger," Billy Joel
|
|
|
|
|
If i have a xmldocument like this:
<?xml version="1.0" standalone="yes"?>
<sessions version="1.0">
<session name="Development">
<parameters>
<developmentsession>true</developmentsession>
<rootdirectory>n:\realsoftware</rootdirectory>
<debuglevel>1</debuglevel>
</parameters>
</session>
<session name="AppserverDevelopment">
<parameters>
<developmentsession>true</developmentsession>
<rootdirectory>f:\pro.net\realsoftware</rootdirectory>
<debuglevel>1</debuglevel>
</parameters>
</session>
</sessions>
And if i do this in the code section:
private void cboSessions_SelectedIndexChanged_1(object sender, System.EventArgs e)
{
ds.Clear();
string pad = "//session[@name='" + cboSessions.SelectedItem.ToString() + "']";
XmlDocument xml = new XmlDocument();
xml.Load(@"c:\kopie van sessions.conf.xml")
XmlNodeList contactNodes = xml.SelectNodes(pad);
string box = contactNodes.Item(0).OuterXml;
xml.LoadXml(box);
XmlTextWriter xmltw = new XmlTextWriter(@"c:\testnodes.xml",new UTF8Encoding(false));
xml.WriteTo(xmltw);
xmltw.Close();
ds.ReadXml(@"c:\testnodes.xml");
this.chkDevelopment.DataBindings.Add("Checked", ds.Tables["parameters"].DefaultView, "developmentsession");
}
Now i have a form with the combobox and the check and textboxes. If i do it with this code, he shows it correctly but when i click my combobox again he says there is a mistake:
An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll
Additional information: This would cause two bindings in the collection to bind to the same property.
What can i do about this? I want to be able to switch between the sessions and make changes to them.
thx in advance
|
|
|
|
|
Be sure to remove any existing binding on the Checked before adding a new one.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi C# gurus,
I have a casting problem in the following set of classes:
<br />
class Polymino<br />
{<br />
...<br />
}<br />
<br />
class Tetramino : Polymino<br />
{<br />
...<br />
}<br />
<br />
class ITetramino : Tetramino<br />
{<br />
...<br />
}<br />
<br />
class GameBoard<br />
{<br />
...<br />
private Polymino m_polymino;<br />
...<br />
<br />
public Polymino polymino<br />
{<br />
get { return m_polymino; }<br />
set { m_polymino=value; }<br />
}<br />
...<br />
}<br />
<br />
class Tetrion : UserControl<br />
{<br />
...<br />
private GameBoard m_gameBoard;<br />
...<br />
private Tetramino m_currentTetramino;<br />
...<br />
<br />
public void Start()<br />
{<br />
m_currentTetramino=GetRandomTetramino();<br />
m_gameBoard.polymino=m_currentTetramino;<br />
}<br />
...<br />
<br />
private Tetramino GetRandomTetramino() ...<br />
}<br />
Polymino is the base class of all.
In the Tetrion.Start method, when I call m_gameBoard.polymino=m_currentTetramino , I have an error in the m_gameBoard.polymino property call. I guess it's a casting problem. In C++ this kind of thinking is okay, but it seems that it does not work in C#, even if I do a cast like that: m_gameBoard.polymino=(Polymino) m_currentTetramino .
Can anybody help me and tell me why the debugger stops at this call?
Best regards.
Thanks.
There is no spoon.
|
|
|
|
|
What is the exact exception you are receiving, including the Type and message (if any)?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi Heath,
I have no exception... The call stack is full of "Tetour.exe!Tetour.GameBoard.set_polymino(Tetour.Polymino value = {Tetour.STetramino}) Line 49 + 0xa bytes"
STetramino is derived from Tetramino which is derived from Polymino. as STetramino is a specialized class based on Polymino class, the casting should work... like for C++...
There is no spoon.
|
|
|
|
|
Yes it should, just like the ArrayList which collects objects can take an instance of any class no matter far down the derivation tree it is.
Are these simple classes or controls (or possibly modify control properties directly)? If so, are you using multiple threads? Odd problems can occur when getting and most often setting properties on controls from another thread besides the main UI thread.
What causes the break into the debugger if you're not seeing an exception? Are you just stepping through lines or does it break while executing?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
it breaks while executing.
All the classes I show you are simple classes. the only classes derived from a UserControl are the Tetrion and TetraminoPreview classes.
The complete code of Tetrion.Start() method looks like this:
<br />
public void Start()<br />
{<br />
Debug.WriteLine("Tetrion.Start");<br />
m_gameStatus=GameStatus.gameStarted;<br />
m_gameBoard.Initialize();<br />
<br />
m_currentTetramino=GetRandomTetramino();<br />
m_gameBoard.polymino=m_currentTetramino;<br />
m_nextTetramino=GetRandomTetramino();<br />
<br />
if (m_tetraminoView != null)<br />
{<br />
m_tetraminoView.tetramino=m_nextTetramino;<br />
m_tetraminoView.Display=m_bShowNextTetramino;<br />
m_tetraminoView.Draw3D=m_gameBoard.Draw3D;<br />
m_tetraminoView.DrawGrid=m_gameBoard.DrawGrid;<br />
}<br />
<br />
Invalidate();<br />
}<br />
<br />
The code stops its execution at the call m_gameBoard.polymino=m_currentTetramino;
while there are no break points.
There is no spoon.
|
|
|
|
|
you were right. the exception is:
"An unhandled exception of type 'System.StackOverflowException' occurred in Tetour.exe"
There is no spoon.
|
|
|
|
|
I suspect the exception is actually being thrown because of GetRandomTetramino() . In some cases, the break appears on the next line after the offending line because the exact problem is not addressable. A StackOverflowException would most likely be one of those exception cases. What does the implementation for GetRandomTetramino() look like?
Microsoft MVP, Visual C#
My Articles
|
|
|
|