软件截图

下面是win32 界面程序代码


#define WIN32_LEAN_AND_MEAN       //  从 Windows 头文件中排除极少使用的信息//#include <windows.h>// Windows 头文件
#include   <afxwin.h>  #include "resource.h"
#include <tchar.h>
#include"stdio.h"
#include"Draw.h"
#define _AFXDLL
#include <direct.h>
// 此代码模块中包含的函数的前向声明:
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
BOOL CreateAToolBar(HWND hwnDlg, HINSTANCE hInstance);
char FilePath[MAX_PATH] ;//全局变量文件路径
char NowPath[120];
BOOL FilePathFlag = FALSE;
double Factor = 0.6;
class mywin
{
public:ATOM m_Register(_In_ HINSTANCE hInstance);BOOL m_Instance(_In_ HINSTANCE hInstance, _In_ int  nCmdShow);BOOL m_ShowWindow();BOOL m_UpdateWindow();HWND m_hWnd;
};ATOM mywin::m_Register(_In_ HINSTANCE hInstance)
{//第一步填充WNDCLASSEX, 窗口类结构体WNDCLASSEX wcex;wcex.cbSize = sizeof(WNDCLASSEX);       //结构体大小wcex.style = CS_HREDRAW | CS_VREDRAW;   //重画wcex.lpfnWndProc = WndProc;             //回调函数wcex.cbClsExtra = 0;wcex.cbWndExtra = 0;wcex.hInstance = hInstance;wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));wcex.hCursor = LoadCursor(NULL, IDC_ARROW);wcex.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);//背景颜色wcex.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1); //菜单名字wcex.lpszClassName = _T("Class");               //类名字wcex.hIconSm = NULL;return RegisterClassEx(&wcex);//第二步 调用注册函数
}BOOL mywin::m_Instance(_In_ HINSTANCE hInstance, _In_ int nCmdShow)
{UINT width = GetSystemMetrics(SM_CXSCREEN);UINT height = GetSystemMetrics(SM_CYSCREEN);m_hWnd = CreateWindow(_T("Class"),   //LPCTSTR   lpClassName,_T("字母图"),          //LPCTSTR   lpWindowName,WS_OVERLAPPEDWINDOW,//DWORD     dwStyle,0,              // int       x,0,              //int       y,width,              //int       nWidth,height - 40,                //int       nHeight,NULL,           //HWND      hWndParent,NULL,           //HMENU     hMenu,hInstance,      //HINSTANCE hInstance,NULL);          //LPVOID    lpParamif (!m_hWnd){MessageBox(NULL, TEXT("创建窗口失败"), TEXT("提示"), MB_ICONWARNING);return FALSE;}CreateAToolBar(m_hWnd, hInstance);ShowWindow(m_hWnd, SW_SHOWNORMAL); //显示窗口UpdateWindow(m_hWnd);return TRUE;
}
HWND hToolBar;
BOOL CreateAToolBar(HWND hwnDlg, HINSTANCE hInstance)
{WNDCLASSEX wcex;wcex.cbSize = sizeof(WNDCLASSEX);       //结构体大小wcex.style = CS_HREDRAW | CS_VREDRAW;   //重画wcex.lpfnWndProc = WndProc;             //回调函数wcex.cbClsExtra = 0;wcex.cbWndExtra = 0;wcex.hInstance = hInstance;wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));wcex.hCursor = LoadCursor(NULL, IDC_ARROW);wcex.hbrBackground = (HBRUSH)GetStockObject(2);//背景颜色wcex.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1); //菜单名字wcex.lpszClassName = _T("childClass");              //类名字wcex.hIconSm = NULL;RegisterClassEx(&wcex);//第二步 调用注册函数const int NumImage = 6;  //  创建工具栏窗口//TOOLBARCLASSNAMEhToolBar = CreateWindowEx(NULL, TOOLBARCLASSNAME, " ", WS_CHILD | WS_VISIBLE | TBSTYLE_TOOLTIPS,0, 0, 32*NumImage,32, hwnDlg, NULL, hInstance, NULL); TBBUTTON tButton[NumImage];ZeroMemory(tButton, sizeof(tButton));//创建一个图片列表HIMAGELIST hInmageList = ImageList_Create(32, 32, ILC_COLOR24/*ILC_COLOR16 | ILC_MASK*/, NumImage, 0);int iBitmap[NumImage] = { 0 };WORD Id[NumImage] = { IDB_OPEN, IDB_CUT, IDB_DRAW, IDB_BIG, IDB_SMALL, IDB_HELP };for (int i = 0; i < NumImage; i++){iBitmap[i] = ImageList_Add(hInmageList, LoadBitmap(hInstance, MAKEINTRESOURCE(Id[i])), 0);}SendMessage(hToolBar, TB_SETIMAGELIST, 0, (LPARAM)hInmageList);   //将位图添加到工具栏//  TCHAR *szBitMAp[] = { "open", "draw", "help" };//标题for (int j = 0; j < NumImage; j++){tButton[j].iBitmap = MAKELONG(iBitmap[j], 0);tButton[j].fsState = TBSTATE_ENABLED;tButton[j].fsStyle = TBSTYLE_BUTTON | BTNS_AUTOSIZE;//tButton[j].iString = (INT_PTR)szBitMAp[j];//标题//tButton[j].idCommand = j+100;//命令}tButton[0].idCommand = ID_FILE_OPEN;tButton[1].idCommand = ID_FILE_SAVE;tButton[2].idCommand = ID_DRAW_DRAW;tButton[3].idCommand = ID_EDIT_ENLARGE;tButton[4].idCommand = ID_EDIT_SHRINK;tButton[5].idCommand = ID_HELP_INSTRUCTION;SendMessage(hToolBar, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 90);   //计算工具栏大小 SendMessage(hToolBar, TB_ADDBUTTONS, sizeof(tButton) / sizeof(TBBUTTON), (LPARAM)&tButton);     //添加按钮到工具栏  //SendMessage(hToolBar, TB_SETBUTTONSIZE, 0, (LPARAM)MAKELONG(10, 10));  SendMessage(hToolBar, TB_AUTOSIZE, 0, 0);    //调整工具栏大小//https://msdn.microsoft.com/en-us/library/windows/desktop/bb787421(v=vs.85).aspxCOLORSCHEME color;color.dwSize = sizeof(COLORSCHEME);color.clrBtnHighlight = RGB(0, 255, 0);color.clrBtnShadow = RGB(0,255,0);SendMessage(hToolBar, TB_SETCOLORSCHEME, 0, (LPARAM)&color);    //调整工具栏大小ShowWindow(hToolBar, TRUE);return TRUE;
}mywin Obj;//全局窗口对象
HINSTANCE *all_Instance;
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,_In_opt_ HINSTANCE hPrevInstance,_In_ LPTSTR    lpCmdLine,_In_ int       nCmdShow)
{Obj.m_Register(hInstance);Obj.m_Instance(hInstance, nCmdShow);all_Instance = &hInstance;_getcwd(NowPath, 120);strcat(NowPath, "\\screener_plugin");MSG msg;while (GetMessage(&msg, NULL, 0, 0)){TranslateMessage(&msg);DispatchMessage(&msg);}return (int)msg.wParam;
}
int xx = 0, yy = 0;BOOL OpenFile(HWND hWnd)
{OPENFILENAME ofn;ZeroMemory(&ofn, sizeof(ofn));ofn.lStructSize = sizeof(ofn);ofn.hwndOwner = hWnd;ofn.lpstrFile = FilePath;ofn.nMaxFile = sizeof(FilePath);ofn.lpstrFilter = NULL;ofn.nFilterIndex = 1;ofn.lpstrFileTitle = NULL;ofn.nMaxFileTitle = 0;ofn.lpstrInitialDir = NULL;ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;FilePathFlag=GetOpenFileName(&ofn);//如果用户指定了一个文件名且点击OK按钮,返回值为非零值。如果用户取消或关闭Save对话框或错误出现,返回值为零。if (FilePathFlag)  //打开文件成功{//std::vector<wstring> vctString(1, FilePath);//保存添加文件的路径//MessageBox(hWnd, FilePath, _T("successful"), MB_OK);//"LPCWSTRTextOut(GetDC(hWnd), 10, 45, FilePath, strlen(FilePath));}else{DWORD dwError = NOERROR;dwError = CommDlgExtendedError();MessageBox(hWnd, _T("open file failed!"), _T("tips"), MB_OK);//"LPCWSTR}return TRUE;
}BOOL MyDraw(HDC hdc)
{if (!FilePathFlag)  return FALSE;CDC *pDC = CDC::FromHandle(hdc);CWnd *pWnd = pDC->GetWindow();RECT rc;pWnd->GetClientRect(&rc);//填充窗口大小结构体rcmyWin WinRect;WinRect.x = rc.left;WinRect.y = rc.top + 500;WinRect.height = rc.bottom - rc.top;WinRect.width = rc.right - rc.left;InterFun(pDC, WinRect, FilePath,Factor);//接口函数return TRUE;
}
void Instruction(HDC hdc)
{CDC *pDC = CDC::FromHandle(hdc);CPen pen;pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 250));CFont font;font.CreateFont(22,                      // nHeight0,                         // nWidth0,                         // nEscapement0,                         // nOrientationFW_NORMAL,                 // nWeightFALSE,                     // bItalicFALSE,                     // bUnderline0,                         // cStrikeOutANSI_CHARSET,              // nCharSetOUT_DEFAULT_PRECIS,        // nOutPrecisionCLIP_DEFAULT_PRECIS,       // nClipPrecisionDEFAULT_QUALITY,           // nQualityDEFAULT_PITCH | FF_SWISS,  // nPitchAndFamily_T("宋体"));pDC->SelectObject(&font);pDC->SelectObject(pen);pDC->Rectangle(300, 130, 1050, 410);pDC->SetTextColor(RGB(0, 0, 250));pDC->TextOut(320, 150, "使用说明:");pDC->TextOut(320, 200, "画图数据是一列实型数据,打开数据前要在画图数据中添加画图参数,");pDC->TextOut(320, 250, "第一行添加一个整型数据:氨基酸字母长度,");pDC->TextOut(320, 300, "第二行添加一个整型数据:氨基酸编码长度(20或21),");pDC->TextOut(320, 350, "两者乘积应等于实型数据的个数。");DeleteObject(pen);DeleteObject(font);
}
CButton btn;
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{int wmId, wmEvent;PAINTSTRUCT ps;switch (message){case WM_COMMAND://菜单命令intwmId = LOWORD(wParam);wmEvent = HIWORD(wParam);switch (wmId)// 分析菜单命令: {case ID_FILE_SAVE://截图{//TCHAR CmdLine[] = TEXT(buffer);STARTUPINFO si; //一些必备参数设置  memset(&si, 0, sizeof(STARTUPINFO));  si.cb = sizeof(STARTUPINFO);  si.dwFlags = STARTF_USESHOWWINDOW;  si.wShowWindow = SW_SHOW;  PROCESS_INFORMATION pi; //必备参数设置结束  int flag=CreateProcess(NULL,NowPath ,NULL,NULL,1,CREATE_NO_WINDOW,NULL,NULL,&si,&pi);if (flag == 0){MessageBox(hWnd, _T("CreateProcess fail!"), _T("title"), MB_OK);//"LPCWSTRMessageBox(hWnd, _T(NowPath), _T("path"), MB_OK);//"LPCWSTR}break;}case ID_FILE_OPEN:  //打开文件{OpenFile(hWnd);break;}case ID_DRAW_DRAW:  //画图InvalidateRect(Obj.m_hWnd, 0, TRUE);UpdateWindow(Obj.m_hWnd);if (!MyDraw(GetDC(hWnd)))MessageBox(hWnd, _T("请先选择文件再画图!"), _T("title"), MB_OK);//"LPCWSTRbreak;case ID_EDIT_ENLARGE: //放大Factor += 0.05;InvalidateRect(Obj.m_hWnd, 0, TRUE);UpdateWindow(Obj.m_hWnd);if (!MyDraw(GetDC(hWnd)))MessageBox(hWnd, _T("请先选择文件再画图!"), _T("title"), MB_OK);//"LPCWSTRbreak;case ID_EDIT_SHRINK:   //缩小Factor -= 0.05;InvalidateRect(Obj.m_hWnd, 0, TRUE);UpdateWindow(Obj.m_hWnd);if (!MyDraw(GetDC(hWnd)))MessageBox(hWnd, _T("请先选择文件再画图!"), _T("title"), MB_OK);//"LPCWSTRbreak;case ID_HELP_INSTRUCTION:  //帮助Instruction(GetDC(hWnd));break;default:return DefWindowProc(hWnd, message, wParam, lParam);}break;case WM_LBUTTONDOWN://鼠标左键{break;}case WM_RBUTTONDOWN:MessageBox(hWnd, _T("right"), _T("title"), MB_OK);//"LPCWSTRbreak;case WM_CREATE: // creating main window {RECT lRect;GetClientRect(hToolBar, &lRect);FillRect(GetDC(hToolBar), &lRect, GetSysColorBrush(COLOR_3DDKSHADOW));//CWnd * pCWnd;//pCWnd = CWnd::FromHandle(hWnd);//btn.Create(_T("btnName"), WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON, CRect(0, 0, 90, 20), pCWnd, 123);//btn.ShowWindow(SW_SHOWNORMAL);break;}case WM_PAINT:HDC hdc;hdc = BeginPaint(hWnd, &ps);// TODO:  在此添加任意绘图代码...EndPaint(hWnd, &ps);break;case WM_DESTROY:       //窗口已经销毁PostQuitMessage(0);//退出程序break;default:            //缺省消息处理return DefWindowProc(hWnd, message, wParam, lParam);}return 0;
}

以下是存放接口函数InterFun(pDC, WinRect, FilePath,Factor)的头文件Draw.h;

#include "stdio.h"
#include "stdlib.h"
#include "math.h"
#include "float.h"
#include   <afxwin.h>
//#define Ncolumn 28//读入数据列数//#define FACTOR   0.6//值越大则高度越高
#define N 1
#define WIDE WinRect.width/(double)(Ncolumn+2.5)//一列宽度#define BLACK RGB(0,0,0)
#define GREEN RGB(0,255,0)
#define RED RGB(255,0,0)
#define BLUE RGB(0,0,255)
#define UN RGB(111,111,111)//颜色
int Ncolumn=0;
//颜色数组
COLORREF color[26] = { BLACK, UN, GREEN, RED, RED, BLACK, GREEN, BLUE, BLACK, UN, BLUE, BLACK, BLACK, GREEN, UN, BLACK, GREEN, BLUE, GREEN, GREEN, UN, BLACK, BLACK, UN, BLACK, UN };//颜色
struct MyChar
{char mychar[1];COLORREF mycolor;double myheight;struct MyChar* prev;struct MyChar* after;}; struct myWin
{int x;int y;int height;int width;
};FILE *open_file(const char * filename,const char *mode)//打开文件
{FILE *fp;fp=fopen(filename,mode);if(fp==NULL){fprintf(stdout,"err msg is %s\n",filename);exit(1);}return fp;
}void Sort(struct MyChar * &MyChar,const int feature)//按照高度排序,从大到小
{struct MyChar temp;for(int i=0;i<feature;i++){for(int j=i+1;j<feature;j++){if(MyChar[i].myheight < MyChar[j].myheight){temp = MyChar[i];MyChar[i] = MyChar[j];MyChar[j] = temp;}}}for(int n=0;n<feature-1;n++){MyChar[feature-1-n].prev=&MyChar[(feature-1-n)-1];MyChar[n].after=&MyChar[n+1];}MyChar[0].prev = NULL;MyChar[feature-1].after=NULL;
}int Paint_a_char(int _x,int _y,double height,COLORREF color,char* mychar,CDC *pDC,myWin WinRect)//输出一个字符
{CFont font;CFont* oldfont;LOGFONT lf;memset(&lf, 0, sizeof(LOGFONT)); //内存分配给对象lflf.lfWeight =500;//字符的粗细lf.lfWidth = WIDE;//字符的宽度lf.lfHeight = height;//字符的高度if(height>0)   lf.lfEscapement = 0;else         lf.lfEscapement=1800;    //char *tem = "@MS Gothic";//MultiByteToWideChar(CP_ACP, 0, tem, sizeof(tem)-1, lf.lfFaceName, sizeof(tem)-1);strcpy(lf.lfFaceName, _T("@MS Gothic")); //字体   VERIFY(font.CreateFontIndirect(&lf));   oldfont=pDC->SelectObject(&font);//选择绘图工具pDC->SetTextColor(color);//字符颜色         pDC->SetBkMode(TRANSPARENT);//背景(透明)int xx = _x;  //字母的位置int yy = _y;//BOOL ExtTextOut(  扩展文本输出函数//  _In_       HDC     hdc,//  _In_       int     X,//  _In_       int     Y,//  _In_       UINT    fuOptions,//  _In_ const RECT    *lprc,//  _In_       LPCTSTR lpString,//  _In_       UINT    cbCount,//  _In_ const INT     *lpDx//);/*  LONG    left;  rectangleLONG    top;LONG    right;LONG    bottom;*/if(height>0)  {  RECT rct = {xx , yy-lf.lfHeight, xx+lf.lfWidth , yy}; //字母的上下左右pDC->ExtTextOutA(_x , _y-lf.lfHeight , ETO_CLIPPED , &rct , mychar , 1 , NULL );}else         {  RECT rct = {xx , yy, xx+lf.lfWidth , yy-lf.lfHeight};pDC->ExtTextOutA(_x+lf.lfWidth , _y-lf.lfHeight , ETO_CLIPPED , &rct , mychar , 1 , NULL );}yy-=lf.lfHeight;//下一次绘图的yypDC->SelectObject(oldfont);font.DeleteObject();return yy;//做了数值上的调整,增大返回值会使字母(列)紧凑
}void Paint_column(struct MyChar *P_MyChar,int n,CDC *pDC,myWin WinRect,double origin_x,double origin_y,const int feature)//输出一列字符
{int y = origin_y-1;struct MyChar *p_positive;p_positive = &P_MyChar[feature-1];//从大到小排列while(p_positive != NULL){if(p_positive->myheight <= 0){p_positive =p_positive->prev;continue;}y = Paint_a_char(origin_x+WIDE*n,y,p_positive->myheight,p_positive->mycolor,p_positive->mychar,pDC,WinRect);p_positive = p_positive->prev;}y = (int)origin_y+1;p_positive = &P_MyChar[0];//从大到小排列while(p_positive != NULL){if(p_positive->myheight >= 0){p_positive =p_positive->after;continue;}y = Paint_a_char(origin_x+WIDE*n,y,p_positive->myheight,p_positive->mycolor,p_positive->mychar,pDC,WinRect);p_positive = p_positive->after;}
}void Heng_zuo_biao(CDC *pDC,int n,myWin WinRect,double origin_x,double&FACTOR)//输出坐标值
{CFont font;LOGFONT lf;memset(&lf, 0, sizeof(LOGFONT)); lf.lfWeight =300;lf.lfWidth = WIDE/4*FACTOR;lf.lfHeight = WIDE/2*FACTOR;lf.lfEscapement =0;strcpy(lf.lfFaceName, "simsun");        VERIFY(font.CreateFontIndirect(&lf));  // create the fontCFont* oldfont=pDC->SelectObject(&font);pDC->SetTextColor(BLACK);               // Set the text colorpDC->SetBkMode(TRANSPARENT);int site=n;site++;char alpha[5]="P";if (site<10){alpha[1]=(char)(site+'0');//alpha[2]=0;}else if (site<100){alpha[1]=(char)(site/10+'0');//alpha[2]=(char)(site%10+'0');alpha[3]=0;}else{      alpha[1]=(char)(site/100+'0');alpha[2]=(char)((site%100)/10+'0');             alpha[3]=(char)(site%10+'0');alpha[4]=0;}int x=origin_x + WIDE*n+WIDE*1/4 ;int y=WinRect.height*FACTOR+WinRect.height*(1-FACTOR)/3+30;pDC->TextOutA(x+15,y+65,alpha,5);pDC->SelectObject(oldfont);font.DeleteObject();}void Zong_zuo_biao(int x,int y,double num,CDC *pDC,myWin WinRect)//输出纵坐标数字
{CFont font;LOGFONT logfont;//The LOGFONT structure defines the attributes of a font.memset(&logfont, 0, sizeof(LOGFONT)); logfont.lfWeight = 200; //For example, 400 is normal and 700 is bold.logfont.lfWidth = WIDE/8;logfont.lfHeight = WIDE/4;strcpy(logfont.lfFaceName, "simsun");//A null-terminated string that specifies the typeface name of the font. VERIFY(font.CreateFontIndirect(&logfont));  // create the fontpDC->SelectObject(&font);pDC->SetTextColor(BLACK);               // Set the text colorpDC->SetBkMode(TRANSPARENT);char strnum[10];sprintf(strnum, "%-.2lf", num);    pDC->TextOutA(x-WIDE/2,y-logfont.lfHeight/2,strnum,strlen(strnum));font.DeleteObject();
}void printline(CDC *pDC,myWin &WinRect,double max_y,double min_y,double origin_x,double origin_y,double&FACTOR)//输出线条
{int vert_move = 32;//工具栏偏移int x_start = origin_x*0.9;int x_end =origin_x + (Ncolumn)*WIDE;int y_top = WinRect.height*(1-FACTOR)/3-60+vert_move;int y_bottom =WinRect.height*FACTOR+ WinRect.height*(1-FACTOR)/3+60+vert_move;//中心横坐标线pDC->MoveTo(x_start-8,origin_y);    //将当前位置移动到 x 和 y 指定的点(或 point)      pDC->LineTo(x_end,origin_y);//底部很坐标线 包含(底部纵坐标刻度(小横线))//y_bottom+=60;pDC->MoveTo(x_start-8,y_bottom-1);pDC->LineTo(x_end,y_bottom-1);pDC->MoveTo(x_start-8,y_bottom);pDC->LineTo(x_end,y_bottom);pDC->MoveTo(x_start-8,y_bottom+1);pDC->LineTo(x_end,y_bottom+1);
//左侧纵轴坐标线pDC->MoveTo(x_start-2,origin_y);                            pDC->LineTo(x_start-2,y_top);pDC->LineTo(x_start-2,y_bottom);pDC->MoveTo(x_start-1,origin_y);                            pDC->LineTo(x_start-1,y_top);pDC->LineTo(x_start-1,y_bottom);pDC->MoveTo(x_start,origin_y);                          pDC->LineTo(x_start,y_top);pDC->LineTo(x_start,y_bottom);
//顶部纵坐标刻度(小横线)pDC->MoveTo(x_start-8,y_top);       pDC->LineTo(x_start,y_top);     pDC->MoveTo(x_start-8,y_top+1);     pDC->LineTo(x_start,y_top+1);   pDC->MoveTo(x_start-8,y_top+2);     pDC->LineTo(x_start,y_top+2);   Zong_zuo_biao(x_start-WIDE/2,(int)origin_y,0.0,pDC,WinRect);  //中间刻度Zong_zuo_biao(x_start-WIDE/2,y_top,max_y,pDC,WinRect);  //max 刻度Zong_zuo_biao(x_start-WIDE/2,y_bottom,-min_y,pDC,WinRect);//纵坐标最小刻度}void InterFun(CDC *pDC, myWin& WinRect, char *path, double FACTOR)
{   FILE *fp_xishu = open_file(path,"r");if (NULL == fp_xishu){pDC->TextOutA(WinRect.width / 2 - 20,WinRect.height / 2,  "Open File Failed!", strlen("Open File Failed!"));return;}int feature = 0;  //每个编码方式的属性数,比如稀疏编码,21个属性+6个。int res=fscanf(fp_xishu,"%d",&Ncolumn);   //氨基酸序列长度if (-1==res){pDC->TextOutA(WinRect.width / 2 - 60, WinRect.height / 2, "文件第一个数据应该是int型,代表肽链长度。", strlen("文件第一个数据应该是int型,代表肽链长度。"));return;}res=fscanf(fp_xishu,"%d",&feature);   //编码长度,只能是20 或者21if (-1 == res){pDC->TextOutA(WinRect.width / 2 - 60, WinRect.height / 2, "文件第二个数据应该是int型,代表编码长度。", strlen("文件第一个数据应该是int型,代表肽链长度。"));return;}//测试文件长度int count = 0;double tem;while (!feof(fp_xishu)){res=fscanf(fp_xishu, "%lf", &tem);if (-1 == res&& !feof(fp_xishu)){char str[20];char *ss = "row:";sprintf(str, "%d", count);pDC->TextOutA(WinRect.width / 2 - 40, WinRect.height / 2, " 数据应该是double型。", strlen(" 数据应该是double型。"));pDC->TextOutA(WinRect.width / 2 - 40, WinRect.height / 2+20, str, strlen(str));return;}count++;}count--;if (count!=Ncolumn*feature){char str[20];char *ss = "count:";sprintf(str, "%s%d",ss, count);pDC->TextOutA(WinRect.width / 2 - 40, WinRect.height / 2 + 20, str, strlen(str));pDC->TextOutA(WinRect.width / 2 - 30, WinRect.height / 2, " 数据个数应该等于肽链长度乘以编码长度。", strlen(" 数据个数应该等于肽链长度乘以编码长度。"));return;}rewind(fp_xishu);fscanf(fp_xishu, "%d", &tem);fscanf(fp_xishu, "%d", &tem);feature+=6;struct MyChar* MyChar = new struct MyChar[feature];double **xishu = new double *[Ncolumn]; // 创建9个二级指针,for (int i=0; i<Ncolumn; i++){xishu[i] = new double[feature];   //int feature = 27;  }  double fabsum=0;double sum=0;double max1=0;double max2=0;for(int i=0;i<Ncolumn;i++)  //按列读取{       if   ((fabsum+sum)/2>=max1)      max1=(fabsum+sum)/2;if   ((fabsum-sum)/2>=max2)      max2=(fabsum-sum)/2;fabsum=0;   sum=0;   //for(int n=0;n<feature;n++)  //一个循环读取20或者21 个数据{if( n==1||n==9||n==14||n==20||n==23||n==25)  //除非氨基酸字母置零{xishu[i][n] = 0.0;}else{fscanf(fp_xishu,"%lf",&xishu[i][n]);   //xishu[i][n]  9*27}fabsum=fabsum+fabs(xishu[i][n]);sum=sum+xishu[i][n];}}fclose(fp_xishu);fp_xishu = NULL;double origin_y = WinRect.height*max1/(max1+max2)*FACTOR+WinRect.height*(1-FACTOR)/3;double origin_x = WIDE*1.5;for(int i=0;i<Ncolumn;i++)  //字母,颜色,高度赋值。{for(int n=0;n<feature;n++){if(n!=26){MyChar[n].mychar[0]='A'+n;MyChar[n].mycolor=color[n];MyChar[n].myheight = (xishu[i][n]/(max1+max2))*WinRect.height*FACTOR;}else  //{MyChar[n].mychar[0]='*';MyChar[n].mycolor=color[n];MyChar[n].myheight = (xishu[i][n]/(max1+max2))*WinRect.height*FACTOR;}}Sort(MyChar,feature);   //按值排序Paint_column(MyChar,i,pDC,WinRect,origin_x,origin_y,feature);Heng_zuo_biao(pDC,i,WinRect,origin_x, FACTOR);//P 1 P2 那行}printline(pDC,WinRect,max1,max2,origin_x,origin_y,FACTOR);//纵坐标和线for (int i=0; i<Ncolumn; i++){delete []xishu[i];xishu[i] = NULL;}delete []xishu;xishu = NULL;delete []MyChar;MyChar = NULL;
}

Win32编程绘图实例--字母图相关推荐

  1. python窗口图形界面编程上传图片_python GUI编程(Tkinter) 创建子窗口及在窗口上用图片绘图实例...

    注意主窗口一定要为tk.Tk(),在主窗口上通过button的点击相应子函数创建子窗口,注意此时创建出来的窗口必须是Toplevel,否则出错. 至于用图片在窗口上绘图,则按代码所示即可. # -*- ...

  2. WIN32编程经验总结

    WIN32编程经验总结 分类: C/C++ 2013-10-28 10:37 157人阅读 评论(0) 收藏 举报 一 窗口和消息 1 前缀 前缀  全称  释义   CS  class style ...

  3. 【Win32】初识Win32编程

    补发:发表于2021-11-08 忘了同步到CSDN上了 链接 Windows编程 应用程序分类 控制台程序Console DOS程序,本身没有窗口,通过Windows DOS窗口执行.(DOS是操作 ...

  4. win32编程常用的数据类型

    win32编程常用的数据类型有: HANDLE 定义一个32位无符号的整数,用作句柄 HINSTANCE 定义一个32位的无符号整数,用作实例句柄 HWND 定义一个32位的无符号整数,用作窗口句柄 ...

  5. Windows 外壳扩展编程入门实例

    Windows 外壳扩展编程入门实例 -- Delphi 篇 作者的话 关于Windows 外壳扩展方面的文章私心以为最好的应当算是Michael Dunn 的TheComplete Idiot's ...

  6. android编程绘图,Android编程绘图操作之弧形绘制方法示例

    本文实例讲述了Android编程绘图操作之弧形绘制方法.分享给大家供大家参考,具体如下: /** * 绘制弧形图案 * @description: * @author ldm * @date 2016 ...

  7. 【javaEE】网络编程套接字

    To u&me: 努力经营当下,直至未来明朗 文章目录 前言 一.网络编程(没时间可以跳过) 一)网络编程了解 二)相关基本概念 二.Socket套接字 三.数据报套接字通信(UDP) 写一个 ...

  8. Win32 编程基础

    Windows编程框架 #include <windows.h> #include <windowsx.h>//函数声明BOOL InitWindow( HINSTANCE h ...

  9. Win32编程基础知识

    Win32编程基础知识 尽管Windows应用程序千变万化,令人眼花缭乱,但,消息机制和窗口过程却始终它们的基础,掌握了这两项技术,也就相当于把握住了问题的关键. 如果你以前是C程序员或是MFC的忠实 ...

最新文章

  1. 如果MySQL事务中发生了网络异常?
  2. 二叉搜索树的第k个结点
  3. Android 数据库 LiteOrm 的使用
  4. python 服务器_只要一行Python代码,就能搭建一个共享文件局域网服务器
  5. 计算机基本网络测试命令实验报告,实验三 基本网络测试工具的使用
  6. 谈谈C#的私有成员的一个有趣的现象!
  7. 破解并配置WebStorm
  8. 上海智能交通建设现状与未来发展要点
  9. 随记(七):Jboss漏洞检测利用工具
  10. rxj热血江hsf湖私服_如何使用RxJ进行React性思考和动画化移动对象
  11. 半路出家,如何推销自己?
  12. 饥荒联机版steam专用服务器创建
  13. 启用Win10家庭版的远程桌面服务端
  14. python-绘图与可视化
  15. c语言程序设计四则运算,用C语言编程实现一个简单的四则运算计算器
  16. java解决udp可靠性,由于UDP协议提供的是不可靠的服务,因此,可以被淘汰掉。...
  17. C语言实现【小游戏——反弹球消砖块】
  18. java存款只能存100_有100万存款,怎么样存银行才是最佳方法呢?
  19. CBTC系统标准: 1474.4---系统特点及应用
  20. 考研邱关源电路总结第一章

热门文章

  1. 个人自我评价格式范文五篇
  2. 建站推荐十个免费的CMS内容管理系统(Php+mysql)
  3. 实时路径追踪篇 反射和折射
  4. Python-PIP 安装常用包
  5. Laravel Trait
  6. 综述:文本分析在市场营销研究中的应用
  7. 富士通服务器怎么配置u盘装系统,详解富士通电脑u盘重装系统win8教程
  8. Linq语句数组List去重
  9. 【8042】产品记分板
  10. 第五期转区系统服务器,梦幻西游:被困在某服务器的玩家,因为系统设置问题暂时不能转区...