Solved

Motif and C++

Posted on 1997-06-19
2
772 Views
Last Modified: 2013-12-26
I am trying to figure out Motif using C++.  I am having a difficult time getting callbacks to work.  I imagine there is some goofy pointer thing happening but I am not sure what.

I have a class MainMenu.  In that class I create some xmPushButtonGadgets.  Now I am trying to set up a call back
here is some code snippets
---
//MainMenu.h
...
protected:
void open(Widget, XtPointer, XtPointer);
...
------
//MainMenu.C

... Widget button;
  button=XtVaCreateManagedWidget("Open",xmPushButtonGadgetClass,_filePullDown,NULL);
  XtAddCallback(button,XmNactivateCallback,&MainMenu::open,NULL);
...

I can not figure out what to pass in for the callback function name.  Everything I have tried generates some goofy error.  This generates the following error

"MainMenu.c++", line 67: error(3252): argument of type
          "void (MainMenu::*)(Widget, XtPointer, XtPointer)" is incompatible
          with parameter of type
          "XtCallbackProc)(Widget, XtPointer, XtPointer)"
    XtAddCallback(button,XmNactivateCallback,&MainMenu::open,NULL);

Thanks

Thought you might be interested to know that I can rack up all the points I want in the advertiser quiz thing by just hitting the back button.
0
Comment
Question by:micah
2 Comments
 
LVL 2

Accepted Solution

by:
lockhart earned 100 total points
ID: 1293545
You may need to typecast your callback to be an XtCallbackProc. This is a C++ thing, in C it wouldn't particularly care. You also don't need the "&" before your routine name. By definition, a routine name is an address if it isn't followed by parens just like a class name is considered to be a type declaration for an instance if it isn't followed by parens.

Just removing the "&" may reduce this to a warning, but something like:

XtAddCallback (button,
               XmNactivateCallback,
               (XtCallbackProc)MainMenu::open,
               NULL);

will probably let the compiler stick the proper address into the activate callback slot.

Mike
0
 
LVL 4

Expert Comment

by:jos010697
ID: 1293546
If you want a nice C++ environment for Motif, mail
rvloon@xs4all.nl or ronald@and.nl. He's the maintainer
of the Motif++ layer. (there's a mailinglist for this stuff too)

kind regards,

Jos aka jos@and.nl (yes, ronalds desk is opposite of mine ;-)
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question