【VC++开源代码栏目提醒】:网学会员--在 VC++开源代码编辑为广大网友搜集整理了:ASCII码十六进制十进制互转工具源码 - 计算机教材绩等信息,祝愿广大网友取得需要的信息,参考学习。
/ASCII码ampamp十六进制ampamp十进制互转工具源码——code by pcd / // turnDlg.cpp : implementation file // include quotstdafx.hquot include quotturn.hquot include quotturnDlg.hquot ifdef _DEBUG define new DEBUG_NEW undef THIS_FILE static char THIS_FILE __FILE__ endif define Lim 10000 //定义最大字符数 ///////////////////////////////////////////////////////////////////////////// // CAboutDlg dialog used for App About class CAboutDlg : public CDialog public: CAboutDlg // Dialog Data //AFX_DATACAboutDlg enum IDD IDD_ABOUTBOX //AFX_DATA // ClassWizard generated virtual function overrides //AFX_VIRTUALCAboutDlg protected: virtual void DoDataExchangeCDataExchange pDX // DDX/DDV support //AFX_VIRTUAL // Implementation protected: //AFX_MSGCAboutDlg //AFX_MSG DECLARE_MESSAGE_MAP CAboutDlg::CAboutDlg : CDialogCAboutDlg::IDD //AFX_DATA_INITCAboutDlg //AFX_DATA_INIT void CAboutDlg::DoDataExchangeCDataExchange pDX CDialog::DoDataExchangepDX //AFX_DATA_MAPCAboutDlg //AFX_DATA_MAP BEGIN_MESSAGE_MAPCAboutDlg CDialog //AFX_MSG_MAPCAboutDlg // No message handlers //AFX_MSG_MAP END_MESSAGE_MAP ///////////////////////////////////////////////////////////////////////////// // CTurnDlg dialog CTurnDlg::CTurnDlgCWnd pParent /NULL/ : CDialogCTurnDlg::IDD pParent //AFX_DATA_INITCTurnDlg //AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon AfxGetApp-gtLoadIconIDI_ICON1 / CHyperLink m_Link m_Link.SetURL_Tquothttp://www.csdn.netquot //指定连接 m_Link.SetUnderlineTRUE //加下划线 m_Link.SetLinkCursorAfxGetApp-gtLoadCursorIDC_HAND //改变光标为手的形状 ///加超链接
代码 void CTurnDlg::DoDataExchangeCDataExchange pDX CDialog::DoDataExchangepDX //AFX_DATA_MAPCTurnDlg DDX_ControlpDX IDC_URLMAIL m_url DDX_ControlpDX IDC_EDIT3 m_hex DDX_ControlpDX IDC_EDIT2 m_int DDX_ControlpDX IDC_EDIT1 m_char //AFX_DATA_MAP BEGIN_MESSAGE_MAPCTurnDlg CDialog //AFX_MSG_MAPCTurnDlg ON_WM_SYSCOMMAND ON_WM_PAINT ON_WM_QUERYDRAGICON ON_BN_CLICKEDIDC_BUTTON1 OnButton1 ON_BN_CLICKEDIDC_BUTTON2 OnButton2 ON_BN_CLICKEDIDC_BUTTON3 OnButton3 ON_BN_CLICKEDIDC_BUTTON5 OnButton5 ON_WM_RBUTTONDOWN ON_BN_CLICKEDIDC_URLMAIL OnUrlmail ON_WM_SETCURSOR //AFX_MSG_MAP END_MESSAGE_MAP ///////////////////////////////////////////////////////////////////////////// // CTurnDlg message handlers BOOL CTurnDlg::OnInitDialog CDialog::OnInitDialog // Add quotAbout...quot menu item to system menu. // IDM_ABOUTBOX must be in the system command range. ASSERTIDM_ABOUTBOX amp 0xFFF0 IDM_ABOUTBOX ASSERTIDM_ABOUTBOX lt 0xF000 CMenu pSysMenu GetSystemMenuFALSE if pSysMenu NULL CString strAboutMenu strAboutMenu.LoadStringIDS_ABOUTBOX if strAboutMenu.IsEmpty pSysMenu-gtAppendMenuMF_SEPARATOR pSysMenu-gtAppendMenuMF_STRING IDM_ABOUTBOX strAboutMenu // Set the icon for this dialog. The framework does this automatically // when the applications main window is not a dialog SetIconm_hIcon TRUE // Set big icon SetIconm_hIcon FALSE // Set small icon // TODO: Add extra initialization here // GetDlgItemIDC_BUTTON4-gtGetWindowRectampm_pRectLink //将静态文本的屏幕坐标存放在m—pRectLink中 // ScreenToClientampm_pRectLink //将屏幕坐标转换为客户坐标 return TRUE // return TRUE unless you set the focus to a control void CTurnDlg::OnSysCommandUINT nID LPARAM lParam if nID amp 0xFFF0 IDM_ABOUTBOX CAboutDlg dlgAbout dlgAbout.DoModal else CDialog::OnSysCommandnID lParam // If you add a minimize button to your dialog you will need the code below // to draw the icon. For MFC applications using the document/view model // this is automatically done for you by the framework. void CTurnDlg::OnPaint if IsIconic CPaintDC dcthis // device context for painting SendMessageWM_ICONERASEBKGND WPARAM dc.GetSafeHdc 0 // Center icon in client rectangle int cxIcon GetSystemMetricsSM_CXICON int cyIcon GetSystemMetricsSM_CYICON CRect rect GetClientRectamprect int x rect.Width - cxIcon 1 / 2 int y rect.Height - cyIcon 1 / 2 // Draw the icon dc.DrawIconx y m_hIcon else CDialog::OnPaint // The system calls this to obtain the cursor to display while the user drags // the minimized window. HCURSOR CTurnDlg::OnQueryDragIcon return HCURSOR m_hIcon void CTurnDlg::OnOK // TODO: Add extra validation here //CDialog::OnOK void CTurnDlg::OnButton1 //消息转换十进制及十六进制 // TODO: Add your control notification handler code here char ch1Lim CString str1Limsumstr1str2Limsumstr2 int ini_t1Lim GetDlgItemTextIDC_EDIT1ch1Lim // strncpych1LPCTSTRstrsizeofch1 //CString 类型转换成char n strlench1 if n0 MessageBoxquot请输入数据!quot if ch100 sumstr10 sumstr20 else sumstr1quotcharquot sumstr2quot0xquot fori0iltni i_t1i intch1i ifi1ltn str1i.Formatquotdquoti_t1i else str1i.Formatquotdquoti_t1i str2i.Formatquotxquoti_t1i sumstr1str1i sumstr2str2i SetDlgItemTextIDC_EDIT2sumstr1 SetDlgItemTextIDC_EDIT3sumstr2 void CTurnDlg::OnButton2 // TODO: Add your control notification handler code here CString strLimhexLimstrsumhexsum char tenLim2chLim int i_ten1mnj0 GetDlgItemTextIDC_EDIT2chLim m 0 n strlench if nlt1 hexsum 0 MessageBoxquot请输入数据!quot else hexsum quot0xquot forint i0iltni//这里的转换有点小问题 负数的转换 待修正.. ifchigt0ampampchilt9 tenmjchi j ifchi;chi,chichi i1n//j2 i1nampampchiampampchi /又遇到个问题 这里的语句 导致转16进制多出个0 原来是n 的值 多了一位..成功解决/ /还是这里的
问题 输入一个数 不加符号什么的 就没有返回 而输入多个数就少返回一组..在J的值上的限制所导致/ i_ten1 atoitenm hexm.Formatquotxquoti_ten1 strm.Formatquotcquoti_ten1 strsumstrm hexsumhexm m j0 else continue SetDlgItemTextIDC_EDIT1strsum SetDlgItemTextIDC_EDIT3hexsum void CTurnDlg::OnButton3 // TODO: Add your control notification handler code here UpdateData char chLimch12 CString int1Limcha1Limcharsumintsum int temp2temp1Limnj0m0 m_hex.GetWindowTextchLim nstrlench ifn0 MessageBoxquot请输入数据!quot intsum quotcharquot ifch00ampampch1x forint i2iltnii2 ch10chi ch11chi1 forj0jlt2j ifch1jlt9ampampch1jgt0 tempj ch1j-0 else ifch1jltzampampch1jgta tempj ch1j-a10 else ifch1jltZampampch1jgtA tempj ch1j-A10 temp1mtemp016temp1//temp1的字符串相加 ifi2gtn int1m.Formatquotdquottemp1m else int1m.Formatquotdquottemp1m cha1m.Formatquotcquottemp1m charsumcha1m intsumint1m m else //FALSE tempatoitempch16 forint i0iltnii2 ch10chi ch11chi1 forj0jlt2j ifch1jlt9ampampch1jgt0 tempj ch1j-0 else ifch1jltzampampch1jgta tempj ch1j-a10 else ifch1jltZampampch1jgtA tempj ch1j-A10 temp1mtemp016temp1//temp1的字符串相加 ifi2gtn int1m.Formatquotdquottemp1m else int1m.Formatquotdquottemp1m cha1m.Formatquotcquottemp1m charsumcha1m intsumint1m m intsum ifch00 m_int.SetWindowTextintsum else m_int.SetWindowText0 m_char.SetWindowTextcharsum UpdateDataFALSE void CTurnDlg::OnButton5 // TODO: Add your control notification handler code here SetDlgItemTextIDC_EDIT10 SetDlgItemTextIDC_EDIT20 SetDlgItemTextIDC_EDIT30 void CTurnDlg::OnRButtonDownUINT nFlags CPoint point // TODO: Add your message handler code here and/or call default CAboutDlg about about.DoModal CDialog::OnRButtonDownnFlags point void CTurnDlg::OnUrlmail // TODO: Add your control notification handler code here HINSTANCE resultShellExecuteNULL_Tquotopenquotquotmailto:p_zuizuihotmail.comquotNULLNULLSW_SHOW / BOOL CWnd::OnSetCursorCWnd pWnd UINT nHitTest UINT message BOOL bCursorChanged NULL ifGetDlgItemIDC_URLMAIL pWnd bCursorChanged TRUE ifbCursorChanged ::SetCursor::LoadCursorNULL IDC_WAIT return TRUE else return CWnd::OnSetCursorpWnd nHitTest message / //DEL void CTurnDlg::OnMouseMoveUINT nFlags CPoint point //DEL //DEL // TODO: Add your message handler code here and/or call default //DEL Cstatic pWnd //DEL ifGetDlgItemIDC_URLMAIL pWnd //DEL m_url.SetCursor::LoadCursorNULLIDC_UPARROW //DEL CDialog::OnMouseMovenFlags point //DEL //DEL void CTurnDlg::OnMouseMoveUINT nFlags CPoint point //DEL //DEL // TODO: Add your message handler code here and/or call default //DEL / CFont font //DEL font.CreateFont //DEL 12 // nHeight //DEL 0 // nWidth //DEL 0 // nEscapement //DEL 0 // nOrientation //DEL FW_NORMAL // nWeight //DEL FALSE // bItalic //DEL TRUE // bUnderline //DEL 0 // cStrikeOut //DEL ANSI_CHARSET // nCharSet //DEL OUT_DEFAULT_PRECIS // nOutPrecision //DEL CLIP_DEFAULT_PRECIS // nClipPrecision //DEL DEFAULT_QUALITY // nQuality //DEL DEFAULT_PITCH FF_SWISS // nPitchAndFamily //DEL quot宋体quot //DEL //DEL //下面设置鼠标在静态文本区时,将光标设成小手状 //DEL //DEL //DEL //DEL //DEL ifpoint.xgtm_pRectLink.leftampamppoint.xltm_pRectLink.rightampamppoint.ygtm_pRectLink.topampamppoint.yltm_pRectLink.bottom //DEL //此处添加判断坐标算法 这里的算法有问题 point 貌似不能获取在静态文本处的坐标 换成button 依然不行... //DEL //DEL //DEL HCURSOR hCursor //DEL hCursorAfxGetApp-gtLoadCursorIDC_HAND //DEL //将鼠标设为小手状 //DEL SetCursorhCursor //DEL // m_url.SetFontampfont //DEL //DEL font.DeleteObject //DEL / //DEL CDialog::OnMouseMovenFlags point //DEL //DEL BOOL CTurnDlg::OnSetCursorCWnd pWnd UINT nHitTest UINT message //DEL //DEL // TODO: Add your message handler code here and/or call default //DEL CFont font //DEL font.CreateFont //DEL 12 // nHeight //DEL 0 // nWidth //DEL 0 // nEscapement //DEL 0 // nOrientation //DEL FW_NORMAL // nWeight //DEL FALSE // bItalic //DEL TRUE // bUnderline //DEL 0 // cStrikeOut //DEL ANSI_CHARSET // nCharSet //DEL OUT_DEFAULT_PRECIS // nOutPrecision //DEL CLIP_DEFAULT_PRECIS // nClipPrecision //DEL DEFAULT_QUALITY // nQuality //DEL DEFAULT_PITCH FF_SWISS // nPitchAndFamily //DEL quot宋体quot //DEL /switchpWnd-gtGetDlgCtrlID //DEL //DEL case IDC_URLMAIL: //静态控件的ID / //DEL SetCursorAfxGetApp-gtLoadCursorIDC_HAND //DEL //AfxGetApp pointer to the single CWinApp object for the application. //DEL m_url.SetFontampfont //DEL // //DEL font.DeleteObject //DEL return CDialog::OnSetCursorpWnd nHitTest message //DEL //还有一个方法是获取屏幕坐标 但实在不知道怎么实现 BOOL CTurnDlg::OnSetCursorCWnd pWnd UINT nHitTest UINT message //原来是WM响应.害我找半天 // TODO: Add your message handler code here and/or call default. //HCURSOR CFont fontfont1 font.CreateFont 12 // nHeight 0 // nWidth 0 // nEscapement 0 // nOrientation FW_NORMAL // nWeight FALSE // bItalic TRUE // bUnderline 0 // cStrikeOut ANSI_CHARSET // nCharSet OUT_DEFAULT_PRECIS // nOutPrecision CLIP_DEFAULT_PRECIS // nClipPrecision DEFAULT_QUALITY // nQuality DEFAULT_PITCH FF_SWISS // nPitchAndFamily quot宋体quot font1.CreateFont 12 // nHeight 0 // nWidth 0 // nEscapement 0 // nOrientation FW_NORMAL // nWeight FALSE // bItalic FALSE // bUnderline 0 // cStrikeOut ANSI_CHARSET // nCharSet OUT_DEFAULT_PRECIS // nOutPrecision CLIP_DEFAULT_PRECIS // nClipPrecision DEFAULT_QUALITY // nQuality DEFAULT_PITCH FF_SWISS // nPitchAndFamily quot宋体quot ifpWnd GetDlgItemIDC_URLMAIL//获取控件指针 ::SetCursor::LoadCursor::AfxGetInstanceHandleMAKEINTRESOURCEIDC_HAND // IDC_HAND为准备好的光标 为什么不显示?? m_url.SetFontampfont font.DeleteObject return TRUE else m_url.SetFontampfont1 font1.DeleteObject //ShowCursorFALSE隐藏cursor return CDialog::OnSetCursorpWnd nHitTest message // turn.cpp : Defines the class behaviors for the application. // include quotstdafx.hquot include quotturn.hquot include quotturnDlg.hquot ifdef _DEBUG define new DEBUG_NEW undef THIS_FILE static char THIS_FILE __FILE__ endif ///////////////////////////////////////////////////////////////////////////// // CTurnApp BEGIN_MESSAGE_MAPCTurnApp CWinApp //AFX_MSG_MAPCTurnApp // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code //AFX_MSG ON_COMMANDID_HELP CWinApp::OnHelp END_MESSAGE_MAP ///////////////////////////////////////////////////////////////////////////// // CTurnApp construction CTurnApp::CTurnApp // TODO: add construction code here // Place all significant initialization in InitInstance ///////////////////////////////////////////////////////////////////////////// // The one and only CTurnApp object CTurnApp theApp ///////////////////////////////////////////////////////////////////////////// // CTurnApp initialization BOOL CTurnApp::InitInstance AfxEnableControlContainer // Standard initialization // If you are not using these features and wish to reduce the size // of your final.