vc++如何刷新VIEW窗口

vc++如何刷新VIEW窗口,第1张

1、实现模式对话框的OnOk()函数,在其中添加下面的代码就可以了:

((C***View)(AfxGetMainWnd()->GetActiveView()))->Invalidate()

其中C***View替换为告局局你自己的View类的名字。

2、调用Invalidate()只是实现了刷新显示而已,至于如何实现图片大小的更新,仍需要其他代码(比如在腊枣View类中添加代表图片大小的成袜让员变量,在OnDraw()中按照成员变量绘制图片,在OnOK()中更新View成员变量的值)。

//脊咐数CreateList_L.cpp

//To create a LinkList

#include <stdlib.h>

#include <iostream.h>

#include <conio.h>

# define TRUE 1

# define FALSE 0

# define OK 1

# define ERROR 0

# define INFEASIBLE -1

# define OVERFLOW -2

typedef struct DuLNode

{ int data

struct DuLNode *prior

struct DuLNode *next

}DuLNode,*DuLinkList

// 初始条件:L已存在。 *** 作结果:返回L中数据元素个数

int ListLength(DuLinkList L)

{

int i=0

DuLinkList p=L->next// p指向第一个结点

while(p!=L) // p没到表头

{

i++

p=p->next

}

return i

}

// 由双链循环线性表L的头结点出发,正序输出每个数据元素

void ListTraverse(DuLinkList L)

{

DuLinkList p=L->next

while(p!=L)

{

cout<<简笑p->data<<"\t"

p=p->next

}

cout<<endl

}

// 由双链循环线性表L的头结点出发,逆序输出每个数据元素

void ListTraverseBack(DuLinkList L)

{

DuLinkList p=L->prior

while(p!=L)

{

cout<<p->data<<"\t"

p=p->prior

}

cout<<endl

}

//To Creatre a DuLinkList L with HeadNode

void CreateList_DuL(DuLinkList &L)

{

int n

int i

DuLNode *p

L=(DuLinkList)malloc(sizeof(DuLNode))

L->next=L->prior=L

cout<<"CreateList_L"<<endl<<"================"<<endl

cout<<"Please input the Init DuLinkNode Number: <eg. 5>"

cin>>n

cout<<"Please input the data for DuLinkList Nodes: <eg. 34,67,3,-9,45,...>"<<endl

for(i=ni>0--i)

{

p=(DuLinkList)malloc(sizeof(DuLNode))

cin>>p->data //Reverse order inputing for Creating a LinkList

p->prior=L

p->next=L->next

L->next->prior=p

L->next=p

}

if(n)

{

cout<<endl

cout<<"Success to Create a DuLinkList !"<<endl

ListTraverse(L)

cout<<endl

}

else cout<<"A NULL DuLinkList have been created !"<<endl

}

//樱首ListInsert_Dul()

int ListInsert_DuL(DuLinkList &L)

{

DuLNode *p=L,*s

int j=0

int i

int e

cout<<"======"<<"before insert:"<<"======"<<endl

ListTraverse(L)

cout<<"input the location you want to insert:"

cin>>i

while (i<1||i>ListLength(L)+1)

{

//i值不合法

cout<<"illeagle location,please input the correct location:"

cin>>i

}

cout<<"input the number you want to insert:"

cin>>e

while(j<i)

{ p=p->next

++j

}

if(!(s=(DuLinkList)malloc(sizeof(DuLNode))))

{

cout<<endl<<"Allocate space failure ! "

return (ERROR)

}

s->data=e

s->prior=p->prior

s->next=p

if(i==1)

L->next=s

p->prior->next=s

p->prior=s

cout<<"has insert:"<<e<<endl

ListTraverse(L)

cout<<"======"<<"after insert:"<<"======"<<endl<<endl

return (OK)

}

// 删除带头结点的双链循环线性表L的第i个元素,i的合法值为1≤i≤表长

int ListDelete(DuLinkList L)

{

DuLinkList p

int j=1// j为计数器

int e

int i

cout<<"input the location of the number you want to delete"<<endl

cin>>i

while(i<0||i>ListLength(L))

{

//i值不合法

cout<<"illeagle location,please input the correct location:"

cin>>i

}

p=L->next// p指向第一个结点

while(p!=L&&j<i) // 顺指针向后查找,直到p指向第i个元素或p指向头结点

{

p=p->next

j++

}

if(p==L||j>i) // 第i个元素不存在

{

cout<<"第i个元素不存在"<<endl

return ERROR

}

else

{

cout<<"======"<<"before delete:"<<"======"<<endl

ListTraverse(L)

e=p->data// 取第i个元素

if(!p) // p=NULL,即第i个元素不存在

return ERROR

e=p->data

p->prior->next=p->next

p->next->prior=p->prior

free(p)

cout<<"has delete:"<<e<<endl

ListTraverse(L)

cout<<"======"<<"after delete:"<<"======"<<endl<<endl

return OK

}

}

void menu(int c)

{

cout<<"================================================="<<endl

cout<<"\t\t1----建立"<<endl

cout<<"\t\t2----插入"<<endl

cout<<"\t\t3----删除"<<endl

cout<<"\t\t4----逆置"<<endl

//cout<<"\t\t5----菜单"<<endl

cout<<"\t\t0----退出"<<endl

cout<<"================================================="<<endl

cout <<endl<<"input you choice number:"

}

void main()

{

DuLinkList L

int c=1

while(c!=0)

{

switch(c)

{

case 0:

break

case 1:

CreateList_DuL(L)

break

case 2:

ListInsert_DuL(L)

break

case 3:

ListDelete(L)

break

case 4:

ListTraverseBack(L)

break

default:

cout<<"infeasible choice,input again:"<<endl

menu(c)

cin>>c

}

if(c!=0)

{

menu(c)

cin>>c

}

}

}

1.首先你应该把DlgConnect s传巧迟给多线盯滚程函数

如下:

hThread=CreateThread(NULL,

0,

(LPTHREAD_START_ROUTINE)ThreadFunc,

pParam,//这里改为(void*)(&s)

0,

&ThreadID)

2.在函数孝则李UINT ThreadFunc(LPVOID pParam)中

删除掉DlgConnect s

把s.DoModal()

改为

(DlgConnect *)(pParm)->DoModal()


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/8199888.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-14
下一篇2023-04-14

发表评论

登录后才能评论

评论列表(0条)

    保存