giaiptb1

#define IDR_MENU1                       101
#define IDI_ICON1                       102
#define IDD_DIALOG1                     103
#define IDC_EDIT1                       1000
#define IDC_EDIT2                       1001
#define IDC_EDIT3                       1002
#define IDC_BUTTON2                     1004
#define IDC_EDIT4                       1006
#define IDC_BUTTON3                     1007
#define IDM_Thoat                       40001


IDR_MENU1 MENU DISCARDABLE
BEGIN
    POPUP "Menu"
    BEGIN
        MENUITEM "Thoat\tAlt+X",                IDM_Thoat
    END
END

IDD_DIALOG1 DIALOG DISCARDABLE  0, 0, 381, 156
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Dialog"
FONT 8, "MS Sans Serif"
BEGIN
    LTEXT           "A",IDC_STATIC,17,34,46,8
    LTEXT           "B",IDC_STATIC,18,56,34,8
    EDITTEXT        IDC_EDIT1,68,32,184,14,ES_AUTOHSCROLL
    EDITTEXT        IDC_EDIT2,68,54,182,14,ES_AUTOHSCROLL
    PUSHBUTTON      "Giai",IDC_BUTTON2,270,43,89,14
    EDITTEXT        IDC_EDIT4,20,89,342,14,ES_AUTOHSCROLL
    PUSHBUTTON      "Ok",IDC_BUTTON3,141,119,50,14
END

#include<afxwin.h>
#include "resource.h"
#include <math.h>
class CMyApp:public CWinApp
{
public:
    BOOL InitInstance();

};



//buoc 1




class CMyDialog: public CDialog
{
public:
    CMyDialog(UINT ID, CWnd *owner = NULL) : CDialog(ID,owner){}
    BOOL OnInitDialog();
    afx_msg void OnGiaiPT();
    DECLARE_MESSAGE_MAP();
};

CMyApp theApp;
BEGIN_MESSAGE_MAP(CMyDialog,CDialog)
ON_COMMAND(IDC_BUTTON2, OnGiaiPT)
END_MESSAGE_MAP()

BOOL CMyApp::InitInstance()
{
    m_pMainWnd = new CMyDialog(IDD_DIALOG1, NULL);
    int kq = ((CMyDialog *)m_pMainWnd)->DoModal();
    return TRUE;
}

BOOL CMyDialog::OnInitDialog()
{
    return TRUE;
}

void CMyDialog::OnGiaiPT()
{
    double a,b;
    char s[150];
    CEdit *ed;
    ed = (CEdit*)GetDlgItem(IDC_EDIT1);
    ed->GetWindowText(s, 20);
    a = atof(s);

    ed = (CEdit*)GetDlgItem(IDC_EDIT2);
    ed->GetWindowText(s, 20);
    b = atof(s);
   
    ed = (CEdit*)GetDlgItem(IDC_EDIT4);
    ed->GetWindowText(s, 20);

   


    if(a==0)
    {
        if(b!=0)
            sprintf(s, "Phuong trinh vo nghiem");
        else
            sprintf(s, "Phuong trinh co vo so nghiem");
    }
    else
        sprintf(s, "Phuong trinh co nghiem duy nhat: %2lf", -b/a);
   
    ed->SetWindowText(s);

}



Bạn đang đọc truyện trên: AzTruyen.Top

Tags: