|
i think if you can use the virtual function.i don't really understand just my feeling .
|
|
|
|
|
I use Getparent() in the OnEraseBkgnd(CDC *pDC) to get the CWnd* of the dialog. And then I can copy the background of the button. The code is as following:
if(!m_bHasErased)<br />
{<br />
CRect rc;<br />
GetClientRect(&rc);<br />
ClientToScreen(&rc);<br />
CWnd *wndParent=GetParentOwner();<br />
CDC *parentDC=wndParent->GetDC();<br />
ScreenToClient(&rc);<br />
CDC memDC;<br />
memDC.CreateCompatibleDC(parentDC);<br />
CBitmap *oldbmp=memDC.SelectObject(&m_bmpBG);<br />
<br />
memDC.BitBlt(0,0,rc.Width(),rc.Height(),parentDC,rc.left,rc.top,SRCCOPY);<br />
<br />
memDC.SelectObject(oldbmp);<br />
wndParent->ReleaseDC(parentDC);<br />
m_bHasErased=TRUE;<br />
}<br />
return CButton::OnEraseBkgnd(pDC);<br />
Then I copy this background to rect in OnPaint() as following:
void CTransBT::OnPaint()<br />
{<br />
CPaintDC dc(this);
CBrush brush;<br />
brush.CreatePatternBrush(&m_bmpBG);<br />
CRect rc;<br />
GetClientRect(&rc);<br />
CDC memDC;<br />
memDC.CreateCompatibleDC(&dc);<br />
memDC.FillRect(&rc,&brush);<br />
dc.BitBlt(0,0,rc.Width(),rc.Height(),&memDC,0,0,SRCCOPY);<br />
memDC.DeleteDC();<br />
}<br />
But the content be drawed is the background under the dialog, not under the button's.
|
|
|
|
|
How did you confirm that your getting the desktops pointer?
whiteclouds wrote: ClientToScreen(&rc);
whiteclouds wrote: ScreenToClient(&rc);
I think this two functions will cancel out each other. the second one should be like
wndParent->ScreenToClient(&rc); isnt it?
|
|
|
|
|
Naveen.R wrote: How did you confirm that your getting the desktops pointer?
Because the content br drawn on button is part of the desktop, not the dialog as I hope.
|
|
|
|
|
Did you try modifing as I said?
|
|
|
|
|
I had tried already. The result was same as before.
|
|
|
|
|
I suggest you to use the GetParent() instead of GetParentOwner().
|
|
|
|
|
Also other things is that you should not capture this from earse background function. Because you will get some white background or some other junk items when you capture so. This problem can be solved if you use the WM_PRINTCLIENT message.
|
|
|
|
|
I'm pleased to see your reply. Thx at first. But I can't find the message you refered. This message isn't existed.
|
|
|
|
|
whiteclouds wrote: But I can't find the message you refered
here it is WM_PRINTCLIENT[^]
|
|
|
|
|
Naveen.R wrote: here it is WM_PRINTCLIENT[^]
I can't find this message in winuser.h of my system. But I can find it in MSDN. Why?
And I can't find it in the message list of CDialog of MFC too. What should I do?
|
|
|
|
|
May be you have to install latest platform SDK. Ho ever u can send this message just by declaring the below macro in your file.
#define WM_PRINTCLIENT 0x0318
|
|
|
|
|
I can't find any address to download the latest SDK. Could you be kind to give me? Thx!
|
|
|
|
|
|
I know this address. I hadn't find any latest SDK fot MFC on it. So I want to know the detailed address. Thx!
|
|
|
|
|
Its not MFC,its win32 programming SDK. Actually you just want the definition of the macro WM_PRINTCLIENT na? for that no need to download all this. Just use the macro I mentioned in the previous post.
|
|
|
|
|
Thx! And I had define WM_PRINTCLIENT by myself. Then I add a function to process it as below:
BEGIN_MESSAGE_MAP(CTransBT, CButton)<br />
ON_WM_ERASEBKGND()<br />
ON_WM_PAINT()<br />
ON_MESSAGE(WM_PRINTCLIENT,OnPrintClient)<br />
END_MESSAGE_MAP()<br />
LRESULT CTransBT::OnPrintClient(WPARAM wParam, LPARAM lParam)<br />
{<br />
if(!m_bHasErased)<br />
{<br />
CRect rc;<br />
GetClientRect(&rc);<br />
ClientToScreen(&rc);<br />
CWnd *wndParent=GetParentOwner();<br />
CDC *parentDC=wndParent->GetDC();<br />
wndParent->ScreenToClient(&rc);<br />
CDC memDC;<br />
memDC.CreateCompatibleDC(parentDC);<br />
CBitmap *oldbmp=memDC.SelectObject(&m_bmpBG);<br />
<br />
memDC.BitBlt(0,0,rc.Width(),rc.Height(),parentDC,rc.left,rc.top,SRCCOPY);<br />
<br />
memDC.SelectObject(oldbmp);<br />
wndParent->ReleaseDC(parentDC);<br />
m_bHasErased=TRUE;<br />
}<br />
return 0;<br />
}<br />
But this function can't work at all! Plz help me again! Thx!
|
|
|
|
|
no no no..
You have to send that message, not handle it.
like
wndParent->SendMessage( WM_PRINTCLIENT, memDC.m_hDC, PRF_CLIENT );
After you send that message, the memDC will contain the dialog image
|
|
|
|
|
mmm...
I had use the code as u say. But the background be gotten is still the background of the desktop. I notice that the button seems like be generated before the dialog be erased. Is this the reason of why I can't get the bg as I hope? If so, how to resolve it?
|
|
|
|
|
The following code should put gridlines into report list.
It does not.
the dwExStyle is set to 1
What am I missing?
Do I have to "activate" extended style?
How?
BOOL CCC_List::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style |= LVS_REPORT | LVS_EDITLABELS;
cs.dwExStyle |= LVS_EX_GRIDLINES;
return CListView::PreCreateWindow(cs);
}
Thanks for reading
Vaclav
|
|
|
|
|
To set the extended style to list control, you must use the CListCtrl::SetExtendedStyle() function.
|
|
|
|
|
Use SetExtendedStyle:
CListCtrl m_list;
m_list.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
|
|
|
|
|
Using
SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE,
LVS_EX_TRACKSELECT | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES,
LVS_EX_TRACKSELECT | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
in "OnUpdate" works.
It also activates editing!
(cs.style |= LVS_REPORT | LVS_EDITLABELS;)
So what is cs.dwExstyle good for in PreCreateWindow ???
(cs.dwExStyle |= LVS_EX_TRACKSELECT| LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES;)
Thanks for your help.
Vaclav
|
|
|
|
|
Vaclav_Sal wrote: So what is cs.dwExstyle good for in PreCreateWindow ???
For the most part, that would be the correct place to set an extended style.
Some controls have special requirements though, as you've seen.
Consistent, huh?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Don't you love this MS "binary" logic?
"Yes No .... Maybe"
I guess using transistors is the whole problem, if MS stuck with diodes we would be OK.
Have a great day anyway. Nice to hear from you.
Vaclav
|
|
|
|