資源簡介
點擊圖片的任意一點獲得坐標,并在窗口中將所點擊的點的坐標顯示出來
-Click the picture to obtain the coordinates of any point and click in the window by the coordinates of the points displayed

代碼片段和文件信息
#include?“stdafx.h“
#include?“ByteFile.h“
ByteFile::ByteFile(){
InternetFile=0;
length=0;
bits=NULL;
}
ByteFile::~ByteFile(){
free(bits);
}
bool?ByteFile::getbytes(long?poslong?lengthchar?*?buf)
{
for(int?i=0;i *(buf+i)=*(bits+pos+i);
}
return?true;
}
bool?ByteFile::getcolor(long?poschar?*color){
for(int?i=0;i<3;i++){
*(color+i)=*(bits+pos+i);
}
return?true;
}
short?int?ByteFile::getshort(long?pos){
unsigned?short?*?temp;
temp=(unsigned?short?*)(bits+pos);
return?*temp;
}
int?ByteFile::getint(long?pos){
unsigned?int?*?temp;
temp=(unsigned?int?*)(bits+pos);
return?*temp;
}
int?ByteFile::getstring(long?poschar?*out){
int?index=0;
unsigned?char*buff;
buff=bits+pos;
while(*(buff+index)?!=?0){
*(out+index)=*(buff+index);
index++;
}
*(out+index)=*(buff+index);
buff=NULL;
return?index+1;//包含結束符
}
bool?ByteFile::setPathName(char?*?dirnamechar?*filename){
if?(strstr(dirname?“http://“)) //?如果路徑包含?http://?則...
{
InternetFile=1;
strcpy(dirName?dirname);
strcpy(fileName?filename);
}
else?if?(strstr(dirname?“:“)) //?如果路徑包含:
{
InternetFile=0;
strcpy(dirName?dirname);
strcpy(fileName?filename);
}
else?
{
InternetFile=0;
GetCurrentDirectory(MAX_PATHNAMEdirName);
strcpy(fileName?filename);
}
return?true;
}
bool?ByteFile::setLocation(POINT?point){
location.x=point.x;
location.y=point.y;
return?true;
}
bool?ByteFile::loadFile(){
char?path[255];
strcpy(path?dirName);
strcat(path?“\\“);
strcat(path?fileName);
if(InternetFile==0){
FILE?*fp;
fp=fopen(path“rb“);
if(fp==NULL)?return?false;?
length=0;
unsigned?char*?pBuff=?new?unsigned?char[1000000];
length=fread(pBuff1999999fp);
fclose(fp);
bits=new?unsigned?char[length+1];//一定要加一,否則無法存結束符
unsigned?char?*?src;
src=pBuff;
unsigned?char?*?dest;
dest=bits;
for(long?i=0;i *dest=*src;
dest++;
src++;
}
dest=NULL;
src=NULL;
free(pBuff);
}
else?if(InternetFile==1){
HINTERNET?hSession=InternetOpen(“Microsoft?Internet?Explorer“INTERNET_OPEN_TYPE_DIRECTNULLNULL0);
HINTERNET?handle2?=?InternetOpenUrl(hSessionpathNULL0INTERNET_FLAG_RAW_DATA?0);
char?Buffer[36];?//?數據緩沖區
DWORD?BufLen=32;
DWORD?dwIndex=0;
HttpQueryInfo(handle2HTTP_QUERY_CONTENT_LENGTHBuffer?&BufLen&dwIndex);
length=atol(Buffer);
bits=new?unsigned?char[length+1];
unsigned?long?Number;
InternetReadFile(handle2bitslength?&Number);
InternetCloseHandle(handle2);
handle2?=?NULL;
InternetCloseHandle(hSession);
hSession?=?NULL;
}
else?return?false;
return?true;
}
/*void?main()
{
ByteFile?buf;
buf.setPathName(“d:\\test“);
buf.loadFile();
short?int?ID1;
int?ID2;
short?int?ID3;
int?pos=0;
ID1=buf.getshort(pos);
pos+=sizeof(ID1);
ID2=buf.getint(pos);
pos+=sizeof(ID2);
ID3=buf.getshort(6);
pos+=sizeof(ID3);
int?lengt
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????3203??2007-07-06?12:23??MyGetRGB\ByteFile.cpp
?????文件????????911??2007-07-06?12:23??MyGetRGB\ByteFile.h
?????文件???????1884??2007-08-02?23:17??MyGetRGB\MyBitmap.cpp
?????文件????????530??2007-07-06?12:23??MyGetRGB\MyBitmap.h
?????文件??????37668??2007-08-03?12:17??MyGetRGB\MyGetRGB.aps
?????文件???????2442??2007-08-03?12:17??MyGetRGB\MyGetRGB.clw
?????文件???????2091??2007-07-06?12:23??MyGetRGB\MyGetRGB.cpp
?????文件???????4706??2007-08-03?12:18??MyGetRGB\MyGetRGB.dsp
?????文件????????541??2007-07-06?12:23??MyGetRGB\MyGetRGB.dsw
?????文件???????1346??2007-07-06?12:23??MyGetRGB\MyGetRGB.h
?????文件??????91136??2007-08-03?12:18??MyGetRGB\MyGetRGB.ncb
?????文件??????57856??2007-08-03?12:18??MyGetRGB\MyGetRGB.opt
?????文件???????1664??2007-08-03?12:17??MyGetRGB\MyGetRGB.plg
?????文件???????7299??2007-08-03?12:17??MyGetRGB\MyGetRGB.rc
?????文件???????5886??2007-08-03?12:17??MyGetRGB\MyGetRGBDlg.cpp
?????文件???????1891??2007-08-03?10:41??MyGetRGB\MyGetRGBDlg.h
?????文件???????1811??2007-07-06?12:23??MyGetRGB\MyPictrue.cpp
?????文件????????576??2007-07-06?12:23??MyGetRGB\MyPicture.h
?????文件???????1485??2007-08-02?23:17??MyGetRGB\OutPut.cpp
?????文件???????1286??2007-07-06?12:23??MyGetRGB\OutPut.h
?????文件???????3615??2007-07-06?12:23??MyGetRGB\ReadMe.txt
?????文件???????1078??2007-07-06?12:23??MyGetRGB\res\MyGetRGB.ico
?????文件????????400??2007-07-06?12:23??MyGetRGB\res\MyGetRGB.rc2
????..A.SH.??????3072??2007-08-03?12:18??MyGetRGB\res\Thumbs.db
?????文件???????1190??2007-08-03?12:17??MyGetRGB\resource.h
?????文件????????210??2007-07-06?12:23??MyGetRGB\StdAfx.cpp
?????文件???????1054??2007-07-06?12:23??MyGetRGB\StdAfx.h
?????文件????????781??2007-07-06?12:23??MyGetRGB\相關使用.txt
?????目錄??????????0??2007-08-03?12:18??MyGetRGB\res
?????目錄??????????0??2007-08-03?12:18??MyGetRGB
............此處省略4個文件信息
評論
共有 條評論