Click here to Skip to main content
15,887,746 members
Home / Discussions / C#
   

C#

 
GeneralRe: To overcome the load screen flashes with user control and images and controls Pin
Lương Tuấn Anh30-May-13 8:24
Lương Tuấn Anh30-May-13 8:24 
GeneralRe: To overcome the load screen flashes with user control and images and controls Pin
Eddy Vluggen30-May-13 9:05
professionalEddy Vluggen30-May-13 9:05 
GeneralRe: To overcome the load screen flashes with user control and images and controls Pin
Lương Tuấn Anh30-May-13 16:00
Lương Tuấn Anh30-May-13 16:00 
GeneralRe: To overcome the load screen flashes with user control and images and controls Pin
Eddy Vluggen31-May-13 6:18
professionalEddy Vluggen31-May-13 6:18 
GeneralRe: To overcome the load screen flashes with user control and images and controls Pin
Lương Tuấn Anh31-May-13 16:54
Lương Tuấn Anh31-May-13 16:54 
GeneralRe: To overcome the load screen flashes with user control and images and controls Pin
Eddy Vluggen31-May-13 21:39
professionalEddy Vluggen31-May-13 21:39 
GeneralRe: To overcome the load screen flashes with user control and images and controls Pin
Lương Tuấn Anh1-Jun-13 7:41
Lương Tuấn Anh1-Jun-13 7:41 
GeneralRe: To overcome the load screen flashes with user control and images and controls Pin
Eddy Vluggen1-Jun-13 11:00
professionalEddy Vluggen1-Jun-13 11:00 
Lương Tuấn Anh wrote:
i will ask you if i dont know Big Grin | :-D
Please do so - wrote the example in a few spare moments, based on a new project;
C#
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 = // load image here
            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); // Create a C "true" boolean as an IntPtr
            Message msgResumeUpdate = Message.Create(
                control.Handle, WM_SETREDRAW, wparam, IntPtr.Zero);
            NativeWindow window = NativeWindow.FromHandle(control.Handle);
            window.DefWndProc(ref msgResumeUpdate);
            control.Invalidate(); // Causes a repaint
        }
    }
}
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 Smile | :)
Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]

GeneralRe: To overcome the load screen flashes with user control and images and controls Pin
Lương Tuấn Anh1-Jun-13 17:51
Lương Tuấn Anh1-Jun-13 17:51 
GeneralRe: To overcome the load screen flashes with user control and images and controls Pin
Lương Tuấn Anh1-Jun-13 18:43
Lương Tuấn Anh1-Jun-13 18:43 
GeneralRe: To overcome the load screen flashes with user control and images and controls Pin
Eddy Vluggen2-Jun-13 0:40
professionalEddy Vluggen2-Jun-13 0:40 
QuestionC# access to a directory path Pin
jazzgirl29-May-13 17:09
jazzgirl29-May-13 17:09 
AnswerRe: C# access to a directory path Pin
Amol_B29-May-13 18:31
professionalAmol_B29-May-13 18:31 
AnswerRe: C# access to a directory path Pin
Anna King30-May-13 3:09
professionalAnna King30-May-13 3:09 
AnswerRe: C# access to a directory path Pin
jazzgirl30-May-13 17:12
jazzgirl30-May-13 17:12 
Questionerror in c# Pin
User349029-May-13 3:03
User349029-May-13 3:03 
AnswerRe: error in c# Pin
Eddy Vluggen29-May-13 3:16
professionalEddy Vluggen29-May-13 3:16 
GeneralRe: error in c# Pin
User349029-May-13 3:36
User349029-May-13 3:36 
QuestionRe: error in c# Pin
Eddy Vluggen29-May-13 3:41
professionalEddy Vluggen29-May-13 3:41 
AnswerRe: error in c# Pin
User349029-May-13 3:48
User349029-May-13 3:48 
GeneralRe: error in c# Pin
Dave Kreskowiak29-May-13 4:13
mveDave Kreskowiak29-May-13 4:13 
GeneralRe: error in c# Pin
Dave Kreskowiak29-May-13 4:11
mveDave Kreskowiak29-May-13 4:11 
GeneralRe: error in c# Pin
Eddy Vluggen29-May-13 4:22
professionalEddy Vluggen29-May-13 4:22 
AnswerRe: error in c# Pin
Abhinav S29-May-13 7:43
Abhinav S29-May-13 7:43 
AnswerRe: error in c# Pin
Anna King30-May-13 2:59
professionalAnna King30-May-13 2:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.