I’m creating a preferences form in VC++ MFC, and I have several textfields that only accept integers. I’m new to MFC, so this is how I found to initialize them in some tutorial:
CProgramDlg::CProgramDlg(CWnd* pParent /*=NULL*/)
: CDialog(CProgramDlg::IDD, pParent)
, m_nSampleValue1()
, m_nSampleValue2() ... m_nSampleValueN {}
This is grand and all, but when I run it, all of the textboxes are filled with zeros. I know with strings that you can just send it “” and it will clear the textbox, but I tried NULL for my ints and did not have any luck.
Is there a trick to getting the textboxes to just be empty without showing zeros? Thank you for your help!
m_nSampleValue1()andm_nSampleValue2()are value-initialized. If its primitive types, then that means they will be zero-initialized.If its integral type, then I think that isn’t possible without changing other part of the code (which part? you’ve not posted it here). If you don’t want to do that, or if that is hard to do, then you can change the type of the members to string, then they will be empty strings automatically.
However, if you want to see non-zero values, then do this: