Menus not working when i use ApplicationEx.Run

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

Hi,

I am using ApplicationEx.Run to show my main form. Then within the
main form, I show additional forms and dialogs using
ApplicationEx.ShowDialog. When I show one of the other forms it
displays just fine along with the secondary forms menu. However, i
cannot click on the menu of the newly displayed form. I have no idea
why. If I swith back to to showing the other forms using the
form.ShowDialog call, everything works fine but my message filter that
I set up for the main form no longer traps the events for the other
forms...

How should I be doing this?

Thank for you help,
Mark
 
You have to understand how things work underneath. The app get's a message
pump (an infinite GetMessage/DispatchMessage loop) when you call Run. This
pump is where all form messages (events) get processed and the the
IMessageFilter messages get intercepted.

When you call ShowDialog on the Form directly, the CF creates a new message
pump for that Form, and therefore nothing goes to the ApplicationEx's pump
and the filter is bypassed. That explains sceanrio 2.

Scenario 1 is more difficult. It sounds like the messages from the menu are
not getting received and dispatched by the pump. I'm not sure why - either
they're not getting received, or the pump believes they are for another pump
and is ignoring them. The best bet is to put some debug info or break
points in the pump and see what happens when you click a menu item. Do you
get any event? What are the incoming params if you do?

-Chris
 
ok, i know how to do this in C++ land, but I do I set a break in the
message loop for a C# form? Sorry, kind of new the the .NET stuff.

The fact that the device is giving me a very annoying sounding "beep"
makes me think something is definitely not right.


Mark.
 
ok, i know how to do this in C++ land, but I do I set a break in the
message loop for a C# form? Sorry, kind of new the the .NET stuff.

Add the SDF 1.4 source code projects to your solution then put a break point
in the ApplicationEx.Run method (actually IIRC there's a private method
called Pump that you could put it in that might be more appropriate).

-Chris
 
Back
Top