CFont global variable.
CFont font;
CreatePointFont() to create a
font. The size of the font is measured in one tenths.
font.CreatePointFont(100,"Courier New");
SetFont() function.
editBoxControl.SetFont(&font);
OnOK() and OnCancel() functions in your dialog class.
class CInventoryStoreDlg : public CDialog
{
// Construction
public:
CInventoryStoreDlg(CWnd* pParent = NULL); // standard constructor
void OnOK() {}
void OnCancel() {}
...
...
};
void CInventoryStoreDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
if ((nID & 0xFFF0) == SC_CLOSE)
{
exit(1); // or another method to close dialog.
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
char * to int.
// function to convert char * to int
int returnInt( char i[] )
{
int integer;
integer = atoi(i); // must include cstdlib (stdlib.h)
return integer;
}
char * to double.
// function to convert char * to double
double returnDouble(char i[])
{
double floaty;
floaty = atof(i); // must include cstdlib (stdlib.h)
return floaty;
}
int to CString.
// function to convert int to CString
CString returnCString( int i )
{
CString s;
s.Format( ("%-15d"), i );
return s;
}
double to CString.
// function to convert double to CString
CString returnCString( double i )
{
CString s;
s.Format( ("%-14.2f"), i );
return s;
}