|
i will set property for form is DoubleBuffered = true . but it did not improve much. >.<
|
|
|
|
|
DoubleBuffering the form will speed up drawing "a bit". Disabling drawing as suggested will improve it "a bit" too. Without your code, I can only give these options. If you only need to assign the image to a control, then there would be not much of a "flickering", albeit the screen will show the update.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I have one form and one panel. my Panel set background image are .png. form set DoubleBuffered = true. One user control have more than 10 controls (combobox, textbox...) when User control add to this panel, it flicker
< ====== My Code> http://www.mediafire.com/?1mgh5qjcly1auq2[^]
UC 1 : have DoubleBuffered = true.
But I don't want form flickered when load. I want form load the same when form don't set background image.
|
|
|
|
|
Lương Tuấn Anh wrote: But I don't want form flickered when load.
Then read the link provided to stop it drawing while running the InitializeComponents-method. How long does it take to show that form? Contains many controls?
--edit;
The idea would be for you to post the relevant code, surrounded with pre-tags, not a binary package.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
i don't knows. you can said more details or help me code in this project. Thank
|
|
|
|
|
Lương Tuấn Anh wrote: you can said more details or help me code in this project. That's what I'm trying. Let's try it another way; copy the method below (comes from here[^])
public static class SuspendUpdate
{
private const int WM_SETREDRAW = 0x000B;
public static void Suspend(Control control)
{
Message msgSuspendUpdate = Message.Create(control.Handle, WM_SETREDRAW, IntPtr.Zero,
IntPtr.Zero);
NativeWindow window = NativeWindow.FromHandle(control.Handle);
window.DefWndProc(ref msgSuspendUpdate);
}
public static void Resume(Control control)
{
IntPtr wparam = new IntPtr(1);
Message msgResumeUpdate = Message.Create(control.Handle, WM_SETREDRAW, wparam,
IntPtr.Zero);
NativeWindow window = NativeWindow.FromHandle(control.Handle);
window.DefWndProc(ref msgResumeUpdate);
control.Invalidate();
}
}
Call it in the InitializeComponents , or whereever you put the image in the control.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
can you give me one example for it .. i'm newbie ... thank you very much
|
|
|
|
|
Ehr, no; read the article, it contains the example.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
ok , thank you . i will ask you if i dont know thank you verry much. Do you have Yahoo or mail ?
|
|
|
|
|
Lương Tuấn Anh wrote: i will ask you if i dont know Please do so - wrote the example in a few spare moments, based on a new project;
using System;
using System.Windows.Forms;
using System.Threading;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
SuspendUpdate.Suspend(this);
InitializeComponent();
SuspendUpdate.Resume(this);
}
public void button1_Click(object sender, EventArgs e)
{
SuspendUpdate.Suspend(this.pictureBox1);
this.pictureBox1.Image =
SuspendUpdate.Resume(this.pictureBox1);
}
}
public static class SuspendUpdate
{
const int WM_SETREDRAW = 0x000B;
public static void Suspend(Control control)
{
Message msgSuspendUpdate = Message.Create(
control.Handle, WM_SETREDRAW, IntPtr.Zero, IntPtr.Zero);
NativeWindow window = NativeWindow.FromHandle(control.Handle);
window.DefWndProc(ref msgSuspendUpdate);
}
public static void Resume(Control control)
{
IntPtr wparam = new IntPtr(1);
Message msgResumeUpdate = Message.Create(
control.Handle, WM_SETREDRAW, wparam, IntPtr.Zero);
NativeWindow window = NativeWindow.FromHandle(control.Handle);
window.DefWndProc(ref msgResumeUpdate);
control.Invalidate();
}
}
} Here we add in some help-routines in a new class; they should be in a separate file. Before updating something, call "Suspend" to stop the drawing temporarily and "Resume" to active it again. It'll speed up things on the UI-thread if it doesn't have to paint every change. I've also surrounded the "InitializeComponents" routine with those calls, to speed up the load-time. Again, it helps "a bit", it's not a miracle-worker. If your image is very large (>5 Mb), then it might be wiser to change the image.Lương Tuấn Anh wrote: Do you have Yahoo or mail ? I'm every day available on CodeProject; whenever I open GMail, I also open CodeProjects' forum. I'd also get an email if you reply to one of my messages
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
|
i will set SuspendUpdate for UC and panel but controls add in UC disappeared at load. when mouse move to controls, it will show. Do you see for me will set SuspendUpdate ok?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace testForm
{
public partial class Form1 : Form
{
public Form1()
{
SuspendUpdate.Suspend(this);
InitializeComponent();
loadUC1();
SuspendUpdate.Resume(this);
}
public void loadUC1()
{
panel1.Controls.Clear();
UserControl1 test = new UserControl1();
SuspendUpdate.Suspend(this.panel1);
panel1.Controls.Add(test);
SuspendUpdate.Resume(this.panel1);
}
public void loadUC2()
{
panel1.Controls.Clear();
UserControl2 test2 = new UserControl2();
SuspendUpdate.Suspend(test2);
panel1.Controls.Add(test2);
SuspendUpdate.Resume(test2);
}
private void button1_Click(object sender, EventArgs e)
{
loadUC1();
}
private void button2_Click(object sender, EventArgs e)
{
loadUC2();
}
}
public static class SuspendUpdate
{
private const int WM_SETREDRAW = 0x000B;
public static void Suspend(Control control)
{
Message msgSuspendUpdate = Message.Create(control.Handle, WM_SETREDRAW, IntPtr.Zero,
IntPtr.Zero);
NativeWindow window = NativeWindow.FromHandle(control.Handle);
window.DefWndProc(ref msgSuspendUpdate);
}
public static void Resume(Control control)
{
IntPtr wparam = new IntPtr(1);
Message msgResumeUpdate = Message.Create(control.Handle, WM_SETREDRAW, wparam,
IntPtr.Zero);
NativeWindow window = NativeWindow.FromHandle(control.Handle);
window.DefWndProc(ref msgResumeUpdate);
control.Invalidate();
}
}
}
and code in UC
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace testForm
{
public partial class UserControl1 : UserControl
{
public UserControl1()
{
SuspendUpdate.Suspend(this);
InitializeComponent();
this.DoubleBuffered = true;
SuspendUpdate.Resume(this);
}
}
}
all with the same result.
|
|
|
|
|
Only one control can be suspended at a time; remove the suspend-methods in the UserControls and it should work
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
In a C# 2008/2010 desktop application, I need to be able to allow users the ability
to select a file they need to work with. There needs to be a default directory path. However I need to be able to allow users the ability to select files from whatever directory path they have access to.
Thus can you tell me. show me code, and/or point me to a url I can use as a reference to accomplish my goal?
|
|
|
|
|
use OpenFileDialog Control. this will allow you to choose any file.
You can get file name using OpenFileDialog.FileName
|
|
|
|
|
OpenFileDialog control seems to be the only option for you as it can allow users to choose any file from whatever directory path they want to access.
|
|
|
|
|
|
hi
i have error when i run my c# program.
the error is :
The Microsoft ACE.OLEDB.12.0 provider is not registered on the local machine.
and i have access 2010 on my laptop.
what is the solution for this error ?
|
|
|
|
|
Install JET[^]. Make sure you install the correct version; you'd want the 64-bit version if your CPU (and app!) support it, otherwise the 32-bit version.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
i have the correct version in my laptop.
my laptop has 64bit cpu and i have install access 2010 64 bit
|
|
|
|
|
..and your app? Set to 64-bit?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
yes my c# that i use in visual studio 2010 is 64bit.
Basically the error is not my laptop in my laptop run ok.
but when i try to run my c# setup program in another laptop
that is also 64 bit appears the error message that i said in my previous message.
Also we have the same programs access 2010 in 64 bit cpu.
i don't understand what maybe be the problem..
|
|
|
|
|
The problem is bitness.
Either the target machine doesn't have 64-bit ACE (Access) installed, or your code is running as 32-bit, not 64. You cannot mix 32- and 64-bit code in the same process.
You have to match the ACE bitness to your application, or the other way around. If the target machine has 32-bit Office (Access) installed and your app is compiled as x64 or AnyCPU running on a 64-bit machine, you'll get this message.
If your code is compiled x86 only and there is only 64-bit Office (Access) installed, you'll still get this error.
|
|
|
|
|
Huh?? There is no 64-bit version of JET. It's 32-bit only and was replaced by ACE. ACE comes in both 32- and 64-bit flavors.
|
|
|
|
|
Didn't know, thanks for the info
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|