|
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
|
|
|
|
|
I have a small bit of code that looks something like the example here. It's just a small example I wrote to illustrate to myself how to properly pass arrays of objects around... The node object just contains an integer.
<br />
#include "node.h"<br />
<br />
node** makeArray();<br />
<br />
using namespace std;<br />
<br />
int main(int argc, char* argv[])<br />
{<br />
node** myArray;<br />
myArray = makeArray();<br />
<br />
cout << "The array contains..." << endl;<br />
<br />
cout << (*myArray)->toString() << endl;<br />
myArray++;<br />
cout << (*myArray)->toString() << endl;<br />
myArray++;<br />
cout << (*myArray)->toString() << endl;<br />
}<br />
<br />
node** makeArray()<br />
{<br />
node* out = new node*[3];
<br />
node* test1 = new node(7);
node* test2 = new node(3);<br />
node* test3 = new node(9);<br />
<br />
out[0] = test1;
out[1] = test2;<br />
out[2] = test3;<br />
<br />
cout << out[0]->toString() << endl;<br />
cout << out[1]->toString() << endl;<br />
cout << out[2]->toString() << endl;<br />
<br />
return out;<br />
}<br />
So the makeArray() function passes back a pointer to an array of nodes. Then I can do things to each node in the array by moving around in it with myArray++ or myArray--.
The question is this (or, I guess, questions)... the array has to be dynamically allocated in makeArray() so it won't go out of scope when the function returns. So when I'm done using the array, I should delete it somehow... what is the preferred way? Would it suffice to simply do "delete myArray" after I use it in main? Do I need to decrement it twice first? Should I use delete[]? Do I need to delete twice since it's a double pointer? Do I need to delete each node individually as well? What is the proper procedure in this case?
Thanks!
|
|
|
|
|
|
MALDATA wrote: Then I can do things to each node in the array by moving around in it with myArray++ or myArray--.
Which will cause problems if you ever want to delete that pointer.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I assume that means that I need to go back to the initial value of the pointer (the one that was returned from the function) before deleting it... is that correct?
What I'm getting from these responses it that I should do a "delete" for each node pointer in the array first, then a "delete[]" on the array pointer itself as opposed to "delete"...
Let me know if that's all ok. Thanks!
|
|
|
|
|
MALDATA wrote: I assume that means that I need to go back to the initial value of the pointer (the one that was returned from the function) before deleting it... is that correct?
Yes.
MALDATA wrote: What I'm getting from these responses it that I should do a "delete" for each node pointer in the array first, then a "delete[]" on the array pointer itself as opposed to "delete"...
Yes, that's because new goes with delete , and new[] goes with delete[] .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
what I'm trying to so is set up my complete Dialog before it is shown to the user.
Hence, I want to populate some CStatic's and a CEdit. However, I keep getting an Assert error when I populate the CStatic with text. (haven't gotten to the other CStatic's and CEdit yet).
To summarize what I've got and to pick on the first Assert error
the Dialog Editor shows that the static text ID is: IDC_FW_VERSION
within the Dialog's .h file, the static text is listed as:
public: CStatic m_staticFwVersion;
within the Dialog's .cpp file, ::DoDataExchange():
DDX_Control(pDX, IDC_FW_VERSION, m_staticFwVersion);
However, this code (within OnInitDialog) fails every time with the Assert error:
<br />
CString strVersion;<br />
strVersion.Format("FW Ver %x.%02x, CheckSum = %03x, POST %x %s%s", <br />
(Attributes.VersionNumber >> 8) & 0xff,<br />
(Attributes.VersionNumber >> 0) & 0xff,<br />
nChecksum, nPostResult,(!nPostResult) ? "PASS" : "FAIL",PostResults);<br />
m_staticFwVersion.SetWindowText(strVersion);<br />
the CString comes out to be a typical null terminated string.
The debugger shows me the failure point:
void CWnd::SetWindowText(LPCTSTR lpszString)<br />
{<br />
ENSURE(this);<br />
ENSURE(::IsWindow(m_hWnd) || (m_pCtrlSite != NULL));
both, m_hWnd and m_pCtrlSite are 0
so where should I initialize the static texts ?
|
|
|
|
|
OnInitDialog is the right place to do this. try stepping into that DDX_Control call, to make sure it's really linking the control to that variable.
|
|
|
|