|
Thanks mate, that worked sweet
|
|
|
|
|
Concatenating strings like - especially potentially large strings - is a bad idea. It is an 2(O(n+m)) operation. Instead, use String.Concat and when you start getting a lot of text in there, you'll notice a substantial difference.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Just drop this on your form, somewhere visible, and use Console as normal.
#region License
#endregion
using System;
using System.IO;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
namespace Xacc.Controls
{
public class WinConsole : System.Windows.Forms.RichTextBox
{
class MessageWriter : TextWriter
{
public override System.Text.Encoding Encoding
{
get { return System.Text.Encoding.Default;}
}
public delegate void MessageWriterHandler(string text);
MessageWriterHandler handler;
public MessageWriter(MessageWriterHandler handler)
{
this.handler = handler;
}
public override void WriteLine(string format)
{
Write(format + NewLine);
}
public override void Write(string format)
{
if (handler != null)
handler(format);
}
}
private System.ComponentModel.Container components = null;
public WinConsole()
{
InitializeComponent();
SetStyle(ControlStyles.Selectable, false);
Console.SetOut( new MessageWriter(
new MessageWriter.MessageWriterHandler(Messg)));
}
Control GetFocus(Control p)
{
Control sender = null;
foreach (Control c in p.Controls)
{
if (c.Focused)
return c;
if (c.HasChildren)
{
sender = GetFocus(c);
if (sender != null)
{
return sender;
}
}
}
return null;
}
void Messg(string text)
{
Control sender = GetFocus(TopLevelControl);
Select();
AppendText(text);
SelectionStart = TextLength;
ScrollToCaret();
if (sender != null)
sender.Select();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if( components != null )
components.Dispose();
}
base.Dispose( disposing );
}
#region Component Designer generated code
private void InitializeComponent()
{
this.BackColor = System.Drawing.SystemColors.Info;
this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.Font = new System.Drawing.Font("Lucida Console", 9F,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.ReadOnly = true;
this.WordWrap = false;
}
#endregion
}
}
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
TextBox.AppendText ("string of data to add to window");
|
|
|
|
|
Hello,
I've for a couple of days been trying to figure out the best way to implement Save/Open dialogs that can show a preview and it turns out to be pretty much work!
Since this feature is present and fairly easy solutions exists outside of .NET, (using for example MFC), can I just create a C++ class for this and use it from my C# program?
If yes, how is this done?
Thanks for your help,
Bjorn
|
|
|
|
|
Create the functions in native win32 dll and then you can call them like the way you call other win32 in C#. Search DllImport in CP and in MSDN for the use of native methods in .NET
Mazy
No sig. available now.
|
|
|
|
|
I told you how before. What about that didn't make sense?
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
No sorry I didn't understand fully and didn't want to reply on that since it would be placed far down on the messageboard =)
(But I just figured out that's what the 'mail-me-when-replied' function is there for...)
What I'm wondering about is the many alternatives to making a control in C++, like COM, Win32 API, etc..
Which of these solutions is best/easiest/tractable?
The reason I dont fully understand is i'm not much into windows programming from before..
|
|
|
|
|
Doing this as a COM component will allow you to use COM interop in your application, which is pretty easy to do. But if you don't know much about Windows programming, COM is even more difficult to learn so I wouldn't recommend it. Besides, deploying the solution requires that not only do you copy the COM DLL to a target directory but that you also register it (both not hard, but it's still a two-step process).
If you just make use of the GetOpenFileName and GetSaveFileName functions, along with the OPENFILENAME struct and a Win32 dialog template resource (all of which you'd have to do for the COM component anyway), you can encapsulate this function just like the default Windows Forms components that you want to replace. As I said before, use a good decompiler to see how they do it. Most of the controls in Windows Forms are just wrappers for native functions and controls, after all. I would recommend this approach. To deploy, just copy the DLL into your application's installation directory or somewhere in the PATH environment variable (like the Windows or Windows\System32 directory). I would recommend the application installation directory with the rest of your managed application though, since it would keep your files together and wouldn't clutter the system with DLLs that other applications might not use.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
If i want to reproduce the functionality found in many microsoft apps, such as the windows on the bottom of vs7, that allow one splitter between two panels, to resize each panel as you move it left and right, how would i do that. I know that i can dock one, and fill the other, and have the splitter eat one of the panels area as you move the splitter, but what if you want both of the panels seperated by the splitter to resize so you dont crop any information?
Thanks,
Ryan
|
|
|
|
|
It's all about the order that the controls are added to your form. Add a Panel , dock it to the left (for example), then add a Splitter (default is to dock left), then add your final Panel with dock fill. In code, it would look like this:
this.Controls.AddRange(new Control[]
{
this.panel2,
this.splitter,
this.panel1
});
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I could be wrong Heath, that that order produces the exact effect the original poster is trying to avoid. Attaching the (Dock=Fill) panel last, places it on the top of the Z-order - and therefore, it ignores the boundary set by the splitter.
For me, to get both panels to completely show up - resized, the first attached panel must be (Dock=Fill), and then the splitter and second panel must be (Dock=Left).
The (Dock=Fill) panel is attached first, and then pushed over by the attached, higher Z-order (Dock=Left) splitter, which is then pushed over again by the finally attached higher z-order (Dock=Left) panel.
If attached to a simple Form, the first panel (Dock=Fill) then shows up on the right, the splitter to its left, and the final panel shows up along the left edge of the form.
Both panels are completely visible and completely resizable.
-Luther
|
|
|
|
|
Actually, panel1 in my snippet represents that far-left panel and panel2 the far-right. I numbered them accordingly to the original post's description, so what I typed and intended is exactly what you're saying now.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks for the post Luther, that worked great!
Ryan
|
|
|
|
|
Is there a .Net Class that I can use within my program to compare the contents of two files (streams?) and give me information about the differences in the files. Like Windiff.
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
For checking the equation you can use Object.Equal() method but for showing the difference I thing you have to look each byte of stream.
Mazy
No sig. available now.
|
|
|
|
|
There's no classes that do quite the job of WinDiff. It's a pretty complicated task actually. You can however get the
source for SDK tools, including WinDiff.[^]
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
I have a ListView control in which I'm loading a Progress bar as one of the sub items. Everything seems to be working except I'm having an issue when the column width is resized. Can anyone suggest the correct event to override to resize my ProgressBar when the Column width is changed ? Also is it possible to block the column width dragging ability in ListViews ?
|
|
|
|
|
You can block the resizing by overriding WndProc and handling the LVM_SETCOLUMNWIDTH message. If the Message.WParam cast to an int is the number of the column, don't pass the message on to base.WndProc . This should work. You should also be able to use this approach to get the new size of the control using some fancy state checking (allowing the column to be resized if desired) and setting the ProgressBar.Width property to the column width.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hello I am trying to get the value out of a cell in the current selected row in a datagrid in column 0.
Any ideas =)
|
|
|
|
|
datagridname[datagridname.CurrentCell.Rowindex,0]
Mazy
No sig. available now.
|
|
|
|
|
The ShowNewFolderButton property doesn't seem to do anything. The New Folder button is displayed no matter what.
Does anyone know why?
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
I googled it and it appears to be a Win2K bug
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
String comparison
Is there any way so that all the below conditions give me true results.
String val = “Hello”
Now comparing val it with the following code.
1 “Hello “ //Note white space at the end of Hello.
2 “ Hello” //Note white space at the beginning of Hello.
3 “Hello “ //Note two white spaces left at the end.
4 “ Hello “ //Note white space both at thebegining and end of Hello.
5 “hello” //Note the caps change.
6 “HEllo” //Note the caps change.
7 "HeLLo " //Note one white space at the beggin and two at the end and also with caps change.
|
|
|
|
|
if (StringOne.Trim().Lower() == StringTwo.Trim().Lower())
will sort all of these cases.
--Colin Mackay--
|
|
|
|