當前位置:首頁 » 軟體設計 » mfc設計

mfc設計

發布時間: 2020-12-18 09:43:15

A. vs2010基於對話框的MFC界面設計

在新對話框的初始化中加
::setparent(新對話框句柄,null);
試一下

B. 基於MFC設計並實現一個簡單的學生成績管理系統

#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#define LEN sizeof(struct scorenode)
#define DEBUG
#include <string.h>
struct scorenode
{int number;/*學號*/
char name[10];/*姓名*/
float computer;/*計算機 成績*/
float english;/*英語成績*/
float math;/*數學成績 */
struct scorenode *next;
};
typedef struct scorenode score;
int n,k;/*n,k為全局變數,本程序中的函數均可以使用它*/
/*==============================================================================================*/
score *creat(void)/*函數creat,功能:創建鏈表,此函數帶回一個指向鏈表頭的指針*/
{
score*head;
score *p1,*p2,*p3,*max;
int i,j;
float fen;
char t[10];
n=0;
p1=p2=p3=(score *)malloc(LEN);head=p3; /*開辟一個新單元輸入學生相關資料*/
printf("請輸入學生資料,輸0退出!\n");
repeat1: printf("請輸入學生學號(學號應大於0):");
scanf("%d",&p1->number);
while(p1->number<0)
{getchar();
printf("輸入錯誤,請重新輸入學生學號:");
scanf("%d",&p1->number);}
if(p1->number==0)
goto end;
else
{
p3=head;
if(n>0)
{for(i=0;i<n;i++)
{if(p1->number!=p3->number)
p3=p3->next;
else
{printf("學號重復,請重輸!\n");
goto repeat1;
}
}
}
}
printf("請輸入學生姓名:");
scanf("%s",&p1->name);
printf("請輸入計算機 成績(0~100):");
scanf("%f",&p1->computer);
while(p1->computer<0||p1->computer>100)
{getchar();
printf("輸入錯誤,請重新輸入計算機 成績");
scanf("%f",&p1->computer);}
printf("請輸入英語成績(0~100):");
scanf("%f",&p1->english);
while(p1->english<0||p1->english>100)
{getchar();
printf("輸入錯誤,請重新輸入英語成績");
scanf("%f",&p1->english);}
printf("請輸入數學成績(0~100):");
scanf("%f",&p1->math);
while(p1->math<0||p1->math>100)
{getchar();
printf("輸入錯誤,請重新輸入數學成績");
scanf("%f",&p1->math);}
head=NULL;
while(p1->number!=0)
{
n=n+1;
if(n==1)
head=p1;
else
p2->next=p1;
p2=p1;
p1=(score *)malloc(LEN);
printf("請輸入學生資料,輸0退出!\n");
repeat2:printf("請輸入學生學號(學號應大於0):");
scanf("%d",&p1->number);
while(p1->number<0)
{getchar();
printf("輸入錯誤,請重新輸入學生學號:");
scanf("%d",&p1->number);}
if(p1->number==0)
goto end;
else
{
p3=head;
if(n>0)
{for(i=0;i<n;i++)
{if(p1->number!=p3->number)
p3=p3->next;
else
{printf("學號重復,請重輸!\n");
goto repeat2;
}
}
}
}
printf("請輸入學生姓名:");
scanf("%s",&p1->name);
printf("請輸入計算機 成績(0~100):");
scanf("%f",&p1->computer);
while(p1->computer<0||p1->computer>100)
{getchar();
printf("輸入錯誤,請重新輸入計算機 成績");
scanf("%f",&p1->computer);}
printf("請輸入英語成績(0~100):");
scanf("%f",&p1->english);
while(p1->english<0||p1->english>100)
{getchar();
printf("輸入錯誤,請重新輸入英語成績");
scanf("%f",&p1->english);}
printf("請輸入數學成績(0~100):");
scanf("%f",&p1->math);
while(p1->math<0||p1->math>100)
{getchar();
printf("輸入錯誤,請重新輸入數學成績");
scanf("%f",&p1->math);}
}
end: p1=head;
p3=p1;
for(i=1;i<n;i++)
{
for(j=i+1;j<=n;j++)
{
max=p1;
p1=p1->next;
if(max->number>p1->number)
{
k=max->number;
max->number=p1->number;
p1->number=k;
strcpy(t,max->name);
strcpy(max->name,p1->name);
strcpy(p1->name,t);
fen=max->computer;
max->computer=p1->computer;
p1->computer=fen;
fen=max->english;
max->english=p1->english;
p1->english=fen;
fen=max->math;
max->math=p1->math;
p1->math=fen;
}
}
max=head;p1=head;/*重新使max,p指向鏈表頭*/
}
p2->next=NULL;/*鏈表結尾*/
printf("輸入的學生數為:%d個!\n",n);
return(head);
}
/*==============================================================================================*/
score *add2311(score *head,score *stu)/*函數add2311,功能將所有學生資料按學號排序*/
{
score *p0,*p1,*p2,*p3,*max;
int i,j;
float fen;
char t[10];
p3=stu=(score *)malloc(LEN);/*開辟一個新單元*/
printf("\n輸入要增加的學生的資料!");
repeat4: printf("請輸入學生學號(學號應大於0):");
scanf("%d",&stu->number);
/*輸入學號,學號應大於0*/
while(stu->number<0)
{getchar();
printf("輸入錯誤,請重新輸入學生學號:");
scanf("%d",&stu->number);}/*輸入錯誤,重新輸入學號*/
if(stu->number==0)
goto end2;/*當輸入的學號為0時,轉到末尾,結束追加*/
else
{
p3=head;
if(n>0)
{for(i=0;i<n;i++)
{if(stu->number!=p3->number)
p3=p3->next;
else
{printf("學號重復,請重輸!\n");
goto repeat4;
}
}
}
}
/******************************************************/
printf("輸入學生姓名:");
scanf("%s",stu->name);
printf("請輸入計算機 成績(0~100):");
scanf("%f",&stu->computer);
while(stu->computer<0||stu->computer>100)
{getchar();
printf("輸入錯誤,請重新輸入計算機 成績");
scanf("%f",&stu->computer);}
printf("請輸入英語成績(0~100):");
scanf("%f",&stu->english);
while(stu->english<0||stu->english>100)
{getchar();
printf("輸入錯誤,請重新輸入英語成績");
scanf("%f",&stu->english);}
printf("請輸入數學成績(0~100):");
scanf("%f",&stu->math);
while(stu->math<0||stu->math>100)
{getchar();
printf("輸入錯誤,請重新輸入數學成績");
scanf("%f",&stu->math);}
p1=head;
p0=stu;
if(head==NULL)
/*當原來鏈表為空時,從首結點開始存放資料*/
else
{
if(p1->next==NULL)
{
p1->next=p0;
p0->next=NULL;
}
else
{
while(p1->next!=NULL)
{
p2=p1;p1=p1->next;
}
p1->next=p0;
p0->next=NULL;
}
}
n=n+1;
p1=head;
p0=stu;
for(i=1;i<n;i++)
{
for(j=i+1;j<=n;j++)
{
max=p1;
p1=p1->next;
if(max->number>p1->number)
{
k=max->number;
max->number=p1->number;
p1->number=k;
strcpy(t,max->name);
strcpy(max->name,p1->name);
strcpy(p1->name,t);/*交換前後結點中的姓名,使之與學號相匹配*/
fen=max->computer;
max->computer=p1->computer;
p1->computer=fen;
fen=max->english;
max->english=p1->english;
p1->english=fen;
fen=max->math;
max->math=p1->math;
p1->math=fen;

}
}
max=head;p1=head;
} end2:
printf("現在的學生數為:%d個!\n",n);
return(head);
}
score *search(score *head)
/*函數search,功能:查詢學生成績*/
{int number;
score *p1,*p2;
printf("輸入要查詢的學生的學號,");
scanf("%d",&number);
while(number!=0)
{
if(head==NULL)

printf("-----------------------------------------\n");
printf("|學號\t|姓名\t|計算機\t|英語\t|數學\t|\n");
printf("-----------------------------------------\n");
p1=head;
while(number!=p1->number&&p1->next!=NULL)

if(number==p1->number)
{printf("|%d\t|%s\t|%.1f\t|%.1f\t|%.1f\t|\n",p1->number,p1->name,p1->computer,p1->english,p1->math);
printf("-----------------------------------------\n");}
else
printf("%d不存在此學生!\n",number);
printf("輸入要查詢的學生的學號,");
scanf("%d",&number);
}
printf("已經退出了!\n");
return(head);}
/*==============================================================================================*/
score *del(score *head)/*函數del,功能:刪除學生資料*/
{
score *p1,*p2;
int number;
printf("輸入要刪除的學生的學號(輸入0時退出):");
scanf("%d",&number);
getchar();
while(number!=0)/*輸入學號為0時退出*/
{
if(head==NULL)
{
printf("\n沒有任何學生資料!\n");
return(head);
}
p1=head;
while(number!=p1->number&&p1->next!=NULL)
{
p2=p1;p1=p1->next;
}
if(number==p1->number)
{
if(p1==head)
head=p1->next;
/*若p1指向的是首結點,把地二個結點地址賦予head*/
else
p2->next=p1->next;
printf("刪除:%d\n",number);n=n-1;
}
else
printf("%d不存在此學生!\n",number);
printf("輸入要刪除的學生的學號:");
scanf("%d",&number);
getchar();
}
#ifdef DEBUG
printf("已經退出了!\n");
#endif
printf("現在的學生數為:%d個!\n",n);
return(head);
}
/*==============================================================================================*/
void print(score *head)/*函數print,功能:顯示學生成績*/
{
score *p;
if(head==NULL)

else
{printf("%d\n",n);
printf("-----------------------------------------\n");
printf("|學號\t|姓名\t|計算機\t|英語\t|數學\t|\n");
printf("-----------------------------------------\n");
p=head;
do
{printf("|%d\t|%s\t|%.1f\t|%.1f\t|%.1f\t|\n",p->number,p->name,p->computer,p->english,p->math);
printf("-----------------------------------------\n");
p=p->next;}while (p!=NULL);
}
}
/*==============================================================================================*/
score *tongji(score *head)
/*函數tongji,功能:統計學生成績*/
{
float sum1=0,sum2=0,sum3=0,ave1=0,ave2=0,ave3=0,max=0,min;
score *p;
int x,y=0,i=0;
p=head;
printf("1個人總分和平均分\t2單科平均分\t3總分最高分\t4總分最低分\n");
scanf("%d",&x);
getchar();
switch(x)
{
case 1: if(head==NULL)

else
{
printf("---------------------------------------------------------\n");
printf("|學號\t|姓名\t|計算機\t|英語\t|數學\t|總分\t|平均分\t|\n");
printf("---------------------------------------------------------\n");
while(p!=NULL)
{
sum1=p->computer+p->english+p->math;
ave1=sum1/3;
printf("|%d\t|%s\t|%.1f\t|%.1f\t|%.1f\t|%.1f\t|%.1f\t|\n",p->number,p->name,p->computer,p->english,p->math,sum1,ave1);
printf("---------------------------------------------------------\n");/*列印表格域*/
p=p->next;}
}
return(head); break;
case 2: if(head==NULL)

while(p!=NULL)
{
sum1=sum1+p->computer;
sum2=sum2+p->english;
sum3=sum3+p->math;/*計算總分*/
y=y+1;
ave1=sum1/y;
ave2=sum2/y;
ave3=sum3/y;
p=p->next;
}
printf("計算機 平均分是%.1f\n",ave1);
printf("英語平均分是%.1f\n",ave2);
printf("數學平均分是%.1f\n",ave3);
return(head); break;
case 3:
if(head==NULL)

max=p->computer+p->english+p->math;
while(i<n)
{
i=i+1;
sum1=p->computer+p->english+p->math;
if(max<sum1)
max=sum1;
p=p->next;
}
printf("總分最高分:%.1f",max);
printf("\n");
return(head); break;
case 4: if(head==NULL)

while(p!=NULL)
{
min=p->computer+p->english+p->math;
while(p!=NULL)
{sum2=p->computer+p->english+p->math;
if(min>sum2)
min=sum2;
p=p->next;
}
}
printf("總分最低分:%.1f",min);
printf("\n");
return(head); break;
default :printf("輸入錯誤,請重試!\n");
}
return(head);
}
/*==============================================================================================*/
save(score *p1)
/*函數save,功能:保存學生的資料*/
{
FILE *fp;
char filepn[20];/*用來存放文件保存路徑以及文件名*/
printf("請輸入文件路徑及文件名:");
scanf("%s",filepn);
if((fp=fopen(filepn,"w+"))==NULL)
{
printf("不能打開文件!\n");
return 0;
}
fprintf(fp,"|學號\t|姓名\t|計算機\t|英語\t|數學\t|\n");
fprintf(fp,"-----------------------------------------\n");
while(p1!=NULL)
{
fprintf(fp,"%d\t%s\t%.1f\t%.1f\t%.1f\t\n",p1->number,p1->name,p1->computer,p1->english,p1->math);
p1=p1->next;
}
fclose(fp);
printf("文件已經保存!\n");
return 0;
}
/*==============================================================================================*/
score *paixu(score *head) /*定義排序函數。此函數帶回一個指向鏈表頭的指針*/
{ score *p,*max;
int i,j,x;
float fen;
char t[10];
if(head==NULL)
/*鏈表為空*/
max=p=head;
for(i=0;i<80;i++)
printf("*");
printf("1按學生學號排序\t2按學生姓名排序\t3按計算機 成績排序\n");
printf("4按英語成績排序\t5按數學成績排序\t\n");
for(i=0;i<80;i++)
printf("*");
printf("請選擇操作:");
scanf("%d",&x);/*選擇操作*/
getchar();
switch(x)
{case 1 :
for(i=1;i<n;i++)
{
for(j=i+1;j<=n;j++)
{
max=p;
p=p->next;

if(max->number>p->number)
{
k=max->number;
max->number=p->number;
p->number=k;
strcpy(t,max->name);
strcpy(max->name,p->name);
strcpy(p->name,t);
fen=max->computer;
max->computer=p->computer;
p->computer=fen;
fen=max->english;
max->english=p->english;
p->english=fen;
fen=max->math;
max->math=p->math;
p->math=fen;
}
}
max=head;p=head;/*重新使max,p指向鏈表頭*/
}
print(head);break;
case 2 : for(i=1;i<n;i++)
{
for(j=i+1;j<=n;j++)
{
max=p;
p=p->next;
if(strcmp(max->name,p->name)>0)/*字元串比較*/
{
strcpy(t,max->name);/*字元串復制*/
strcpy(max->name,p->name);
strcpy(p->name,t);
k=max->number;
max->number=p->number;
p->number=k;
fen=max->computer;
max->computer=p->computer;
p->computer=fen;
fen=max->english;
max->english=p->english;
p->english=fen;
fen=max->math;
max->math=p->math;
p->math=fen;
/*交換前後結點中的數學成績,使之與姓名相匹配*/
}
}
p=head;
max=head;
}
print(head);
break;

case 3 : for(i=1;i<n;i++)
{for(j=i+1;j<=n;j++)
{max=p;
p=p->next;
if(max->computer>p->computer)
{
fen=max->computer;
max->computer=p->computer;
p->computer=fen;
k=max->number;
max->number=p->number;
p->number=k;
strcpy(t,max->name);
strcpy(max->name,p->name);
strcpy(p->name,t);
fen=max->english;
max->english=p->english;
p->english=fen;
fen=max->math;
max->math=p->math;
p->math=fen;
}
}
p=head;
max=head;
}
print(head);
break;

case 4 : for(i=1;i<n;i++)
{for(j=i+1;j<=n;j++)
{max=p;
p=p->next;
if(max->english>p->english)
{
fen=max->english;
max->english=p->english;
p->english=fen;
k=max->number;
max->number=p->number;
p->number=k;
strcpy(t,max->name);
strcpy(max->name,p->name);
strcpy(p->name,t);
fen=max->computer;
max->computer=p->computer;
p->computer=fen;
fen=max->math;
max->math=p->math;
p->math=fen;
}
}
p=head;
max=head;
}
print(head);
break;
case 5 : for(i=1;i<n;i++)
{for(j=i+1;j<=n;j++)
{max=p;
p=p->next;
if(max->math>p->math)
{
fen=max->math;
max->math=p->math;
p->math=fen;
k=max->number;
max->number=p->number;
p->number=k;
strcpy(t,max->name);
strcpy(max->name,p->name);
strcpy(p->name,t);
fen=max->computer;
max->computer=p->computer;
p->computer=fen;
fen=max->english;
max->english=p->english;
p->english=fen;
}
}
p=head;
max=head;
}
print(head);
break;
default :printf("輸入錯誤,請重試! \n");
}
return (0);}
/*==============================================================================================*/
int menu(k)/*函數menu,功能:菜單選擇界面*/
{
int i;
printf("\t\t\t\t學生信息管理系統\n");
for(i=0;i<80;i++)
printf("*");
printf(" \t\t\t1添加學生記錄\t\t\t \n");
printf(" \t\t\t2.顯示學生記錄\t\t\t \n");
printf(" \t\t\t3.刪除學生記錄\t\t\t \n");
printf(" \t\t\t4.查詢學生記錄\t\t\t \n");
printf(" \t\t\t5.統計學生記錄\t\t\t \n");
printf(" \t\t\t6.排序\t\t\t \n");
printf(" \t\t\t7.保存學生記錄\t\t\t \n");
/*菜單選擇界面*/
for(i=0;i<80;i++)
printf("*");
printf("請選擇您所要的操作(選擇(0)退出):");
scanf("%d",&k);/*選擇操作*/
getchar();
return (k);}
main()
{score *head=0,*stu=0;
while(1)
{k=menu(k);
switch(k)/*用switch語句實現功能選擇*/
{case 1: head=creat();break;/*調用創建鏈表函數*/
case 2: print(head); break;/*調用顯示學生信息函數*/
case 3: head=del(head); break;/*調用刪除學生信息函數*/
case 4: head=search(head);break;/*調用成績查詢函數*/
case 5: tongji(head); break;/*調用統計函數*/
case 6: paixu(head);break;/*調用排序函數*/
case 7: save(head);break;/*調用保存函數*/
case 0: exit(0);/*退出系統,返回主界面*/
default: printf("輸入錯誤,請重試!\n"); }
}

自己套了修改!

另外,虛機團上產品團購,超級便宜

C. vs2010基於對話框的MFC界面設計

OnCtlColor函數可以設置對話框的顏色,那麼可以在按鈕消息函數裡面給一個變數設置新的顏色回值,然後重繪對話框答,那麼OnCtlColor函數會被調用,調用OnCtlColor函數的時候使用前面按鈕消息函數裡面設置的顏色值設置對話框顏色。

D. C++ MFC 程序結構應該怎麼設計

vc6新建一個Win32 Application空工程,然後添加一個cpp文件,輸入 (注意添加對話框資源,並且在對話框上添加一個文本框)

E. MFC主要是用來設計界面的嗎

MFC,Microsoft Foundation Class,中文叫微軟基礎類
它對windows的api進行了封裝,把他們做成類,方便用戶使用
它不專光有界面的類,也屬有網路等其他的類

它只在VC6中使用,使用起來也不是很方便
VS2005或後續的VS2008,對它又進行了改進
所以可以這么說:VS2008設計界面,比MFC更簡單

F. vs2010 mfc應用程序 界面設計

首先復你要建一個基於對話框的制工程, 然後在屏幕的最右邊有一個toolbox, 那個就相當於vc的控制項列表,比如你新建一個按鈕,然後右鍵點屬性,出來一個屬性對話框,上面有一個閃電圖標的選項卡,那個就是添加消息響應

G. VS2012的MFC應用中怎麼打開圖形設計界面

找到資源文件 然後雙擊IDD開頭的那個就有了

拓展資料


Visual Studio是微軟公司推出的開發環境。是最流行的專Windows平台屬應用程序開發環境。2012年9月12日微軟在西雅圖發布Visual Studio 2012。其實早在8月16日Visual Studio 2012和.NET Framework4.5已經可以下載,微軟負責Visual Studio部門的公司副總裁Jason Zander還發表博客,列舉了升級到Visual Studio 2012版的12大理由。當時還主要是分發給MSDN訂閱用戶。

資料來源 網路Visual Studio 2012

H. VC++ MFC 設計繪圖程序

在你的主框架的里添加該消息。添加響應函數on();
CMainFrameWnd::On(UINT flag,POINT piont){
CDC *dc=this->GetActiveView()->getDC();//獲取視圖的專DC
//也可以這樣CDC *dc=this->getDC();這樣的是獲屬取框架的DC;
dc->TextOut(0,0,"預祝大家學習愉快",9);
this->ReleaseDC();
}
獲取主框架的或者視圖的DC相差不大。你試試看,這個沒有去編譯,你自己看看那羅,完全手寫

I. VS2010基於對話框的MFC界面設計

在新對話框的初始化中加
::SetParent(新對話框句柄,NULL); 試一下

J. MFC的設計裡面到底有什麼是比較優秀的嗎

優秀來是個相對的詞。沒有比源較對象的話,談優秀沒有意義。這里假設你的比較對象是ATL、Windows Forms、WPF這樣的Windows類庫。
MFC是微軟出的唯一一個能算應用程序框架的東西,是用來集成其他模塊的。比如內建了ATL和Windows Forms支持,也支持用MFC擴展DLL來進行模塊化開發。相對之下,ATL是做組件的框架,而WinForms、WPF都不過是界面層而已。
MFC的OLE支持雖然有20年沒怎麼改了,但是直到現在都是做的最好的沒有之一。創建MFC項目的時候選擇一個復選框就可以讓自己的文檔能夠像Word和Adobe PDF Reader一樣在瀏覽器裡面顯示了,要在新創建的項目里集成這樣的活動文檔也就是一個復選框的事情。相比之下,VB、VFP、.Net的OLE支持都弱爆了。MFC的實現代碼是給人看的,同時還有一部分教育功能。相比之下,VC里模板套模板的STL代碼就不是給人看的……至少不是給一般人看的,微軟做C++ Runtime的人都說看不懂。

作者:蔣晟

熱點內容
美發店認證 發布:2021-03-16 21:43:38 瀏覽:443
物業糾紛原因 發布:2021-03-16 21:42:46 瀏覽:474
全國著名不孕不育醫院 發布:2021-03-16 21:42:24 瀏覽:679
知名明星確診 發布:2021-03-16 21:42:04 瀏覽:14
ipad大專有用嗎 發布:2021-03-16 21:40:58 瀏覽:670
公務員協議班值得嗎 發布:2021-03-16 21:40:00 瀏覽:21
知名書店品牌 發布:2021-03-16 21:39:09 瀏覽:949
q雷授權碼在哪裡買 發布:2021-03-16 21:38:44 瀏覽:852
圖書天貓轉讓 發布:2021-03-16 21:38:26 瀏覽:707
寶寶水杯品牌 發布:2021-03-16 21:35:56 瀏覽:837