Click here to Skip to main content
15,914,229 members
Home / Discussions / C#
   

C#

 
GeneralRe: Recording my internet browsing on file Pin
BhuvanRamIconcept8-Nov-11 1:13
BhuvanRamIconcept8-Nov-11 1:13 
GeneralRe: Recording my internet browsing on file Pin
Member 83534878-Nov-11 2:13
Member 83534878-Nov-11 2:13 
AnswerRe: Recording my internet browsing on file Pin
BobJanova8-Nov-11 1:19
BobJanova8-Nov-11 1:19 
GeneralRe: Recording my internet browsing on file Pin
Member 83534878-Nov-11 3:55
Member 83534878-Nov-11 3:55 
GeneralRe: Recording my internet browsing on file Pin
BobJanova8-Nov-11 4:16
BobJanova8-Nov-11 4:16 
GeneralRe: Recording my internet browsing on file Pin
Member 83534878-Nov-11 5:04
Member 83534878-Nov-11 5:04 
GeneralRe: Recording my internet browsing on file Pin
BobJanova8-Nov-11 5:19
BobJanova8-Nov-11 5:19 
QuestionWM_NCPAINT and Massive Amount of Flicker Pin
Matt U.7-Nov-11 14:39
Matt U.7-Nov-11 14:39 
Hello again, CP! I am now trying to create a custom Form by painting a new title bar. I have never done this before but I did remember seeing it a lot when I was heavy into C++ and MFC. So I knew to look for WM_NCPAINT. The resources I found were telling me to override WndProc for the form and catch WM_NCPAINT, and then do my custom drawing from there. So this is what I did:

C#
protected override void WndProc(ref Message m)
        {
            // Handle non-client painting
            IntPtr hdc = GetWindowDC(m.HWnd);
            Graphics g = null;
            if ((int)hdc != 0)
                g = Graphics.FromHdc(hdc);

            if (m.Msg == WM_NCPAINT || m.Msg == WM_NCACTIVATE || m.Msg == WM_SETTEXT)
            {
                if ((int)hdc != 0)
                {
                    OnNcPaint(g);
                    ReleaseDC(m.HWnd, hdc);

                    m.Result = (IntPtr)1;
                }
            }
            else
                base.WndProc(ref m);
        }


In OnNcPaint(Graphics) I make a simple call to graphics.FillRectangle, which fills the entire rectangle with a solid color (in this case, Color.Blue). However, when I resize the form I am seeing a large amount of flickering across the entire form. The background is not custom painted. I have ResizeRedraw set in the form's "SetStyle()" method. When I remove ResizeRedraw it does not paint properly at all.

How can I eliminate the flicker here? This is kind of irritating. Haha. Smile | :)

BTW, I have "base.WndProc(ref m);" in the "else" statement because otherwise, if I call it alongside WM_NCPAINT, it will just paint Windows' non-client area (Win7, Aero Theme). Thanks in advance.
djj55: Nice but may have a permission problem
Pete O'Hanlon: He has my permission to run it.

AnswerRe: WM_NCPAINT and Massive Amount of Flicker Pin
Luc Pattyn7-Nov-11 15:35
sitebuilderLuc Pattyn7-Nov-11 15:35 
GeneralRe: WM_NCPAINT and Massive Amount of Flicker Pin
Matt U.7-Nov-11 15:43
Matt U.7-Nov-11 15:43 
AnswerRe: WM_NCPAINT and Massive Amount of Flicker Pin
Luc Pattyn7-Nov-11 16:06
sitebuilderLuc Pattyn7-Nov-11 16:06 
GeneralRe: WM_NCPAINT and Massive Amount of Flicker Pin
Matt U.7-Nov-11 16:25
Matt U.7-Nov-11 16:25 
AnswerRe: WM_NCPAINT and Massive Amount of Flicker Pin
Luc Pattyn8-Nov-11 1:38
sitebuilderLuc Pattyn8-Nov-11 1:38 
AnswerRe: WM_NCPAINT and Massive Amount of Flicker Pin
J a a n s7-Nov-11 21:52
professionalJ a a n s7-Nov-11 21:52 
QuestionI want to use switch statement in windows form application how to use switch statement through buttons and textboxes ? Pin
zahra19917-Nov-11 7:28
zahra19917-Nov-11 7:28 
AnswerMessage Removed Pin
7-Nov-11 7:34
professionalN_tro_P7-Nov-11 7:34 
GeneralRe: I want to use switch statement in windows form application how to use switch statement through buttons and textboxes ? Pin
zahra19917-Nov-11 7:37
zahra19917-Nov-11 7:37 
GeneralMessage Removed Pin
7-Nov-11 8:04
professionalN_tro_P7-Nov-11 8:04 
GeneralRe: I want to use switch statement in windows form application how to use switch statement through buttons and textboxes ? Pin
zahra19917-Nov-11 8:14
zahra19917-Nov-11 8:14 
GeneralMessage Removed Pin
7-Nov-11 8:41
professionalN_tro_P7-Nov-11 8:41 
GeneralRe: I want to use switch statement in windows form application how to use switch statement through buttons and textboxes ? Pin
zahra19917-Nov-11 8:44
zahra19917-Nov-11 8:44 
GeneralRe: I want to use switch statement in windows form application how to use switch statement through buttons and textboxes ? Pin
zahra19917-Nov-11 8:58
zahra19917-Nov-11 8:58 
AnswerRe: I want to use switch statement in windows form application how to use switch statement through buttons and textboxes ? Pin
BillWoodruff7-Nov-11 19:32
professionalBillWoodruff7-Nov-11 19:32 
QuestionPound sign in XML Pin
RugbyLeague7-Nov-11 1:54
RugbyLeague7-Nov-11 1:54 
AnswerRe: Pound sign in XML Pin
Reiss7-Nov-11 3:32
professionalReiss7-Nov-11 3:32 

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.