问题描述
我在这里有两个问题.
我已经使用c ++创建了一个表单,并在将其发送给我的朋友时发送了一个exe文件,表单大小各异且图片对齐不正确.即使将表单发送给其他人也如何保持表单不变.
第二个问题.我已经使用c ++和tab contols创建了一个表单.在tabpage1中包含5个按钮和文本框,当您单击button时,将打开其中包含button的form2.当按下表单中的按钮时,应在form1的文本框中显示您已单击form2"之类的文本.当我添加form1时.在form2代码中.它显示错误.解决这两个问题所需的帮助
I have two question here .
I have created a form using c++ and send an exe file to my friend when i send it the form size varies and picture is alignment is not proper . How to keep the form constant even when you send it to other people .
Second question . I have created a form using c++ with tab contols . In the tabpage1 contains 5 buttons and textbox when you click on button it will open form2 which contains button . When the button in form is pressed textlike"you have clicked on form2" should be displayed on textbox in form1 . When i add form1. in the form2 code . It shows error . Help needed for both problems
推荐答案
// file IButtonCallback.h
class IButtonCallback {
public:
virtual void OnForm2Button1Pressed() = 0;
};
// file mainwnd.h
#include "IButtonCallback.h"
class MainWnd : public CWnd, IButtonCallback {
// ...
void OnForm2Button1Pressed();
};
// file mainwnd.cpp
MainWnd::MainWnd(/*...*/) { // constructor
form2.SetCallback(this);
// ...
}
void MainWnd::OnForm2Button1Pressed() {
form1.SetText(_T("Button pressed!"));
}
// file form1.h
class Form1 : public CWnd {
// ...
void SetText(TCHAR* text);
};
// file form2.h
#include "IButtonCallback.h"
class Form2 : public CWnd {
// ...
void SetCallback(IButtonCallback* cb);
void OnButtonPressed();
private:
IButtonCallback* m_cb;
};
// file forms.cpp
void Forms::SetCallback(IButtonCallback* cb) {
m_cb = cb;
}
void Form2::OnButtonPressed() {
m_cb->OnForm2Button1Pressed();
}
这篇关于如何保持表格大小不变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!