在多种形式之间切换

在多种形式之间切换

本文介绍了在多种形式之间切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

pls帮助....通过Internet搜索,但没有超过2种形式之间切换的示例....

我有3种形式,形式a,b,c;
我想这样,形成一个可以切换到形成b和c的形式,
形式b可以转换为a和c,形式c可以转换为a和b.

因为形式a是我的主要形式..我从其他形式转换成形式a ...没有问题(我使用this-> hide()来显示形式a);
但是当我使用c表格时,我想显示b表格吗?如果我包含b.h表格,那么我
当我想从表单b切换到表单c时遇到了问题.我无法在表单b中包括表单c.h ....

任何使我所有表单都可以自由切换的方法?

pls help....search through internet but no example on switch between more than 2 forms....

i had 3 form ,form a,b,c;
i want to make it like this,form a can switch to form b and c,
form b can switch to form a and c,form c can switch to form a and b.

as form a is my main form..i had no problem to switch from other form to form a...(i use this->hide() to show form a);
but when i in form c,i want to show form b,how?if i include form b.h then i
had problem when i wan to switch to form c from form b..i cant include form c.h in my form b ....

any method to make all my form can freely switch between?

推荐答案

ref class ToggleForm
{
public:
    ToggleForm(void)
    {
        current = 0;
        //formlist = gcnew ArrayList()
    };
    void addForm(Form^ form)
    {
        formlist.Add(form);
    };
    void next(void)
    {
        moveToForm(1);
    };
    void previous(void)
    {
        moveToForm(-1);
    };
private:
    int current;
    ArrayList formlist;

    void moveToForm(int movement)
    {
        Form^ currentForm = (Form^)formlist[current];
        currentForm->Visible = false;
        current = (formlist.Count + current + movement) % (formlist.Count);
        Form^ nextForm = (Form^)formlist[current];
        nextForm->Visible = true;
    };

};



在第一个表单的负载中,我创建了其他表单,将它们添加到ToggleForm类中,并为每个表单提供对toggleForm的引用.我只是简单地两次使用了所谓的OtherForm,但是它当然可以是任何其他形式.



In the load of the first form I create the other forms, add them to the ToggleForm class and give each a reference of toggleForm. I simply used the so called OtherForm twice but of course it can be any other form.

toggleForm = gcnew ToggleForm();
toggleForm->addForm(this);
OtherForm^ otherFormB = gcnew OtherForm;
otherFormB->Text = "B";
OtherForm^ otherFormC = gcnew OtherForm;
otherFormC->Text = "C";
toggleForm->addForm(otherFormB);
toggleForm->addForm(otherFormC);
otherFormB->toggleForm = toggleForm;
otherFormC->toggleForm = toggleForm;



表单上的按钮仅调用ToggleForm对象的上一个和下一个函数,这将处理表单的隐藏和显示.

您也可以从以下位置下载此简单的示例项目:
http://orion.woelmuis.nl/FormToggleExampleProject.zip [ ^ ]

好吧,这可能会让您对如何实现这种机制有足够的了解.

祝您好运!



The buttons on the form simply call the previous and next functions of the ToggleForm object and this handles the hiding and showing of the forms.

You can also download this simple example project at:
http://orion.woelmuis.nl/FormToggleExampleProject.zip[^]

Well, this probably will give you enough idea about how to implement such a mechanism.

Good luck!




这篇关于在多种形式之间切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 03:35