|
I have a WinForms application that moves a group of points around with the mouse. The code has worked fine on Win 98, XP and Vista. It was slow under Win7, until I disabled the Aero stuff and then it was fine there, too. Now under Win8 it's acting just like on Win7 with Aero activated.
I've checked to make sure the graphics drivers are updated, and even gone to Control Panel and set things for Optimum Performance rather that Optimum Appearance. No difference at all.
Does anyone know what might be done? This is a show stopper! The program uses plain GDI and is in C#.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Disable Aero for Win8
modified 19-Apr-13 15:36pm.
|
|
|
|
|
If you figured out how to disable Aero in Win 8, I'd love to hear about it. I thought about that first.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Joke is joke, but come back to reality...
The transparent borders/glass effect as Aero themes are gone in Windows 8. Many useful information you'll find here: http://superuser.com/questions/445971/disable-aero-on-windows-8[^]
Although, above information isn't friendly much, there is a possibility to disable some visual options, which can help to improve performance:
1) Go to Control Panel-> (in Icon View) click Easy Of Access Center
2) Find Explore All Setting section
3) Go to Make things on the screen easier to see section and find Turn off all unnecessary animation (when it possible) and Remove background images (when available)
4) Check both options
That's all. I hope it helps.
|
|
|
|
|
I tried all of that months ago before posting the message, even talked to Microsoft. I also investigated graphics card issues - no change.
It appears they have changed something inside the Win8 graphics kernel so that part of Aero is built-in and cannot be disabled conventionally.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
below is my routine which works fine but the routine is not generating the image of sdi form with proper height & width. here is my routine and i think there is flaw but i am not being able to capture & fix the flaw. so here is my code. please have a look and guide me what i need to change in this code to fix this flaw.
protected virtual void OnMinimize(EventArgs e)
{
Rectangle r = this.RectangleToScreen(this.ClientRectangle);
int titleHeight = r.Top - this.Top;
_lastSnapshot = new Bitmap(r.Width, r.Height);
using (Image windowImage = new Bitmap(r.Width, r.Height + titleHeight))
using (Graphics windowGraphics = Graphics.FromImage(windowImage))
using (Graphics tipGraphics = Graphics.FromImage(_lastSnapshot))
{
windowGraphics.CopyFromScreen(new Point(r.Left, r.Top - titleHeight),
new Point(0, 0), new Size(r.Width, r.Height + titleHeight));
windowGraphics.Flush();
tipGraphics.DrawImage(windowImage, 0, 0, r.Width, r.Height + titleHeight);
_lastSnapshot.Save(@".\tmp.bmp", ImageFormat.Bmp);
}
}
with the help of above routine i could generate form image and just click on the link to check.
http://i.stack.imgur.com/wCvUl.png[^]
tbhattacharjee
|
|
|
|
|
Unfortunately the ClientRectangle does not include the form borders so that is not useful for capturing the complete window. However the actual location and size is kept in the form's properties and can be used to capture the window as below. And in this case, the title bar size is not needed.
Rectangle r = new Rectangle(this.Left, this.Top, this.Width, this.Height);
Bitmap _lastSnapshot = new Bitmap(r.Width, r.Height);
using (Image windowImage = new Bitmap(r.Width, r.Height))
using (Graphics windowGraphics = Graphics.FromImage(windowImage))
using (Graphics tipGraphics = Graphics.FromImage(_lastSnapshot))
{
windowGraphics.CopyFromScreen(new Point(r.Left, r.Top), new Point(0, 0), new Size(r.Width, r.Height));
windowGraphics.Flush();
tipGraphics.DrawImage(windowImage, 0, 0, r.Width, r.Height);
_lastSnapshot.Save(@".\tmp.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
}
Use the best guess
|
|
|
|
|
thanks for your answer. i got another trick that is bit small and works well
Bitmap bmp = new Bitmap(this.Width, this.Height);
this.DrawToBitmap(bmp, new Rectangle(Point.Empty, bmp.Size));
bmp.Save(@"d:\Zapps.bmp", ImageFormat.Bmp);
tbhattacharjee
|
|
|
|
|
Good catch.
Use the best guess
|
|
|
|
|
i want to detect mouse over on title bar or mouse out from title bar in my c# winform apps. i got a code sample which works but the problem is when i place the mouse on any area of win form then mouse leave occur and when i put mouse on title bar then right event call. actually i want that if i place my mouse on any area of form except title bar then nothing should happen.only when i will place mouse on title bar then a notification should come to me and when i will remove mouse from title to out of my form then label should display mouse out message but if remove mouse from title bar to form body then label should be blank.
here is code. just run this code and tell me what modification i should do to get my expected result. thanks
using System.Runtime.InteropServices;
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
protected override void WndProc(ref Message m)
{
if (m.Msg == 0xA0) // WM_NCMOUSEMOVE
{
TrackNcMouseLeave(this);
//ShowClientArea();
label1.Text = "mouse move on title bar";
}
else if (m.Msg == 0x2A2) // WM_NCMOUSELEAVE
{
//HideClientAreaIfPointerIsOut();
label1.Text = "mouse leave from title bar";
}
base.WndProc(ref m);
}
protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave(e);
//HideClientAreaIfPointerIsOut();
}
private int previouseHeight;
private void ShowClientArea()
{
if (this.ClientSize.Height == 0)
this.ClientSize = new Size(this.ClientSize.Width, previouseHeight);
}
private void HideClientAreaIfPointerIsOut()
{
if (this.Bounds.Contains(Cursor.Position))
return;
previouseHeight = this.ClientSize.Height;
this.ClientSize = new Size(this.ClientSize.Width, 0);
}
public static void TrackNcMouseLeave(Control control)
{
TRACKMOUSEEVENT tme = new TRACKMOUSEEVENT();
tme.cbSize = (uint)Marshal.SizeOf(tme);
tme.dwFlags = 2 | 0x10; // TME_LEAVE | TME_NONCLIENT
tme.hwndTrack = control.Handle;
TrackMouseEvent(tme);
}
[DllImport("user32")]
public static extern bool TrackMouseEvent([In, Out] TRACKMOUSEEVENT lpEventTrack);
[StructLayout(LayoutKind.Sequential)]
public class TRACKMOUSEEVENT
{
public uint cbSize;
public uint dwFlags;
public IntPtr hwndTrack;
public uint dwHoverTime;
}
}
tbhattacharjee
|
|
|
|
|
HI,
I Have Created a Desktop Winforms Application On The Basis of Wix.com Means a user can create Html templates in the Application and then Publish Them.now when a user Clicks on the Menu On Right side( Which Contains Menu For Adding Buttons and Other General Controls),The Control is Drawn on The Webbrowser control ( Setting its Editmode true).
But Whenever we add a Control is Alighned to left By Default and There is No Mean To Reorder them .
Can we implement a Functionality Which Lets Users Place Controls on Document where ever they want instead of Having Each control Autoalighned to Left.
Thanx
Tarjeet
Tarjeet
|
|
|
|
|
First, get your finger off the Shift key. You're not using correctly and it makes your post a little difficult to read.
Second, what controls are you talking about?? HTML controls?? Like INPUT tags? If so, you've got a lot to learn about writing HTML and why everything is "left aligned" by default.
|
|
|
|
|
ok but can i break this behaviour of html ??
|
|
|
|
|
You have two choices if you want to continue to use HTML.
1) Use the nightmare that is CSS positioning.
2) Rewrite the HTML spec yourself and write a parsing and rendering engine to use your new spec.
Other than that, we have no idea what you're using HTML for and what your app does, so it's pretty much impossible to suggest any other methods.
|
|
|
|
|
I am finding a new kind of memory link. Maybe not new but new to me. I have an application that generates 50 to 70 threads. I am using a vision library by a third part which generates many of them. My program is a C#/WPF. I think the library was done in C++.
I capture and analyze an image every 60 msec. After 3 to 4 hours I see the thread count for the application rise. This is well over 100,000 images. Every image creates a few threads and then closes them when finished. This spreads the load out over several core. I am watching it in Resource Monitor. Of course as thread count raises so does memory.
Has anyone seen a similar leak?
So many years of programming I have forgotten more languages than I know.
|
|
|
|
|
Do not know for sure. But you could try to call Garbage Collection manually after processing an image. Use GC.WaitForPendingFinalizers() and GC.Collect() . Maybe that helps.
|
|
|
|
|
Even if the system is not used for 5 minutes the extra threads still persists. That should be plenty of time for automatic garbage collection to get rid of old threads.
So many years of programming I have forgotten more languages than I know.
|
|
|
|
|
It's hard to say. The issue could be inside this external library, or it could be in your code. What I would do is, rather than trying to manage the threading by yourself, make use of the Task Parallel Library (TPL). This is a great way to have your code do threading without burdening you with thread lifetime issues. It's incredibly simple to use.
|
|
|
|
|
I am fairly sure it is inside the external library. It processes the images and create all the threads. I only provide an operator interface and process the results.
So many years of programming I have forgotten more languages than I know.
|
|
|
|
|
If it's in that library then you have no recourse but to notify the vendor that their library is leaking memory.
|
|
|
|
|
I have gone to the vendor. Since it takes hours and several 100,000 images they cannot reproduce it and cannot deal with it. It is kind of an exponential failure. Once you get one then there is a higher probability of getting the second, etc.
I do not expect a fix at this point but still hope. It is just a very different kind of bug than I have ever seen and in so many different ways. I was kind of hoping that someone else had seen something like this and might have some clues because it would be really nice to fix.
So many years of programming I have forgotten more languages than I know.
|
|
|
|
|
The only way to fix it is to get the source for the component you're using (yeah, right) and rework the component or scrap the component you're using and use a different library that does the same job, or work up a component from scratch yourself.
|
|
|
|
|
There's no magic bullet to fix threading issues. You can't try and arbitrarily kill threads because you have no idea as to whether or not they are busy. The problem is, doing threading right is hard - very, very hard. I wouldn't accept their answer that they can't reproduce it - if necessary, you could send them a slimmed down version of your code that triggers the leak and let them use that with their debuggers.
|
|
|
|
|
I found the problem. It is a memory leak by design in the TextBox control. There is a feature of this box that allows you to undo a change. By default it is set to infinite. Every time you update the value in the control whether from the keyboard or from the code behind it adds to this buffer. It can be turned off completely by putting a -1 in the number of values to be buffered.
This is well documented in MSDN forums but several years old. Finding the right search key that forces it to go back that far is very difficult.
This is an old tread of mine I just ran across and forgot to update it when I found the answer. I hope this will help others when they do a search.
So many years of programming I have forgotten more languages than I know.
|
|
|
|
|
I have an usercontrol that contains a toolstrip. The toolstrip is exposed through the usercontrol by a readonly property 'HostStrip' with DesignerSerializationVisibility.Content attribute. In this way we can handle the toolstrip and its contents from the usercontrol.
While using the usercontrol in an application, after adding the elements of the toolstrip, if I copy the whole usercontrol and paste it somewhere else, the elements of the toolstrip get deleted. I need to add them all over again. Why is this happening and can it be solved?
Regards!
|
|
|
|