Spin control
-
hi i want to know that how spin control can be attached to its buddy that is some edit control and i want to know that CWnd *pParent is used in dialpog based. if we use pParent in pWndbuddy in followng statement: m_spin.SetBuddy(CWnd *pWndbuddy) then it gives error so tellme wat can i use here. Ashish Dogra MCA Noida
-
hi i want to know that how spin control can be attached to its buddy that is some edit control and i want to know that CWnd *pParent is used in dialpog based. if we use pParent in pWndbuddy in followng statement: m_spin.SetBuddy(CWnd *pWndbuddy) then it gives error so tellme wat can i use here. Ashish Dogra MCA Noida
You can set the buddy for the spin control as //m_spinCtrl is variable for the spin control and m_editctrl for edit box m_spinCtrl .SetBuddy (m_editctrl.GetWindow(IDC_EDIT1)); Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_
-
hi i want to know that how spin control can be attached to its buddy that is some edit control and i want to know that CWnd *pParent is used in dialpog based. if we use pParent in pWndbuddy in followng statement: m_spin.SetBuddy(CWnd *pWndbuddy) then it gives error so tellme wat can i use here. Ashish Dogra MCA Noida
hi can explain clearly .. and if u r using the exact code in ur program then it won't work, remove the CWnd* and use pWndbuddy alone
-
You can set the buddy for the spin control as //m_spinCtrl is variable for the spin control and m_editctrl for edit box m_spinCtrl .SetBuddy (m_editctrl.GetWindow(IDC_EDIT1)); Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_
sir thanks for reply but it does not work as i use this in oninitdialog function m_spin.SetBuddy(m_edit.GetWindow(IDC_EDIT2)); whwre m_spin is variable of spin control and m_edit is variable of edit control. Ashish Dogra MCA Noida
-
sir thanks for reply but it does not work as i use this in oninitdialog function m_spin.SetBuddy(m_edit.GetWindow(IDC_EDIT2)); whwre m_spin is variable of spin control and m_edit is variable of edit control. Ashish Dogra MCA Noida
You need to override the function for OnDeltaposSpin1:
void CTestDlg::OnDeltaposSpin1(NMHDR *pNMHDR, LRESULT *pResult) { LPNMUPDOWN pNMUpDown = reinterpret_cast(pNMHDR); CString s;s.Format ("%d",pNMUpDown->iPos ); m_edit.SetWindowText (s); // TODO: Add your control notification handler code here *pResult = 0; }
Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_
-
You need to override the function for OnDeltaposSpin1:
void CTestDlg::OnDeltaposSpin1(NMHDR *pNMHDR, LRESULT *pResult) { LPNMUPDOWN pNMUpDown = reinterpret_cast(pNMHDR); CString s;s.Format ("%d",pNMUpDown->iPos ); m_edit.SetWindowText (s); // TODO: Add your control notification handler code here *pResult = 0; }
Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_
sir where is this OnDeltaposSpin1 function as this is not in the classwizard or message handler Ashish Dogra MCA Noida
-
hi can explain clearly .. and if u r using the exact code in ur program then it won't work, remove the CWnd* and use pWndbuddy alone
ya thanks as in many function that include CWnd pointer and i check in application the CWnd pointer is *pParent what when i use this one it gives error Ashish Dogra MCA Noida
-
sir where is this OnDeltaposSpin1 function as this is not in the classwizard or message handler Ashish Dogra MCA Noida
In message map add ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN1, OnDeltaposSpin1) //add in the header file afx_msg void OnDeltaposSpin1(NMHDR *pNMHDR, LRESULT *pResult); and copy and paste the code for the implementation of the function as in my above post. You can right click on the spin control if you are working with an MFC Dialog based application and then go to property window to implement this function. Declaring functions/definitions are more error prone if they are done by hand and are not recommended. Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_
-
In message map add ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN1, OnDeltaposSpin1) //add in the header file afx_msg void OnDeltaposSpin1(NMHDR *pNMHDR, LRESULT *pResult); and copy and paste the code for the implementation of the function as in my above post. You can right click on the spin control if you are working with an MFC Dialog based application and then go to property window to implement this function. Declaring functions/definitions are more error prone if they are done by hand and are not recommended. Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_
thanks sir can we use this methode to add function and why this function is not in the message handler Ashish Dogra MCA Noida
-
thanks sir can we use this methode to add function and why this function is not in the message handler Ashish Dogra MCA Noida
Yes we can use this method to add a function but it is not recommended as with this method there are more chances of committing an error and then creating troubles.You can't remember the prototypes for all the handler's etc. Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_
-
thanks sir can we use this methode to add function and why this function is not in the message handler Ashish Dogra MCA Noida
When you Rclick in Spin control and use Event HAndle then you can see UDN_DELTAPOS_**
**_
whitesky