Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
date: Thu, 10 Jul 2008 17:36:45 +0100,    group: microsoft.public.win32.programmer.ui        back       


control painting, text messages and headaches   
Hello Guys,

In my application I have a simple static control that can display text with 
any color, font, etc. I have derived a class from CWnd, I handle the 
WM_PAINT message in my own OnPaint(), and I have put a Text Control onto my 
application in the designer (and then I put the DDX_Control macro to link 
the resource id to my CWnd derived class) - that's how it works.

I also have a tester application (itis a different process) that gets the 
value of this control by calling the ::GetWindowText() API (that internally 
sends WM_GETTEXT if I am not mistaken)
Now my problem is that once I call SetWindowText on my control in the 
application, it flickers, and it seems to call the OnPaint function of the 
CWnd class. If I do not call the SetWindowText (therefore I fool CWND, it 
has no idea about the text it displays), GetWindowText() it the tester 
returns the text of the CWnd, that is not what I want.

So I have two options now: either the flicker, or the testing problem.

My questions:

1. Is there a way to stop CWnd::OnPaint from doing anything?

2. Or is there a way to say to CWnd::SetWindowText not to invoke 
CWnd::OnPaint?

3. Or is there a way to direct the WM_GETTEXT message from CWnd to my class 
(without hooks, that would be far too complex...)

Thank you for all answers!!!

Jozsi
date: Thu, 10 Jul 2008 17:36:45 +0100   author:   Jozsef Bekes

Re: control painting, text messages and headaches   
On Jul 10, 9:36 am, "Jozsef Bekes"  wrote:
> Hello Guys,
>
> In my application I have a simple static control that can display text with
> any color, font, etc. I have derived a class from CWnd, I handle the
> WM_PAINT message in my own OnPaint(), and I have put a Text Control onto my
> application in the designer (and then I put the DDX_Control macro to link
> the resource id to my CWnd derived class) - that's how it works.
>
> I also have a tester application (itis a different process) that gets the
> value of this control by calling the ::GetWindowText() API (that internally
> sends WM_GETTEXT if I am not mistaken)
> Now my problem is that once I call SetWindowText on my control in the
> application, it flickers, and it seems to call the OnPaint function of the
> CWnd class. If I do not call the SetWindowText (therefore I fool CWND, it
> has no idea about the text it displays), GetWindowText() it the tester
> returns the text of the CWnd, that is not what I want.
>
> So I have two options now: either the flicker, or the testing problem.
>
> My questions:
>
> 1. Is there a way to stop CWnd::OnPaint from doing anything?
>
> 2. Or is there a way to say to CWnd::SetWindowText not to invoke
> CWnd::OnPaint?
>
> 3. Or is there a way to direct the WM_GETTEXT message from CWnd to my class
> (without hooks, that would be far too complex...)
>
> Thank you for all answers!!!
>
> Jozsi



Hi,

What happnes when you handle the following message
and return TRUE, does SetWindowText() cause a flicker?

	WM_ERASEBKGND

http://msdn.microsoft.com/en-us/library/ms648055(VS.85).aspx

Kellie.
date: Thu, 10 Jul 2008 11:10:34 -0700 (PDT)   author:   Kellie Fitton

Re: control painting, text messages and headaches   
You say you have:

    - a simple static control
    - a class derived from CWnd
    - a Text Control

It is not clear to me if they are all the same or all different or if one of 
them is the same as the other or what.

You also say "gets the value of this control" but I don't know what "this" 
is.

I know what CWnd is but I do not know what CWND is.

Most likely the problem is caused by something that is not described in your 
message.


"Jozsef Bekes"  wrote in message 
news:e0jPmsq4IHA.1204@TK2MSFTNGP04.phx.gbl...
> Hello Guys,
>
> In my application I have a simple static control that can display text 
> with any color, font, etc. I have derived a class from CWnd, I handle the 
> WM_PAINT message in my own OnPaint(), and I have put a Text Control onto 
> my application in the designer (and then I put the DDX_Control macro to 
> link the resource id to my CWnd derived class) - that's how it works.
>
> I also have a tester application (itis a different process) that gets the 
> value of this control by calling the ::GetWindowText() API (that 
> internally sends WM_GETTEXT if I am not mistaken)
> Now my problem is that once I call SetWindowText on my control in the 
> application, it flickers, and it seems to call the OnPaint function of the 
> CWnd class. If I do not call the SetWindowText (therefore I fool CWND, it 
> has no idea about the text it displays), GetWindowText() it the tester 
> returns the text of the CWnd, that is not what I want.
>
> So I have two options now: either the flicker, or the testing problem.
>
> My questions:
>
> 1. Is there a way to stop CWnd::OnPaint from doing anything?
>
> 2. Or is there a way to say to CWnd::SetWindowText not to invoke 
> CWnd::OnPaint?
>
> 3. Or is there a way to direct the WM_GETTEXT message from CWnd to my 
> class (without hooks, that would be far too complex...)
>
> Thank you for all answers!!!
>
> Jozsi
>
>
>
date: Sat, 12 Jul 2008 07:36:25 -0700   author:   Sam Hobbs _change_social_to_socal

Re: control painting, text messages and headaches   
Hi

Sorry for being so inaccurate. I only have one control. It is derived from 
CWnd. CWND = CWnd in my post. When I said CStatic I wanted to explain the 
functionality of the control. Its task is to display a label, just like a 
CStatic, but you can cusomize the type and the size of the font, also you 
can specify some colors.

Text Control: in the designer I put an element (control?) onto my dialog, 
and then I subclass that element by using the DDX_Control() function in the 
dialog's DoDataExchange() function. The type of the element in the designer 
is Text Control.

"gets the value of this control" simply means that I call GetWindowText() on 
this only control that I described.

Finally I have reduced the flicker, I have implemented my own WindowProc() 
like this:

LRESULT CIPMPColorStatic::WindowProc(UINT message, WPARAM wParam, LPARAM 
lParam)
{
  if (message == WM_PAINT)
  {
    CIPMPColorStatic::OnPaint();
    return 0;
  }

  if (message == WM_ERASEBKGND)
  {
    return TRUE;
  }

  //followings have to be here because of the tester.
  //if the tester calls WM_GETTEXT, I have to return the proper text,
  // because CWnd has no idea about it
  if (message == WM_SETTEXT)
  {
    m_text.Empty();
    TCHAR* pCh = (TCHAR*)lParam;
    while (*pCh != 0)
    {
      m_text.AppendChar(*pCh);
      pCh++;
    }
    return 1;
  }
  if (message == WM_GETTEXTLENGTH)
  {
    return m_text.GetLength();
  }
  if (message == WM_GETTEXT)
  {
    memset((void*)lParam, 0, wParam);
    int size = m_text.GetLength() < (int)wParam ? wParam : 
m_text.GetLength();
    memcpy((void*)lParam, m_text.GetBuffer(), size);
    return 1;
  }
  return CWnd::WindowProc(message, wParam, lParam);
}

Still if I call

SendMessage(WM_SETTEXT, 0, (LPARAM)(tmp.GetBuffer(0)));

from the SetWindowText() function of my control, the flicker happens as 
well. If I just store m_text, and do not notify the parent, then the flicker 
is reduced a lot, but it is not completely gone. Actually the WM_ERASEBKGND 
branch did not help.

Thank you for your help!!

Jozsi
date: Wed, 16 Jul 2008 14:34:53 +0100   author:   Jozsef Bekes

Re: control painting, text messages and headaches   
I have found the solution. I had to add the branches to WindowProc() that 
handle window enable/disable. Now it is working fine :-)

Thanks,
Jozsi


"Jozsef Bekes"  wrote in message 
news:O5ft7i05IHA.2332@TK2MSFTNGP03.phx.gbl...
> Hi
>
> Sorry for being so inaccurate. I only have one control. It is derived from 
> CWnd. CWND = CWnd in my post. When I said CStatic I wanted to explain the 
> functionality of the control. Its task is to display a label, just like a 
> CStatic, but you can cusomize the type and the size of the font, also you 
> can specify some colors.
>
> Text Control: in the designer I put an element (control?) onto my dialog, 
> and then I subclass that element by using the DDX_Control() function in 
> the dialog's DoDataExchange() function. The type of the element in the 
> designer is Text Control.
>
> "gets the value of this control" simply means that I call GetWindowText() 
> on this only control that I described.
>
> Finally I have reduced the flicker, I have implemented my own WindowProc() 
> like this:
>
> LRESULT CIPMPColorStatic::WindowProc(UINT message, WPARAM wParam, LPARAM 
> lParam)
> {
>  if (message == WM_PAINT)
>  {
>    CIPMPColorStatic::OnPaint();
>    return 0;
>  }
>
>  if (message == WM_ERASEBKGND)
>  {
>    return TRUE;
>  }
>
>  //followings have to be here because of the tester.
>  //if the tester calls WM_GETTEXT, I have to return the proper text,
>  // because CWnd has no idea about it
>  if (message == WM_SETTEXT)
>  {
>    m_text.Empty();
>    TCHAR* pCh = (TCHAR*)lParam;
>    while (*pCh != 0)
>    {
>      m_text.AppendChar(*pCh);
>      pCh++;
>    }
>    return 1;
>  }
>  if (message == WM_GETTEXTLENGTH)
>  {
>    return m_text.GetLength();
>  }
>  if (message == WM_GETTEXT)
>  {
>    memset((void*)lParam, 0, wParam);
>    int size = m_text.GetLength() < (int)wParam ? wParam : 
> m_text.GetLength();
>    memcpy((void*)lParam, m_text.GetBuffer(), size);
>    return 1;
>  }
>  return CWnd::WindowProc(message, wParam, lParam);
> }
>
> Still if I call
>
> SendMessage(WM_SETTEXT, 0, (LPARAM)(tmp.GetBuffer(0)));
>
> from the SetWindowText() function of my control, the flicker happens as 
> well. If I just store m_text, and do not notify the parent, then the 
> flicker is reduced a lot, but it is not completely gone. Actually the 
> WM_ERASEBKGND branch did not help.
>
> Thank you for your help!!
>
> Jozsi
>
>
>
date: Wed, 20 Aug 2008 17:56:38 +0100   author:   Jozsef Bekes

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us