control flicker when I use double buffering to avoid window flicker
Now i need to draw some graphics on the entire
dialog ......also ,on the dialog i have some drag Bars(for
example,buttons)
I use double buffer to avoid the dialog flicker ,do something like
this:
1. CRect rect;
this->GetClientRect(rect);
m_memBmp.CreateCompatibleBitmap(pDC,rect.Width(),rect.Height());
CBitmap *pOldBmp=m_memDC.SelectObject(&m_memBmp);
//.........draw graphics into memDC...
pDC->BitBlt(0,0,rect.Width(),rect.Height(),&m_memDC,
0,0,SRCCOPY);
m_memBmp.DeleteObject();
m_memDC.DeleteDC();
2. override the OnEraseBkgnd function ,just to return TRUE;
With the two steps above ,the dialog's flickering can be avoided..
...but when i drag the button to move ,the button flickers....
is there anyway to solve this problem?
thanks for any reply
X-Hamster-Info: Score=0 ScoreLoad=0 ScoreSave=0 Received 110531230252
Xref: localhost microsoft.public.vc.mfc:11609
Path: news.ett.com.ua!nntp.ukr.net!volia.net!news2.volia.net!feed-A.news.volia.net!postnews.google.com!22g2000prx.googlegroups.com!not-for-mail
From: Dani Peer <danipeer@gmail.com>
Newsgroups: microsoft.public.vc.mfc
Subject: Re: CEdit does not get WM_CHAR in a DLL when the main application is minimized
Date: Tue, 31 May 2011 09:32:35 -0700 (PDT)
Organization: http://groups.google.com
Lines: 149
Message-ID: <9774acc0-2970-4113-a02d-daccf26486ec@22g2000prx.googlegroups.com>
References: <5b9cade5-2c62-4632-969d-bbf0b4ed3b3d@18g2000prd.googlegroups.com> <973au6tbrp785scch0hvupn3k1iabgit4j@4ax.com>
NNTP-Posting-Host: 192.118.118.1
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1306859556 5636 127.0.0.1 (31 May 2011 16:32:36 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Tue, 31 May 2011 16:32:36 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: 22g2000prx.googlegroups.com; posting-host=192.118.118.1; posting-account=bjRrlAoAAADujcN-Kpy9j4fdhMD-q3UH
User-Agent: G2/1.0
X-Google-Web-Client: true
X-Google-Header-Order: ARLUEHNKC
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64;
Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR
3.0.30729; Media Center PC 6.0; InfoPath.2; GTB7.0),gzip(gfe)
X-Old-Xref: news.ett.com.ua microsoft.public.vc.mfc:34947
On May 31, 7:15 pm, Joseph M. Newcomer <newco...@flounder.com> wrote:
See below...
On Tue, 31 May 2011 07:45:59 -0700 (PDT), Dani Peer <danip...@gmail.com> =
wrote:
Hi,
I have a simple application that lunch a DLL. The DLL opens a window
with a splitter of 2 CFormView and each one of the forms there is an
edit.
****
Note that applications do not "launch" DLLs. They merely use them. =
Or, as you indicate
below, dynamically load them.
****>The code is as following:
void CTest002View::OnBnClickedButton2()
****
You really have to stop using the stupid names that VS assigns to control=
s and change the
names to something that has meaning.
****>{
HINSTANCE hDLL; // Handle to DLL
hDLL = LoadLibrary("SessionWindow.dll");
****
LoadLibrary(_T("SessionWindow.dll"));
Might as well start programming Unicode-aware. It is a good habit to d=
evelop. Stop
thinking that 8-bit characters are useful.
****> if (hDLL == NULL)
FreeLibrary(hDLL);
****
This is silly. If the hDLL is NULL, there is no possible way you can c=
all FreeLibrary on
a NULL handle. Note that what you wrote here is
if(hDLL == NULL)
FreeLibrary(NULL);
which does not make sense
****> else
{
typedef BOOL (CreateObject3)();
CreateObject3* pCreateObject3 = (CreateObject3
*)GetProcAddress(hDLL, "CreateObject3");
****
It might be really, really useful here to see if pCreateObject3 is NULL b=
efore trying to
use it...
Note that GetProcAddress is the *only* API that uses 8-bit only character=
s, so using _T()
around the second argument would actually be incorrect. But this is ju=
st about the only
exception to using _T() you will encounter, except in very rare and exoti=
c situations.
****> BOOL bRet = (pCreateObject3)();
****
You do not need to put pCreateObject3 in parentheses; you can write
BOOL bRead = pCreateObject3();
***> }
}
The method in the DLL is as following:
extern "C" __declspec(dllexport) BOOL CreateObject3()
{
//AFX_MANAGE_STATE(AfxGetStaticModuleState());
SessionFrame2* pSessionFrame2 = new SessionFrame2;
pSessionFrame2->Create(NULL, _T("Session Frame"),
WS_OVERLAPPEDWINDOW , CRect(20, 20, 400, 400), NULL, NULL,
WS_EX_TOPMOST);
****
I'm not sure what the totally random numbers 20, 20, 400, 400 could possi=
bly mean. If you
care about window sizes, you will compute them dynamically based upon oth=
er
characteristics of the screen, its resolution, the parent frame size, etc=
.. There is no
way these values can have meaning other than on one machine with one curr=
ent default font,
a particular graphics card, a particular screen resolution, a particular =
version of the
device driver for the card, and a particular display screen.
****> pSessionFrame2->ShowWindow(SW_SHOWNORMAL);
return TRUE;
}
Everything works fine, and when I minimized the main application I
still can type on the edits in the dll.
But, when I'm adding the method
AFX_MANAGE_STATE(AfxGetStaticModuleState());
I can not type on the edits in the DLL when I minimized the
application.
****
What is SessionFrame2 derived from; I can't tell what Create means unless=
I know the class
of the object being created. However, I'm guessing from the name it mi=
ght be a class
derived from CMDIChildWnd, in which case the fifth parameter is the paren=
t window which
you have specified as NULL, which means the parent is supposed to be the =
main application
window. In this case, if you minimize the application, the frame windo=
w you just created
should disappear as well. The fact that it does not means that I may h=
ave guessed wrong
about the class this is derived from.
Note that I have no idea about what AFX_MANAGE_STATE does to the ability =
to find the main
application window, but if this SessionFrame2 class really is derived fro=
m CMDIChildWnd,
the first thing I'd do is start single-stepping to see what the parent AC=
TUALLY is
computed as being, or I'd use Spy++ to identify the parent window; it sou=
nds suspiciously
like you have a parent that is the desktop, which allows the window to ig=
nore what happens
to the main frame.
Also, you have not indicated how the edit control is created, or who crea=
tes it; if you
have a CFormView in this view, that would be an interesting fact to know.=
I'm not sure at
this point it helps, but it would be useful to know.
Note that if the parent of the window is the desktop, then what you are s=
eeing is
*exactly* how it is *supposed* to behave. But I suspect that you do no=
t want the parent
of the window in question to be to the desktop, but to be the main applic=
ation frame.
joe
Any idea ?
-- Dani
Joseph M. Newcomer [MVP]
email: newco...@flounder.com
Web:http://www.flounder.com
MVP Tips:http://www.flounder.com/mvp_tips.htm
Thanks,
1. SessionFrame2 derived from CFrameWndEx.
2. The Edit are created as part of the CFormView resources.