|
Hello,
can someone show me how to use this function?
I recive only errors
regards
termal
|
|
|
|
|
termal wrote: I recive only errors
Are we supposed to guess what those are?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello,
i try to use
BOOL CDemoDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);
function and i dont know how to do this!
I recive an error in line with message map:
ON_NOTIFY(WM_NOTIFY, IDC_LIST, OnNotify)
Error is:
error C2440: 'type cast' : cannot convert from 'int (__thiscall CTabAll::*)(unsigned int,long,long *)' to 'void (__thiscall CCmdTarget::*)(struct tagNMHDR *,long *)'
Pointers to members have different representations; cannot cast between them
ok, i see i have different parameters, but how to do right!
thanks
termal
|
|
|
|
|
Are you using VS6 or VS200x?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello David,
i use VS6.
regards
temal
|
|
|
|
|
Read the error message. The compiler is expecting the parameter list to be (NMHDR*, LRESULT*) but your function has (WPARAM, LPARAM, LRESULT*) (mentally substitute LRESULT for long , it's a typedef )
|
|
|
|
|
Michael Dunn wrote: The compiler is expecting the parameter list to be (NMHDR*, LRESULT*)...
Why is that, Mike? I'm looking through all of my examples, and it's a three-argument method.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
See here: clickety[^] - see the section "ON_NOTIFY: Handling WM_NOTIFY Messages in MFC Applications"
|
|
|
|
|
I guess it changed in MFC 8. It's
BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
on MFC 7.1 (VS2003) as well.
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
That's what struck me as odd. This VS2005 page shows it to take three arguments.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Yep - CWnd::OnNotify[^]
I wonder which is true? I only have VS2005 Express so I can't test it
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Arg Now I see it - The OnNotify with 3 arguments is a virtual function that doesn't require
a message map entry. The ones in the link from Michael Dunn are for use with the more specific
ON_NOTIFY message map macros.
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hello all,
maybe is that the reason why i dont have any error when in dont make any message map entries!
That is what i dont know before!
I try to use this like in
http://www.codeproject.com/miscctrl/gridctrl.asp[^]
Here is:
BOOL CGridCtrlDemoDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
thanks to all for help!
regards
termal
|
|
|
|
|
Did you get it working?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hello,
yes, it works, i only remove the macro ON_NOTIFY(...) and this works...
I didn't know that i dont have to call this macro?
But im now more confused as before, when should i use this OnNotify(..) with 3 paramethers, and when this one with two params?
I like to use my MFC Grid in virtual mode!
regards
termal
|
|
|
|
|
The virtual CWnd::OnNotify is called for every child notification. According to the document
TN061: ON_NOTIFY and WM_NOTIFY Messages[^], the default implementation checks the
message map for notification handlers.
The message map ON_NOTIFY lets you relate a specific notification code and control ID to a
specific function. Without using the ON_NOTIFY macro (just overriding OnNotify), you need to
extract this information yourself.
That's the difference.
Here's what the document states:
In general, you do not override OnNotify. Instead, you provide a handler function and add a
message-map entry for that handler to the message map of your owner window's class.
Make sense?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hello Mark,
i can now use this OnNotify() like in MFC Grid Control from Chris Maunder, but one question is there!
Where are my own data, i use pGrid->InsertRow() and pGrid->SetItemText(); to add my data,
but now is there my sample message?
thanks
termal
|
|
|
|
|
hmm I'm not sure about that one. I've never used Chris' control
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
In my OnSize:
m_List.SetWindowPos(NULL,
m_rcOldList.left*(cx-m_rcOldWnd.left)/(m_rcOldWnd.right-m_rcOldWnd.left),
m_rcOldList.top*(cy-m_rcOldWnd.top)/(m_rcOldWnd.bottom-m_rcOldWnd.top),
m_rcOldList.left+(m_rcOldList.right-m_rcOldList.left)*(cx-m_rcOldWnd.left)/ (m_rcOldWnd.right-m_rcOldWnd.left),
m_rcOldList.top+(m_rcOldList.bottom-m_rcOldList.top)*(cy-m_rcOldWnd.top)/(m_rcOldWnd.bottom-m_rcOldWnd.top),
SWP_NOZORDER);
But the ListBox changes not very correctly,how should i convert the coordinates to make the change more precise? Thank you!
-- modified at 9:58 Wednesday 18th April, 2007
|
|
|
|
|
kingliub wrote: But the ListBox changes not very correctly...
Which means what? What exactly are you trying to do?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I can only guess from your description that the coordinates you work with are wrong. Make sure you use coordinates relative to you point of reference... see GetWindowRect(), ScreenToClient(), GetClientRect() .
|
|
|
|
|
I can sure the coordinates are right,but the methord I used to convert the coordinates is not very precise,which make the ListBox and the dailog`s proportion seem a little wrong. So can you give a more precise methord to locate the ListBox`s size and position? Thanks very much!
|
|
|
|
|
kingliub wrote: but the methord I used to convert the coordinates is not very precise
Please show the code, otherwise it is hard to help.
|
|
|
|
|
Now I have made it,I do like this:
CListBox m_List;// The ListBox;
CRect m_rcOldList;// The initialization WindowRect of the ListBox;
CRect m_rcOldWnd;// The initialization ClientRect of the Window;
OnSize(UINT nType, int cx, int cy)
{
m_List.SetWindowPos(NULL,m_rcOldList.left*cx/m_rcOldWnd.Width(),
m_rcOldList.top*cy/m_rcOldWnd.Height(),
m_rcOldList.Width()*cx/m_rcOldWnd.Width(),
m_rcOldList.Height()*cy/m_rcOldWnd.Height(),
SWP_NOZORDER);
}
This can work well,but there is still a problem, I want to define two variable:
int m_iPercentX;// The percent of the window`s client width has changed
int m_iPercentY;// The percent of the window`s client height has changed
OnSize(UINT nType, int cx, int cy)
{
m_iPercentX=cx/m_rcOldWnd.Width();
m_iPercentY=cy/m_rcOldWnd.Height();
m_List.SetWindowPos(NULL,m_rcOldList.left*m_iPercentX,
m_rcOldList.top*m_iPercentY,
m_rcOldList.Width()*m_iPercentX,
m_rcOldList.Height()*m_iPercentY,
SWP_NOZORDER);
}
But as you know, the m_iPercentX and m_iPercentY can`t be very precise, so the position of the ListBox will be a little wrong, how should I do? Thank you!
|
|
|
|
|
kingliub wrote: m_iPercentX and m_iPercentY can`t be very precise, so the position of the ListBox will be a little wrong
I see, this is a mathematical problem. Here a possible solutions, when calculating the position of a control don't throw away the fractions (of a pixel) and further resizing will be accurate. For an implementation see CResizeCtrl in method CResizeCtrl::CalcValue() plus bugfix!
Hope it helps.
|
|
|
|