|
i use CEdit Spin, Very troublesome to use,
thanks agian , god bless u
|
|
|
|
|
|
or I wish I can find any similar or equivalent one.
HR
|
|
|
|
|
When I type number and press enter program exits
The program '[5312] NumericEditTest.exe: Native' has exited with code 13
|
|
|
|
|
Has anyone found fix for this?
Pressing enter calls OnDestroy no matter what. Enter key is not captures by neither OnChar OnKeyDown at all. Weird.
If you find a solution to this proble, please post here.
HR
|
|
|
|
|
------------------------------------------------------
my problem:
I have MDI project & i DoModal dialog (in dialog i have an CNumericEdit control)
When 'change spin control' & close dialog and DoModal again make error!
The problem fix with this change (first create m_wndSpinButton then assign value to m_wndEdit):
------------------------------------------------------
class CNumericEdit in .cpp file:
//
//---------------
int CNumericEdit::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CWnd::OnCreate(lpCreateStruct) == -1) return -1;
CRect r(0,0,0,0);
m_wndButton.Create(_T("v"),WS_CHILD|WS_VISIBLE,r,this,1);
m_wndEdit.Create(WS_CHILD|WS_VISIBLE,r,this,2);
m_wndSpinButton.Create(WS_CHILD|WS_VISIBLE|UDS_ARROWKEYS,r,this,3);
m_wndSpinButton.SetRange32(m_nMin,m_nMax);
m_wndEdit.SetWindowText(_T("0"));
return 0;
}
//---------------
//
|
|
|
|
|
I have a dialog with 5 CNumericEdit controls. In the example the main dialog receives the NEN_CHANGED message when the value has changed and then the buddy edit control is updated with the new value. If I use this method of receiving NE_CHANGED msgs, how do I know which CNumericEdit was changed? Is the control ID passed in wParam or lParam?
Ed
|
|
|
|
|
I found out how to do this....
I modified NumericEdit::CreateEx to us the version that specifies the Ctrl ID,
then in the NumericEdit::SetVal, I pass the ctrl Id in the wparam when the NEN_CHANGE message is sent.
Ed
|
|
|
|
|
Thank you for the nice control!
But change 2 things:
1. Remove WS_VISIBLE style from the CreateEx call.
2. Replace SetWindowPos(0,x,y,0,0,SWP_NOSIZE | SWP_NOZORDER) few lines below with SetWindowPos(&wndTop,x,y,0,0,SWP_NOACTIVATE | SWP_NOSIZE | SWP_SHOWWINDOW)
...and dialog caption will not flicker to no-activated state when popup appears.
|
|
|
|
|
Nice article and very useful. I have created a simple spinner derivation that could give the same results, while retaining much of the standard control operation.
This approach preserves the "buddy" relationship between the spin control and the edit box, and as well uses the dialog fonts mentioned by another reader. It also does not require a CWnd derived class to parent the edit and spin control.
Instead of having a separate button (CMyButton), this uses a right click on the up/down control to show the slider popup. I personally like more with less, so this works for me.
This also doesn't paint the bar below the edit control as yours does, but I would suggest overriding OnPaint() for your CMyEdit control and after calling CEdit::Paint(), simply draw a bar on the bottom two pixels of the edit control.
You can test this approach by using CMySpinEditCtrl instead of the CSpinEditCtrl for m_spnMin, m_spnMax, etc, in your demo program.
// Put this in NumericEdit.h ////////////////////////////////
class CMySpinButtonCtrl : public CSpinButtonCtrl
{
DECLARE_DYNAMIC(CMySpinButtonCtrl)
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg LRESULT OnSetPos(WPARAM /*wParam*/,LPARAM nNewValue);
};
// Put this in NumericEdit.cpp /////////////////////////////
IMPLEMENT_DYNAMIC(CMySpinButtonCtrl, CSpinButtonCtrl)
BEGIN_MESSAGE_MAP(CMySpinButtonCtrl, CSpinButtonCtrl)
ON_WM_RBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_REGISTERED_MESSAGE(NEM_SETPOS,OnSetPos)
END_MESSAGE_MAP()
void CMySpinButtonCtrl::OnRButtonDown(UINT nFlags, CPoint point)
{
CSpinButtonCtrl::OnRButtonDown(nFlags,point);
CMyTrackPopup* pTrackPopup = new CMyTrackPopup();
CRect rcRect;
GetWindowRect(rcRect); // Get button location to determine popup location
int min, max, pos;
GetRange32( min, max );
pos = GetPos32();
pTrackPopup->Create( rcRect.left + point.x,rcRect.bottom + 4, min, max, pos, this);
}
void CMySpinButtonCtrl::OnLButtonUp(UINT nFlags, CPoint point)
{
CSpinButtonCtrl::OnLButtonUp(nFlags,point);
CEdit* editPtr = (CEdit*)this->GetBuddy();
editPtr->SetSel( -1, 0 ); // Turn off the edit selection
}
afx_msg LRESULT CMySpinButtonCtrl::OnSetPos(WPARAM /*wParam*/,LPARAM nNewValue)
{
SetPos32((int)nNewValue);
return 0;
}
Cheers,
Steve
|
|
|
|
|
A newbie cannot know right click on spin button, so it's not a good design.
The original one is complex but intuitionistic.
|
|
|
|
|
Not all applications are for newbies and intuitive ( especially JASC Paint Shop Pro! ) I am still learning about all the hidden features in Visual Studio for example. Early on I learned to right click on controls to see what happens - and I'm always surprized to find a new easter egg. Good Design for a user interface is very subjective and ultimately up to the end user to decide.
Cheers,
Steve
|
|
|
|
|
I changed the color of the edit box (say RED in CtlColor ) and added a
checkbox to enable / disable display of edit box. The edit box doesn't get
repainted it says red until I move the NumericEdit dlg window around then
it gets repainted ? any idea ? what do I need to do to enfoce repaint
thanks
|
|
|
|
|
VC6 MFC and VC7 MFC are two different set of classes, and your sample bears testament to that.
Having IE6 makes no difference. SetPos32 and GetPos32 do.
William
Fortes in fide et opere!
|
|
|
|
|
hi -
This is a very useful control, but there are two minor problems with it:
1. It uses the system default font, rather than the default dialog font, hence it looks 'out of place'
2. The control is dynamically created on the dialog, rather than subclassed (or even overlaid) so the position and size are both hardcoded, which is a Bad Thing.
Neither of these are difficult to fix and I'd do them myself and submit changes, if I'd more time.
|
|
|
|
|
Did you try to change the editbox bkg color to some other color and try
to enable/disable the display of editbox? the repainting doesn't happen...would you know why?
|
|
|
|
|