easyx 简单的inputbox制作

先上图片:

由于visual studio2008经常因为TCHAR和char的转换问题,所以这次干脆在vc6的环境下制作了。代码如下:(vc2008可能编译不通过)

// inputbox.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

char s[1000];
char tmp;
int i=0;
int row=0;

int main(int argc, char* argv[]){
	initgraph(250,20);
	setbkcolor(WHITE);
	setcolor(BLACK);
	cleardevice();
	for(;;){
		tmp=_getch();
		if(tmp==8){
			if(i==0)goto end;
			--i;s[i]='\0';
		}
		else{
			s[i]=tmp;++i;s[i]='\0';
		}
		cleardevice();
end:
		outtextxy(0,0,s);
	}
	closegraph();
	return 0;
}

stdafx.h的内容如下:(大部分是注释)

// stdafx.h : include file for standard system include files,
//  or project specific include files that are used frequently, but
//      are changed infrequently
//

#if !defined(AFX_STDAFX_H__89DA211D_4E1E_4B54_A06F_5887A7B3D040__INCLUDED_)
#define AFX_STDAFX_H__89DA211D_4E1E_4B54_A06F_5887A7B3D040__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers

#include <stdio.h>

// TODO: reference additional headers your program requires here

#include<graphics.h>
#include<iostream>
#include<string.h>
#include<conio.h>

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_STDAFX_H__89DA211D_4E1E_4B54_A06F_5887A7B3D040__INCLUDED_)

posted @ 2021-09-28 16:32  计算机知识杂谈  阅读(1562)  评论(0编辑  收藏  举报