Home » U++ Library support » Menus&Toolbars » ToolBar Callback weirdness
ToolBar Callback weirdness [message #35273] |
Sat, 28 January 2012 00:48  |
 |
Alboni
Messages: 216 Registered: January 2012 Location: Kajaani, Finland
|
Experienced Member |
|
|
I created the next example to show off a problem I'm having with my app: (project added in zipfile)
For some reason the variable 'tool' is always 1 in the function ToolBarContent (callback for filling the toolbar) while it has the correct values everywhere else.
Is there some multithreading issue going on? I tried making 'tool' volatile but that didn't help. Changing to multithreading library didn't change it either.
(I use Visual C++ 2010 Express)
------------example--------------
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
#define IMAGEFILE <bartest/bartest.iml>
#define IMAGECLASS bartest
#include <Draw/iml.h>
struct BarTest: TopWindow {
ToolBar toolbar;
int tool;
typedef BarTest CLASSNAME;
BarTest()
{
tool=1;
AddFrame(toolbar.Left());
toolbar.Set(THISBACK(ToolBarContent));
}
virtual void Paint(Draw& w)
{
char s[80];
w.DrawRect(GetSize(), Gray());
sprintf(s,"tool=%d",tool); // yeah I know
w.DrawText(200,220,s);
}
void MoveClicked()
{
tool=1;
Refresh();
}
void RotateClicked()
{
tool=2;
Refresh();
}
void ToolBarContent(Bar& bar)
{
bar.Add("Move", bartest::move(), THISBACK(MoveClicked)).Check(tool==1);
bar.Add("Rotate", bartest::rotate(), THISBACK(RotateClicked)).Check(tool==2);
}
};
GUI_APP_MAIN
{
BarTest().Run();
}
-
Attachment: bartest.zip
(Size: 2.91KB, Downloaded 369 times)
[Updated on: Sat, 28 January 2012 00:53] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Fri May 16 14:16:52 CEST 2025
Total time taken to generate the page: 0.02963 seconds
|