Click here to Skip to main content
15,887,812 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 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 
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 
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?
C#
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)
        {
            // Create a C "true" boolean as an IntPtr
            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
C#
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.
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 
GeneralRe: error in c# Pin
User349030-May-13 3:05
User349030-May-13 3:05 
Questionbarcode Pin
arash_saba28-May-13 19:59
arash_saba28-May-13 19: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.