|
thank you for this advice..but this doesn't help because I move the panel by changing its location to achieve the slider effect...so DoubleBuffered doesn't help..(I also tried it already with no effect).
|
|
|
|
|
Have you tried handling the WM_PAINT event in the WndProc? If you try using the WndProc you will be able to choose when the control should paint and stop the event from raising when the control should not be painted.
Regards,
1tg46
Check out 3D Game Development with Dark Basic Professional [^]programming.
|
|
|
|
|
Hi, I don't know how it did not worked because I'm also a visual component developer and have developed custom panels also which you can move by mouse, expand and collapse vertically and horizontally (with or without animation) and everything works fine. Override WndProc event of your panel where you can find an example in MSDN library under WndProc. Handle the WM_PAINT event in a switch statement which is a value of 0x000F. To prevent repaint of your panel on every pixel move, checkout the location change and make it repaint itself forexample if the change is 2 or 3 pixels...
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
protected override void WndProc(ref Message m)
{
// Listen for operating system messages.
switch (m.Msg)
{
// The WM_PAINT message occurs when the application
// becomes the active application or becomes inactive.
case 0x000F: // WM_PAINT
// What you should check...
// if new location of your panel is NOT different enough
// to repaint:
// Msg.Result = IntPtr.Zero; // prevents the repaint of your panel
// else:
// do nothing
break;
}
base.WndProc(ref m);
}
But my first reply should have helped you, if this does not help either, send me your code. I can have a look at it and may see if you do something wrong by mistake.
|
|
|
|
|
Please clear the comments of WM_PAINT message decleration. I have forgotten to change them because I copied the code from MSDN Library example and modified explicitly. WM_PAINT occures nearly %90 of all times, "not only" when the application becomes active or inactive. Hope everything works fine.
|
|
|
|
|
Thank you for your help.....
it's better now...but with controls on it (like some standard buttons) when the panel grows (I mean when it sliders to the right) it still has some problems...
here is the code:
public partial class LeftSidedSliderPanel : Panel //, IMessageFilter
{
public static List<LeftSidedSliderPanel> allPanels = new List<LeftSidedSliderPanel>();
private int headerWidth = 30;
private bool animating = false;
private Timer slideEffectTimer;
public int HeaderWidth
{
get { return headerWidth; }
set { headerWidth = value; }
}
public LeftSidedSliderPanel()
{
InitializeComponent();
allPanels.Add(this);
this.Disposed += delegate { allPanels.Remove(this); };
this.DoubleBuffered = true;
// Application.AddMessageFilter(this);
}
public void Stop()
{
if (this.slideEffectTimer != null)
{
this.slideEffectTimer.Stop();
}
if (hoverTimer != null)
{
hoverTimer.Stop();
}
//preparing for more speed
for (int i = 0; i < this.Controls.Count; i++)
{
this.Controls[i].ResumeLayout();
}
animating = false;
}
private void StartSliding(int targetValue)
{
if (animating)
{
return;
}
this.animating = true;
this.SuspendLayout();
//preparing for more speed
for (int i = 0; i < this.Controls.Count; i++)
{
this.Controls[i].SuspendLayout();
}
this.slideEffectTimer = new Timer();
this.slideEffectTimer.Interval = 10;
int difference = 40;// 40;
if (this.Location.X > targetValue + difference) //get smaller
{
difference = 20;
}
int tempDifference = difference;
this.slideEffectTimer.Tick += delegate
{
if (difference <= 0)
{
difference = tempDifference;
}
if (this.Location.X > targetValue + difference) //get smaller
{
User32.MoveWindow(this.Handle, this.Location.X - difference, this.Location.Y, this.Width, this.Height, true);
difference++;
}
else
{
if (this.Location.X < targetValue - difference) //grow
{
User32.MoveWindow(this.Handle, this.Location.X + difference, this.Location.Y, this.Width, this.Height, true);
difference++; //--;
}
else // finnish effect
{
this.Location = new Point(targetValue, this.Location.Y);
this.Stop();
this.ResumeLayout();
this.Invalidate();
this.Refresh();
}
}
};
this.slideEffectTimer.Start();
}
public void Grow(bool withAnimation)
{
this.Stop();
for (int i = 0; i < allPanels.Count; i++)
{
if ((allPanels[i] != null) && (allPanels[i] != this))
{
allPanels[i].Stop();
allPanels[i].Collapse(false);
}
}
if (withAnimation)
{
this.StartSliding(0);
}
else
{
this.Location = new Point(0, this.Location.Y);
}
}
public void Collapse(bool withAnimation)
{
this.Stop();
if (withAnimation)
{
this.StartSliding(this.headerWidth - this.Width);
}
else
{
this.Location = new Point(this.headerWidth - this.Width, this.Location.Y);
}
}
protected override void OnMouseEnter(EventArgs e)
{
base.OnMouseEnter(e);
if (this.Location.X == 0)
{
this.Stop();
return;
}
this.Grow(true);
}
protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave(e);
if (animating)
{
return;
}
hoverTimer = new Timer();
hoverTimer.Interval = 1000;
hoverTimer.Tick += delegate { this.Collapse(true); hoverTimer.Stop(); };
hoverTimer.Start();
}
protected override void OnLayout(LayoutEventArgs levent)
{
base.OnLayout(levent);
if (!this.DesignMode)
{
this.Collapse(false);
}
}
protected override void OnPaint(PaintEventArgs e)
{
//base.OnPaint(e);
}
private Timer hoverTimer;
int painting = 0; //for animation
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")]
protected override void WndProc(ref Message m)
{
// Listen for operating system messages.
switch (m.Msg)
{
case 0x000F: // WM_PAINT
if (animating)
{
if (painting % 3 == 0)
{
m.Result = IntPtr.Zero;
}
painting++;
}
break;
}
base.WndProc(ref m);
}
}
|
|
|
|
|
I created service and client application. I had no problems with Server-activated Objects but in my case SAO is not what I need, becouse object must keep state for each client individually.
But when I use CAO I get error: object does not have constructor.
I tried to share only Interface betwean server and client and then full object definition, but I still get the same exception.
Piece of server code:
<br />
namespace ServerService<br />
{<br />
public partial class Service1 : ServiceBase<br />
{<br />
<br />
public Service1()<br />
{<br />
InitializeComponent();<br />
}<br />
<br />
protected override void OnStart(string[] args)<br />
{<br />
<br />
ChannelServices.RegisterChannel(new HttpChannel(9999));<br />
RemotingConfiguration.ApplicationName = "tester";<br />
RemotingConfiguration.RegisterActivatedServiceType(typeof(MyRemoteClass));<br />
<br />
}<br />
<br />
protected override void OnStop()<br />
{<br />
}<br />
}<br />
<br />
public class MyRemoteClass : MarshalByRefObject, MyInterface<br />
{<br />
public bool wywolany = false;<br />
<br />
public int FunctionOne(string str)<br />
{<br />
if (wywolany) return str.Length + 1;<br />
else<br />
{<br />
wywolany = true;<br />
return str.Length;<br />
}<br />
}<br />
}<br />
}<br />
Client code:
<br />
namespace Client<br />
{<br />
class Program<br />
{<br />
public static MyInterface m_RemoteObject = null;<br />
public static ObjectHandle oh = null;<br />
<br />
static void Main(string[] args)<br />
{<br />
object[] url = { new UrlAttribute("http://localhost:9999/tester") };<br />
<br />
<br />
try<br />
{<br />
<br />
m_RemoteObject = (MyInterface)Activator.CreateInstance(typeof(MyInterface), url, null);<br />
<br />
}<br />
catch(Exception e)<br />
{<br />
Console.WriteLine("Error konstruowania");<br />
Console.WriteLine(e.Message);<br />
Console.ReadLine();<br />
return;<br />
}<br />
<br />
if(m_RemoteObject==null)<br />
{<br />
Console.WriteLine("Error wykonania");<br />
}<br />
else{<br />
try<br />
{<br />
Console.WriteLine(m_RemoteObject.FunctionOne("Nish"));<br />
Console.WriteLine(m_RemoteObject.FunctionOne("Nish"));<br />
}<br />
catch<br />
{<br />
Console.WriteLine("Error");<br />
Console.ReadLine();<br />
return;<br />
}<br />
}<br />
Console.ReadLine();<br />
}<br />
}<br />
}<br />
I have read many tutorials about CAO but I still have problems with it...
Please help
source code of the project (if it's necessary) can be downloaded from http://www.mdz.jawnet.pl/CAO.zip
Secound question:
In one article there was a method to get CAO using singlecall SAO - singlecalll method return reference to the object we want to host - is it a good idea?
|
|
|
|
|
i load datatable into a grid, the grid is added, edited. Now i put into the grid a new row with the same key as another row. I have used Rowchanged and Columnchanged Events. But after it messaged the error as i gave, it message a error message from System.
I want to turn of it. How can i do that? Please help me!
superdragon
|
|
|
|
|
You could try adding an event handler for Application.ThreadException (could be wrong on event name). This would catch all events for the current thead that are not already handled and allow the program to continue as normally.
Regards,
1tg46
Check out 3D Game Development with Dark Basic Professional [^]programming.
|
|
|
|
|
Hi all ,
In my project i have to pass parameters to a fuctionthat is present in Delphi created dll.
I am able to invoke the functiion with no parameters.
I am getting the message that was placed in the function that was present in a delphi created Dll.
Please any one help me.
Thanking you all
Varma g
Varmag
|
|
|
|
|
I could not understand what your request was but if you can give your code and the format of the function which is embedded in a dll created with delphi, I can help you better. Otherwise I offer you to checkout Marshal class under System.Runtime.InteropServices. This class should help you well. Hope it helps.
|
|
|
|
|
I`ve made a program which is using DirectX9.0 classes DirectX.Audio.Video.Output, DirectX.DirectSound! Every time i start the program on the user machine i get the errors like (every time is a different error):
Process id=0x748 (1864), Thread id=0x231...
Proces id=0x118 (280), Thread id=...
I have checked for the dependencies in my solution, and the only files which have been found by VS are DirectX classes and dotNETFXRedist_x86_enu.msm which cannot be redistributet!
DirectX90c is working fine on the user machine, and all classes can be found in Assembly Cache ot he user machine!
How can i fix this error!? I used the error handling in the program which is generating the log file whenever the program brakes, but in this case the log file is missing, which makes me think that the program breaks on the ".NET framework" layer (if i could say like that), and it doesn`t start at all! Could be that some .NET file is missing on the user machine because of different .NET versions on the Developer and User machine?? Any idea please!
Thanks a lot!
|
|
|
|
|
You only show the part of the error message that tells in what process it occured. What is the error message?
---
b { font-weight: normal; }
|
|
|
|
|
Which version of .NET is installed on the user's machine and which version are you developing with/for?
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
I am using the .NET framework SDK 1.1! On the user machine was installed .NET framework Redistributable (dotnetfx.exe), downloaded from the microsoft.com download center! The error message is:
Header - Common Language Runtime Debugging Service
Application has generated an exception that could not be handled.
Proces id=.... i wrote this (every time different)
Click OK to terminate the application.
Click CANCEL to debug the application.
I had captured that form and here is a link to that file (error message that i`m keep getting):
http://img478.imageshack.us/img478/9673/dx9proba8ir.png
Thanx!
|
|
|
|
|
The message itself doesn't tell you much - just that an exception has been thrown very early into your program.
Since all the .NET redistributables are called dotnetfx.exe, you can't tell the version just from the filename.
Look at C:\Windows (or C:\WinNT) on the user's machine. You must have a subdirectory Microsoft.NET\Framework\v1.1.4322. If you do, then you can be pretty sure .NET 1.1 is installed.
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
I had a similar issue with different cultures and performance counters. Disable them if you are using them and see if thats the issue.
|
|
|
|
|
How can i prevent my form from freezing when doing a large fucntion.
For instance:
I read a 20,000 line file line by line.
after each line i do something with the data.
This could take a long time. So i would use a progress bar to show progress.
The progress bar starts but after a couple of seconds the progress bar does not move and the form freezes up until the process is finished.
How can i prevent this from happening.
Do i use another Thread?
|
|
|
|
|
Yes. Using another thread will fix the problem. In .Net 2.0 you can use the backgroundworker class, which seems to be an improvement over the Thread class.
|
|
|
|
|
If you use a worker thread, make sure you don't try to update your progress bar directly from that thread; invoke a delegate method for updating your progress bar instead.
--
I've killed again, haven't I?
|
|
|
|
|
However, if you are using .Net 2.0 the background worker class has a progress updated event handler in which you can update your progress bar.
|
|
|
|
|
I've run into this before. I ended up using creating a single delegate function called ThreadEvent which does everything and derived my own class called ThreadEventArgs from EventArgs to handle communicating what the thread is reporting.
Here's my delegate that handles whenever the thread sends any signal:
private void ThreadEventDelegate (object sender, ThreadEventArgs e)<br />
if (<control>.InvokeRequired)<br />
{<br />
this.BeginInvoke(new ThreadEvent (ThreadEventDelegate), new Object[] { sender, e });<br />
}<br />
else<br />
{<br />
<handle the event properly here><br />
}<br />
This is needed because the thread cannot change a control. What this does is it asks the control what unique thread number it is under. Whatever current thread is running is compared and if they are the same, then it doesn't need to invoke and it's safe to change the control. If they are different, the thread calls BeginInvoke to execute a new delegate asynchronously with the same data it was passed inside the thread it should have been.
|
|
|
|
|
I am currently using VS 2003 Professional and I am looking to see if anyone knows if MS added a RS232 Serial Comm class to VS2005?
|
|
|
|
|
|
Thanks. I will take a look.
|
|
|
|
|
Hi guys.I am actually working on a project which plot a graph and then show different values of graph in a datagrid.Can anybody help me with some hints how can I grab this points from graph and show them on datagrid?
Best regards.
|
|
|
|