CallBack Functions

This is a discussion on CallBack Functions within the Windows Programming forums, part of the Platform Specific Boards category; I am playing around with Event handling and I am trying to make my own menu in a Win32 console. ...

CallBack Functions

I am playing around with Event handling and I am trying to make my own menu in a Win32 console. I have an event pump
but I am getting a little confused when it comes to event model vs callback model and how I would implement them.

I have a basic skeleton program that I am using to write test programs. Perhaps my design is flawed.

Under a callback design, you access the function via a function pointer. Under an event design, you signal an event. Depending on the programming language and OS, the message queue dispatches the message to the appropriate module.

Thanks Kuphryn. I understand that a callback model uses function pointers. I am trying to understand the process so I am attempting to create a model. I have an event pump that reads in messages from the the keyboard and mouse. The event handler (a switch statement) basically filters the input and executes some function accoding to the event MOUSE_MOVED, or FROM_LEFT_1st_BUTTON_PRESSED, so do I just replace the functions in the switch statement with function pointers? DOH I don't create any new events. So I need to define my own events either with an enumeration or const. IE(const MY_EVENT=1).
Then write that back to the input buffer? is that right?

Scenerio: We have a file menu with selections for open save save as and quit;

Normally the menu will be closed be a single line at the top of the screen with the word File
the title of the menu.

Now the MOUSE_MOVED event would test for the location of the mouse to see if it is over the file menu.

Once the mouse is moved over the file menu then the MOUSE_MOVED event would load
the function_ptr for the FROM_LEFT_1ST_BUTTON_PRESSED to ppoint to the function that calls openmenu() so when you click the buttom it opens the Filemenu. If you move off from the File menu it swithes the function_ptr back.

After the menu is open then the MOUSE_MOVED event would test for the location of
each selection and repeat the above sequence of events. Wehen moved outside the area of the menu the menu would close automatically

Does this sound right?

[edit]
NeverMind When the person clicks on the menu it sends the location of the mouse so
i don't need to test continually in MOUSE_MOVED event.

I am trying to add a File menu to this project. I was making an ascii art editor to make maps for a text based console game. I thought it would be simple to add a menu but I am finding it frustrating. It is crude you press F1 to bring up the ascii symbols and colors. You just click on the symbol and left click on color for foreground and rightclick on color for background. I want to be able to save the finished artwork to a file and also to load so I thought I would add a menu.