原码反码补码图形化注意

1.先在黑窗口写编写一个能实现需求的代码(当然你也可以直接去MFC里去写)。

2.将编写好的程序头文件加到MFCtoolDlg.cpp文件的前边

像这样:

#include "stdafx.h"
#include "MFCtool.h"
#include "MFCtoolDlg.h"
#include "afxdialogex.h"
#include <stdio.h>
#include <stdlib.h>


#ifdef _DEBUG
#define new DEBUG_NEW
#endif

3.在MFS的头文件stdafx.h中加入取消安全机制(注意:加在了第二行,而不是第一行)

#pragma once
#define  _CRT_SECURE_NO_WARNINGS
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN            // 从 Windows 头中排除极少使用的资料
#endif

4.将编写的函数除了主函数外都放到MFCtoolDlg.cpp中,紧挨着头文件放就行。

5.移植主函数到   void CMFCtoolDlg::OnBnClickedButton1() 中,也就是最后面的那个函数。

void CMFCtoolDlg::OnBnClickedButton1()
{
    // TODO:  在此添加控件通知处理程序代码


    //char str[100] = { 0 };
    //int num=10;
    //sprintf(str, "%d", num);//整数转化为字符串

    //char getstr[100] = { 0 };
    //CStringA  getstrX;//C++的字符串
    //m_edit1.GetWindowTextA(getstrX);
    ////CStringA  char*类型转换
    ////sscanf("%d")
//m_edit1.SetWindowTextA(str);  m_edit1是在窗口中EditContrl按钮中添加的变量名。
//m_edit1.SetWindowTextW(L"ABC");


    int  num=0;
    //scanf("%d", &num);
    CStringA  str;
    m_edit1.GetWindowTextA(str);
    sscanf(str, "%d", &num);//扫描出来

    char stry[33] = { 0 };
    char strf[33] = { 0 };
    char strb[33] = { 0 };
    
    ycode(num, stry);
    m_edit2.SetWindowTextA(stry);
    fcode(num, strf);
    m_edit3.SetWindowTextA(strf);
    bcode(num, strb);
    m_edit4.SetWindowTextA(strb);
}

 4.一定要注意在Button按钮中添加事件处理程序。

posted @ 2016-06-12 06:57  芬乐  阅读(255)  评论(0编辑  收藏  举报