Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » Menus&Toolbars » ToolBar Callback weirdness
ToolBar Callback weirdness [message #35273] Sat, 28 January 2012 00:48 Go to previous message
Alboni is currently offline  Alboni
Messages: 214
Registered: January 2012
Location: Deventer, Netherlands
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 316 times)

[Updated on: Sat, 28 January 2012 00:53]

Report message to a moderator

 
Read Message
Read Message
Read Message
Previous Topic: How do I create vertical toolbars
Next Topic: Popup menu with check items
Goto Forum:
  


Current Time: Thu Mar 28 10:15:51 CET 2024

Total time taken to generate the page: 0.01392 seconds