|
Thanks for the idea Darryl. I will try it out.
Thanks,
VPMahank
|
|
|
|
|
I tried your suggestion. The idea works!!!. But the painting is not done neatly. I mean I have a inherited panel and I did set the styles to enable doubleBuffering. But using those panels would not paint properly when using the spiltter( I inherited splitter control from label and set the styles for this too). Please let me know if I am missing anything.
Thanks,
VPMahank.
|
|
|
|
|
Are you resizing your panels as you move your splitter? I did not do it that way.
I would allow the user to move my splitter (panel) then when they release I then resize the other panels.
I'm not sure what you did with "I inherited splitter control from label...". I just dropped a panel on my form, made it very narrow (so it looks like a splitter) and allow the user to click on it and drag it to the desired location and release it. At that point, I just resize the panels affected by the new location of the splitter.
Darryl Borden
Principal IT Analyst
dborden@eprod.com
|
|
|
|
|
You havn't described "How it doesn't work". I has used it and everything is expected.
|
|
|
|
|
Ok what I was doing was a little different. I was resizing the panel each time the splitter is moved. So the two panels were resizing each time the MouseMove of the splitter is called. The problem with this the panel resizing is not done smoothly as required.
I tried making a few changes to the code now. Relocating the splitter location in mouse move and relocating and resizing the panels in the mouseup.
Here is what I did. Please let me know if I can improve this anymore and allow a cleaner dispaly.
public class NoDockSplitter : Label
{
public NoDockSplitter()
{
// set styles to prevent flickering
SetStyle(ControlStyles.DoubleBuffer, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyles();
}
protected void SetStyles()
{
this.BorderStyle = BorderStyle.None;
this.Text = "|";
this.TextAlign = ContentAlignment.MiddleCenter;
}
protected Control _leftSideControl;
protected Control _rightSideControl;
public Control LeftSideControl
{
get
{
return _leftSideControl;
}
set
{
_leftSideControl =value;
SetControlSize(_leftSideControl);
}
}
public Control RightSideControl
{
get
{
return _rightSideControl;
}
set
{
_rightSideControl =value;
SetControlSize( _rightSideControl);
}
}
protected bool _mouseDown = false;
protected bool _sizeSet = false;
protected int _leftSideControlWidth = 0;
protected int _rightSideControlWidth = 0;
protected int _rightSideControlXPos = 0;
protected int _splitterStartXPos = 0;
protected bool _widthSet = false;
protected int _diff = 0;
protected int _startXPos = 0;
protected void SetControlSize(Control c)
{
if(! _sizeSet )
{
this.Size = new Size( 4, c.Height);
_sizeSet = true;
}
}
protected override void OnMouseEnter(EventArgs e)
{
base.OnMouseEnter (e);
this.Cursor = Cursors.VSplit;
if( !_widthSet)
{
_leftSideControlWidth = _leftSideControl.Width;
_rightSideControlWidth = _rightSideControl.Width;
_rightSideControlXPos = _rightSideControl.Location.X;
_splitterStartXPos = this.Location.X;
_widthSet = true;
}
}
protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave (e);
this.Cursor = Cursors.Default;
}
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown (e);
_mouseDown = true;
_diff = 0;
_startXPos = e.X;
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove (e);
if( _mouseDown)
{
_diff = _startXPos - e.X;
this.Location = new Point(_splitterStartXPos - _diff, this.Location.Y);
this.Parent.Refresh();
}
}
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp (e);
if( _mouseDown)
{
_diff = _startXPos - e.X;
this.Location = new Point(_splitterStartXPos - _diff, this.Location.Y);
_leftSideControl.Width = _leftSideControlWidth - _diff;
_rightSideControl.Width = _rightSideControlWidth + _diff;
_rightSideControl.Location = new Point( _rightSideControlXPos - _diff, _rightSideControl.Location.Y);
this.Parent.Refresh();
}
_mouseDown = false;
}
}
|
|
|
|
|
My additional need was to have a splitter between controls that are not docked at all. So I need a control that behaves like a splitter but for undocked controls.
Thanks,
VPMahank
|
|
|
|
|
how can i scroll panels scroollbars automaticaly
|
|
|
|
|
panel M = new panel();
M.AutoScroll = true? perhaps?
|
|
|
|
|
No i mean,
I have a panel, at run time i add pictureBoxes when user clicked a button.
And i want to show last added picture at the end of panel as EnsureVisible Property of ListView.
|
|
|
|
|
Hi!
Is it possible to Embed and Run a VB6 Exe in .NET Windows Application
If Yes, then how to how to communicate with that Exe (set or get variables), call functions, etc.
If No, then please tell me any other way to communicate that exe
Actually I am trying to develop an application in .NET (C# Or VB .NET) and this application does not support controls used in VB6 Exe
The VB6 Exe connects to the database, How do i send the connection string to that exe from .NET application
Is there any way other than "CommandLine arguments"?
Thank you
Gulfraz Khan
|
|
|
|
|
There is no way to embed a VB6 app inside a .NET app and expect it to run. It must be a seperate file.
Communication is going to be a huge PITA. You cannot call its functions or anything else, unless the VB6 app exports them through COM. A normal VB6 app cannot do this unless it's written as an ActiveX server.
As for the controls that work in VB6 and won't work in C#, I doubt it. I haven't come acrossed a control that didn't work in the .NET world, but did in VB6. I have, however, come acrossed some badly written controls that I didn't even bother with in the conversion to .NET. I either got an updated control or just wrote an equivalent control myself and replaced it.
Your best solution is to scrap the VB6 app entirely and rewrite in C#. Why have 2 different runtimes loaded, VB6 Runtime and the .NET Framework, for your app to work?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello everybody.
I've just started with C# programming and I'm new here. I've only studied C# for half a term so you can say i can't so much about programming. I love to program, but anyway to my question.
I've just done a small game and I would like to have a highscore table that is saved everytime I close the game.
everyone here seems to be better than me so this is propably kind of easy for you guys ha?
Tutorials or just type the code here maybe?
any help is appreciated.
thank you.
Simon an amateur in c# programming.
|
|
|
|
|
All you have to do is write your data to a file on disk. You can do this easily using System.IO.File.
MSDN has 101 C# examples covering everything from UI development to dealing with files & folders on disk; these tutorials should help you get off to a good start. The tutorials are available here[^].
|
|
|
|
|
Thank you.
Simon an amateur in c# programming.
|
|
|
|
|
|
How to set string myString= javascript_string; where myString is a string created by c# and javascript_string is a string created with java script on the same form
|
|
|
|
|
You need to submit the JavaScript string so that the server (aka C#) has access to it in the post-back. Try adding a TextBox and setting it using JavaScript. Then, when you submit the form, you should get the new value.
Michael Flanakin
Web Log
|
|
|
|
|
Parsing a html document in C# using mshtml object works very slow.
Why is this happening ? Is it possible to avoid it ?
|
|
|
|
|
We haven't seen this. Have you run your code through a profiler? Perhaps there's something on your end causing the problem.
|
|
|
|
|
What do you mean by a profiler ?
I have made a test end code - a code that simply gets recursively all children of each node and that runs through each attribute of each node. Even very simple html pages run in 1-2 seconds. However the same pages, with the same algorithms, run instantly on VB6 or VC++ 6.
Can you provide me a simple C# project that does the same thing and runs instantly on html pages of medium complexity ?
|
|
|
|
|
Go download the ANTS profiler trial[^], run your project with it, and it'll tell you what's taking time.
My guess is one of 3 things; you're modifying the DOM document (which is not too fast), or there's a bug in the interop assembly (microsoft.mshtml.dll), or you're not caching your references to the DOM objects. Run a profiler and see what's taking up time.
|
|
|
|
|
1. The program doesn't modify the DOM for sure.
2. Probably there's a bug in the interop.
3. I am caching the reference to DOM objects (i.e. access the objects always through a local object).
I have made a simple COM in VB6 that takes as input a HTMLDocument object and runs the same algorithm as the one written in C#. If it's run by a VB6 program - it runs very fast.
If it's run by C# - then it runs slowly, similar to C# code. But ! if the VB6 com receives the URL of the page, loads it itself and then calls the function that parses it - then it works very fast again.
I think this is due to some kind of .NET object wrapper.
|
|
|
|
|
I have run the profiler. The biggest part of the time is spent on accessing/enumerating (with Foreach, or with IEnumerator) all children or all attributes of each node.
|
|
|
|
|
Try enumerating them with a regular for loop. Also, cache references to these if you're accessing them multiple times. You may also want to profile mshtml.dll when you run this to see if there's anything odd going on there.
|
|
|
|
|
I am sure that if there's something wrong, then it's wrong with the mshtml.dll . As I said before, if I run a VB6 COM that uses the HTMLDocument from C# (received as a parameter to its function) - then it runs slowly, but if the VB6 COM doesn't take the C# HTMLDocument (load the page itself) - then it runs fast.
How to run the profiler on mshtml.dll ?
As you said at the beginning - you didn't encounter such things as slow running. Have you made a similar module or code that parses a HTMLDocument object using mshtml ? If so - what VS.NET did you use , and on what windows ?
Thanks.
|
|
|
|