Why don't exec MessageBox(L"1\nDIVIDE BY ZERO");
durban2
Posts
-
_controlfp() - function -
_controlfp() - functionMFC, STUDIO'2008, WINDOWS'XP 2003 #include <float.h> _controlfp(_DN_FLUSH, _MCW_DN); // : error C3861: '__controlfp': identifier not found // Denormal values flushed to zero by hardware on ALPHA and x86 // processors with SSE2 support. Ignored on other x86 platforms. below some variants: //+-1 _controlfp(0, MCW_EM); <float.h> // below following line is incorrect - don't display MessageBox(L"1\nDIVIDE BY ZERO"); _controlfp(_DN_FLUSH, _MCW_DN); _controlfp(0, _MCW_DN); _controlfp(_DN_SAVE, _MCW_DN); _controlfp(0, _MCW_DN); int err; double fResult; // Bennet, pg.136 double x,y; x = 5.0; y = 0.0; _try { fResult = x/y; // _control87_2(0, 0,&fResult, 0); //- _controlfp(0, 0,&fResult, 0); // : error C2660: '_controlfp' : function does not take 4 arguments //- _controlfp(&fResult, 0); // : error C2664: '_controlfp' : cannot convert parameter 1 from 'float *' to 'unsigned int' } _except (GetExceptionCode() == EXCEPTION_FLT_DIVIDE_BY_ZERO) { MessageBox(L"1\nDIVIDE BY ZERO"); MessageBox(_T("2\nDIVIDE BY ZERO")); AfxMessageBox(_T("3\nDIVIDE BY ZERO")); }
-
_exceptWhy don't execution function MessageBox(L"DIVIDE BY ZERO"); ? The code is skipping. #include "Excpt.h" #include "Winnt.h" #include "cmath" float fResult; // Bennet, pg.136 //int x,y; float x,y; // x = 5; // y = 0; x = 5.0; y = 0.0; _try // __try { fResult = x/y; } //__except (GetExceptionCode() == EXCEPTION_FLT_DIVIDE_BY_ZERO) _except (GetExceptionCode() == EXCEPTION_FLT_DIVIDE_BY_ZERO) { MessageBox(L"DIVIDE BY ZERO"); }
-
alignment of modelessMFC, STUDIO 2008 Help me, please alignment dialog window after it appear on screen to right side of screen. Thank you.
-
Control CStatic, Height of FONTMFC, STUDIO 2008 How to increase height of text CStatic* pStatic = (CStatic*) GetDlgItem(IDC_STATIC2); CFont font; font.CreateFont(640, // 320 - same 0, // int nWidth, 0, 0, 400, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_ROMAN, L"Times New Roman"); // Do something with the font just created... pStatic->SetFont(font,1); pStatic->SetWindowTextW(L"Any text");
-
functionMFC, STUDIO 2008 Created in class with help wizard function my_func1 which must return variable CStrimg CString CMainDlg2::my_func1(void) { return CString(); } But I want for example: CString CMainDlg2::my_func1(void) { CString s; s = ”test”; // is necessary return s; // return CString(); How to use value of variable ‘s’ from my_func1? }
-
parserStuart Dootson, OK ! THANK You Very much!
-
parserThe variable m_sDate2 of class CString contains 14.06.1955 How to set value variables int year, month, day; CString s; ? Have been show below attempts was failure: //+ MessageBox(L"61.\nm_sDate2 = " + m_sDate2); // _tscanf((LPCTSTR)m_sDate2, "%d.%d.%d", &day, &month, &year); //1.++- s.Format(L"62.\nday = %d\n,month = %d\n,year = %d\nm_sDate2 = %s", &day, &month, &year,m_sDate2); day = 1234628 ,month = 1234640 ,year = 1234652 m_sDate2 = 27.03.1965 //2++- s.Format(L"62a.\nday = %d\n,month = %d\n,year = %d\nm_sDate2 = %s", day, month, year,m_sDate2); // 62a. day = -858993460 ,month = -858993460 ,year = -858993460 m_sDate2 = 27.03.1965 //3++- _tscanf((LPCTSTR)m_sDate2, "%d.%d.%d", day, month, year); // 62b s.Format(L"62b.\nday = %d\n,month = %d\n,year = %d\nm_sDate2 = %s", day, month, year,m_sDate2); //4++- _tscanf((LPCTSTR)m_sDate2, L"%d.%d.%d", day, month, year); //5++- wscanf(m_sDate2, L"%d.%d.%d", day, month, year); // пусто //6++- wscanf(m_sDate2, "%d.%d.%d", day, month, year); // пусто //-7 scanf(m_sDate2, "%d.%d.%d", day, month, year); //-8 scanf((LPCTSTR)m_sDate2, "%d.%d.%d", day, month, year); //-9 scanf((LPCTSTR)m_sDate2, "%d.%d.%d", &day, &month, &year); //-10 scanf(m_sDate2, "%d.%d.%d", &day, &month, &year); //- swscanf((LPCTSTR)m_sDate2, "%d.%d.%d", day, month, year); //- swscanf((LPCTSTR)m_sDate2, "%d.%d.%d", day, month, year); //- swscanf((LPCTSTR)m_sDate2, "%d", &day); //- swscanf(m_sDate2, "%d", &day); _tscanf((LPCTSTR)m_sDate2, "%2d.%2d.%4d", &day, &month, &year); s.Format(L"\nday = %d\n,month = %d\n,year = %d\nm_sDate2 = %s", &day, &month, &year,m_sDate2); MessageBox(s);
-
parameter of functionmy function f_my() receive identifier of control, for example IDC_DATETIMEPICKER1 How do set type of argument? And how this function to call for execution? As show - unproperly: error C2660: 'GetDlgItem' : function does not take 1 arguments void CADO_MDIApp:: f_my (long identifier) { COleDateTime* p1 = (COleDateTime*) GetDlgItem(identifier); }
-
PointersThere are two pointers, both points on controls of type IDC_DATETIMEPICKER. COleDateTime* pIN = (COleDateTime*) GetDlgItem(IDC_DATETIMEPICKER1); The second control is on another dialog window COleDateTime* pDest = (COleDateTime*) (m_pParent->GetDlgItem(IDC_DATETIMEPICKER1)); The first pointer to point date ’27.05.1953’ How do with help the second pointer receive date ’27.05.1953’ ? Thank you.
-
DATETIMEPICKERThere is control on the dialog window DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER1, m_date); COleDateTime m_date; CString m_sBD; m_sBD have format ‘dd.mm.yyyy’ for example m_sBD = L”19.05.1849”; How do show date into control that identifier is IDC_DATETIMEPICKER1?
-
two dialog window and variableInto event NM_CLICK Of modal dialog window chose row into control CListCtrl int row; For example row = 6; Modeless window is opened. In event WM_LBUTTONDOWN ( on surface of modeless) set: CMainDlg2 dlgModal; // modal m_sWorkModeless.Format(L"row = %d",dlgModal.row); MessageBox(m_sWorkModeless); Result: row = 0 , but must be = 6 How to receive 6?
-
modal, modeless and variableThere are two classe of dialog windows: class CMainDlg2 : public Cdialog // modal CString m_sADDRESSHOM; class CAdderDialog2 : public CDialog // MODELESS #include "adderdlg2.h" #include "modeldlg2.h" There are in the code attached to command button OK set: m_pModeless7 = new CAdderDialog2(this); if (m_pModeless7->Create() == TRUE) { m_sADDRESSHOM = "London"; } View the fragment of code modeless window: BOOL CAdderDialog2::OnInitDialog() { CDialog::OnInitDialog(); CMainDlg2 dlg7; MessageBox(L"dlg7.m_sADDRESSHOM=\n" + dlg7.m_sADDRESSHOM); // display empty - the contents from constructor of modal dialog window } How to receive "London" ?
-
extern variableMFC, STUDIO 2008, MDI There are into project some global variable created same method Last ‘m_gsADDRESSHOM’ can’t to create. extern CString m_gsADDRESSHOM; // set into file stdafx.h // modeldlg2.cpp : implementation file #include "stdafx.h" #include "modeldlg2.h" CString m_gsADDRESSHOM; // CMainDlg2 dialog Using global variable pEdit_ADDRESS->SetWindowTextW(dlg7.m_gsADDRESSHOM); // error C2039: 'm_gsADDRESSHOM' : is not a member of 'CMainDlg2'
-
constructor and OnInitDialog()MFC, STUDIO 2008, MDI Why ignore ( skip ) value from OnInitDialog() There are modal and modeless windows: // modeldlg2.h class CMainDlg2 : public CDialog // modal window { public: virtual BOOL OnInitDialog(); CString m_sPP_modal7; }; // adderdlg2.h class CAdderDialog2 : public Cdialog // modeless window { public: virtual BOOL OnInitDialog(); }; // modeldlg2.cpp : implementation file CMainDlg2::CMainDlg2(CWnd* pParent /*=NULL*/) // standard constructor : CDialog(CMainDlg2::IDD, pParent) m_sPP_modal7 = "Paris"; } BOOL CMainDlg2::OnInitDialog() { CDialog::OnInitDialog(); m_sPP_modal7 = "New-York"; return TRUE; // return TRUE unless you set the focus to a control } // adderdlg2.cpp : implementation file MODELESS window BOOL CAdderDialog2::OnInitDialog() { CDialog::OnInitDialog(); CMainDlg2 dlg7; MessageBox(L"dlg7.m_sPP_modal7 = \n" + dlg7.m_sPP_modal7); Why have been chose value from constructor but not from the method OnInitDialog() modal window? } Result: Paris Why not New-York ? How to receive New-York ?
-
Font text on command buttonMFC, STUDIO 2008, MDI CButton m_button1; CString font(L"Courier New"); m_button1.SetFont(font,20); // error C2664: 'CWnd::SetFont' : cannot convert parameter 1 from 'const wchar_t [12]' to 'CFont *' m_button1.SetFont(L"Courier New",20); // error C2664: 'CWnd::SetFont' : cannot convert parameter 1 from 'const wchar_t [12]' to 'CFont *' 2. // How do to set BOLD FONT on button? m_button1.SetFont(L"Courier New",20,600); // error C2660: 'CWnd::SetFont' : function does not take 3 arguments Add #include "afxctl.h" class CFontHolder; // add into header file my class where is command button that I want write caption.
-
variable and class ViewMFC, STUDIO 2008, MDI-project Christ has arisen! There are 2 classes: class CADO_MDIView : public CscrollView class CAdodc_MDI : public Cdialog В class CADO_MDIView имеем CString m_s5(“YYYYYYYYYYY”); MessageBox(m_s); // ADO_MDIView.cpp : implementation of the CADO_MDIView class #include "stdafx.h" #include "ADO_MDI.h" #include "ADO_MDIDoc.h" #include "CntrItem.h" #include "ADO_MDIView.h" #include "Adodc_MDI.h" // Adodc_MDI.cpp : implementation file #include "stdafx.h" #include "ADO_MDI.h" //-1 #include "ADO_MDIView.h" #include "Adodc_MDI.h" //-3 #include "ADO_MDIView.h" CADO_MDIView dlg_View; // adodc_mdi.cpp(211) dlg_View.m_s5; -------------------------------------- ado_mdiview.h(23) : error C2143: syntax error : missing ';' before '*' ado_mdiview.h(23) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int ado_mdiview.h(23) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int ado_mdiview.h(23) : warning C4183: 'GetDocument': missing return type; assumed to be a member function returning 'int' adodc_mdi.cpp(211) : error C2248: 'CADO_MDIView::CADO_MDIView' : cannot access protected member declared in class 'CADO_MDIView' ado_mdi\ado_mdiview.h(18) : see declaration of 'CADO_MDIView::CADO_MDIView' ado_mdi\ado_mdiview.h(15) : see declaration of 'CADO_MDIView' -------------------------------------- // Attributes public: CADO_MDIDoc* GetDocument() const; // ado_mdiview.h(23) -------------------------------------- class CADO_MDIView : public CScrollView { protected: // create from serialization only CADO_MDIView(); // ado_mdi\ado_mdiview.h(18)
-
create control of class CEditMFC, STUDIO 2008, MDI-project void CPage1::OnBnClickedButton1() { CRect rect(85, 110, 180, 210); CEdit m_edit; // Embedded edit object m_edit.Create(WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_AUTOHSCROLL | WS_BORDER, rect, this, ID_EXTRA_EDIT); // error C2065: 'ID_EXTRA_EDIT' : undeclared identifier m_edit.SetFocus(); }
-
identifier of dialog window and the name of the classMFC, STUDIO 2008, MDI-project if J know the name of class then how can to define the identifier of dialog wndow on base that was created this class?
-
increase the code of symbolsHow to convert string “ABC” to “BCD” into UNICODE? CString strSource; strSource = L"ABC"; TCHAR SourceFile[100]; _tcscpy(SourceFile, strSource ); MessageBox(SourceFile); // display "ABC" - OK! below 3 operators are unproperly ! SourceFile[0] ++; SourceFile[1] ++; SourceFile[2] ++; MessageBox(SourceFile); // display ">BC"