如何在 Bada 中传递控件作为参考?

发布于 2024-09-09 23:12:25 字数 906 浏览 2 评论 0原文

总体而言,我想在 Bada 中创建一个基于框架的应用程序,它具有单个 UI 控件 - 标签。到目前为止一切顺利,但我希望它显示我选择的数字并每 X 秒重复减少一次。线程很好(我认为),但我无法将标签指针作为类变量传递。

//MyTask.h 
//...
result Construct(Label* pLabel, int seconds);
//...
Label* pLabel;

//MyTask.cpp
//...
result
MyTask::Construct(Label* pLabel, int seconds) {
 result r = E_SUCCESS;
 r = Thread::Construct(THREAD_TYPE_EVENT_DRIVEN);
 AppLog("I'm in da constructor");
 this->pLabel = pLabel;
 this->seconds = seconds;

 return r;
}
//...

bool
Threading::OnAppInitializing(AppRegistry& appRegistry)
{
// ...

    Label* pLabel = new Label();
 pLabel = static_cast<Label*>(pForm->GetControl(L"IDC_LABEL1"));
 MyTask* task = new MyTask();
 task->Construct(&pLabel); // HERE IS THE ERROR no matching for Label**
 task->Start();

// ...
}

问题是我已经尝试了 *、& 的所有可能组合,以及组合学中已知的普通 pLabel...

我得到这个并不是非常重要(它只是用于训练),但我很想了解如何来解决问题。

In the big picture I want to create a frame based application in Bada that has a single UI control - a label. So far so good, but I want it to display a number of my choosing and decrement it repeatedly every X seconds. The threading is fine (I think), but I can't pass the label pointer as a class variable.

//MyTask.h 
//...
result Construct(Label* pLabel, int seconds);
//...
Label* pLabel;

//MyTask.cpp
//...
result
MyTask::Construct(Label* pLabel, int seconds) {
 result r = E_SUCCESS;
 r = Thread::Construct(THREAD_TYPE_EVENT_DRIVEN);
 AppLog("I'm in da constructor");
 this->pLabel = pLabel;
 this->seconds = seconds;

 return r;
}
//...

bool
Threading::OnAppInitializing(AppRegistry& appRegistry)
{
// ...

    Label* pLabel = new Label();
 pLabel = static_cast<Label*>(pForm->GetControl(L"IDC_LABEL1"));
 MyTask* task = new MyTask();
 task->Construct(&pLabel); // HERE IS THE ERROR no matching for Label**
 task->Start();

// ...
}

The problem is that I have tried every possible combination of *, &, and just plain pLabel, known in Combinatorics...

It is not extremely important that I get this (it is just for training) but I am dying to understand how to solve the problem.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

从来不烧饼 2024-09-16 23:12:25

您尝试过吗:

task->Construct(pLabel, 0);

我想指出您缺少 MyTask::Construct 的第二个参数。

Have you tried:

task->Construct(pLabel, 0);

And by that I want to point out that you are missing the second parameter for MyTask::Construct.

风启觞 2024-09-16 23:12:25

不,我没有。我不知道第二个参数。但这个问题已经解决了。如果我声明一个变量Object* __pVar,那么构造函数应该是Init(Object* pVar),如果我想初始化一个实例变量,我应该写

Object* pVar = new Object();
MyClass* mClass = new MyClass();
mClass->Construct(pVar);

No, I haven't. I don't know of a second parameter. But this problem is solved. If I declare a variable Object* __pVar, then the constructor should be Init(Object* pVar), and if I want to initialize an instance variable I should write

Object* pVar = new Object();
MyClass* mClass = new MyClass();
mClass->Construct(pVar);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文