Community of MapPoint and Virtual Earth Users and Developers
This is a discussion on Solution: Server busy window after popup context menu. within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; Hi, I that a lot users on the forum have this problem. When you popup a context menu, or some ...
| |||||||
| Today's Posts | Twitter Feed | Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Solution: Server busy window after popup context menu. When you popup a context menu, or some dialog from an event fired from MapPoint, you get a "Server busy" message after 10 seconds. Realy annoying, it allways happens when you demo your code to your boss. I found my own (imho nicer than sending "esc" char after 9 seconds) solution. You can have your context menu longer open than 10 seconds without problems. This solution is for C# (so .NET), but it it is just the concept. Make a timer that sets off after 1 msec. and two variables that hold the mouse position. Code: private System.Windows.Forms.Timer showContextMenuTimer; private int mouseYloc, mouseXloc; // This timer is used to popup a context menu, when // an user has right clicked a symbol on the map showContextMenuTimer = new Timer(); showContextMenuTimer.Tick+=new EventHandler(showContextMenuTimer_Tick); showContextMenuTimer.Interval=1; Code: private void showContextMenuTimer_Tick(object sender, EventArgs e)
{
showContextMenuTimer.Stop();
// insert your contextMenu.show routine here...
subscriberMenu.Show(this,new Point(mouseXloc+180,mouseYloc+10));
}
showContextMenuTimer.Start(); Code: private void axMappointControl1_BeforeClick(object sender, AxMapPoint._IMappointCtrlEvents_BeforeClickEvent e)
{
if(e.button==2) // right click
{
e.cancel=true;
mouseXloc = e.x; // used in the Timer.Tick event
mouseYloc= e.y;
showContextMenuTimer.Start();
}
}
have fun with it! |
| |||
|
Hi, Thanks for feedback Yes this is a good idea. The problem is not threading, the timer's tickis executed in same thread context, but the difference is that the code is executed outside the event. This explains more. A menu is nothing else than a modal form, so displaying a modal form in the event will block mappoint. So when you do it outside it then all is ok. wonderfull idea A better approach should be to not use a timer but post a message to the form with the x, y parameters. In de WndProc method there you pop the menu . If someone wants example I be glad to post it of course !
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
|
Hmm, if it is not too much work, could you post an example? I'm not really understanding what you mean with "post wndproc message to the form". (I've learned java and standard c++ so i'm not really into window messages) |
| |||
|
Hi, Ok here is example and I try to explain (my english is not so well The whole windows thing is based on messages. When you move your mouse over a form thousands of them are sent to it with the x,y coordinates, same if you pull down a button on keyboard and if you lose it again. Messages are handled by each window by a so called message pump. Now you can also make custom message handlers. That is message handlers that does what you want. You need many times execute code outside of a loop or ouside an event (what we are gonna do). Also it is "the" system if you are in a thread and you want code execute in the thread context of a particular window that is created in another therad. A good example is the User interface. There are 2 importand ones, that is SendMessage and PostMessage. Both are doeing the same with the difference that SendMessage will block the thread until the custom message handler has finished while PostMesage is async and will return immediatly. In both of the code will execute as soon as the destination start pumping messages. So we define first our message. It has to be > WM_USER witch is 0x400.: Code: const int WM_POPUPMENU = 0x401; Code: private void popup(IntPtr x, IntPtr y)
{
// here you popup your menu
}
protected override void WndProc(ref Message m)
{
switch (m.Msg) {
case WM_POPUPMENU:
popup(m.WParam, m.LParam);
break;
default:
base.WndProc(ref m);
break;
}
}
and in the BeforeClick you post the message: Code: private void MP_BeforeClick_1(object sender, AxMapPoint._IMappointCtrlEvents_BeforeClickEvent e)
{
Win32.PostMessage(Handle, WM_POPUPMENU, e.x, e.y);
Code: public class Win32
{
[DllImport("User32.dll")]
public static extern Boolean PostMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
- beforclick post the message, since postmessage is async the event handler continue his work until it end - then the form start pumping messages again (because noting of your code is running) - the custom mssage handler is called and the window pups up I hope my explanation make sence
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| ||||
|
The original timer method is useful for VB though, I use this to fake multi-threading for batch processing in an add-in. Richard
__________________ Winwaed Software Technology LLC http://www.winwaed.com See http://www.mapping-tools.com for MapPoint Tools See the Geoweb Guru for online mapping |
| |||
|
Hi Richard, Quote:
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
![]() |
| Tags |
| busy, context, menu, popup, server, solution, window |
| ||||
| Posted By | For | Type | Date | |
| night.swimmer's bookmarks tagged with "mappoint" on del.icio.us | This thread | Refback | 06-20-2008 09:45 AM | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Disable Context menu | Anonymous | MapPoint 2006/2009 Discussion | 12 | 12-23-2008 12:05 PM |
| looking for Delphi solution for the "Server Busy" | schuchhardp | MapPoint 2006/2009 Discussion | 8 | 10-20-2008 04:04 AM |
| Custom context menu | Anonymous | MapPoint 2006/2009 Discussion | 3 | 09-10-2004 10:15 PM |
| Disable Mappoin 2002 PopUp Menu (using Vb.net) | Anonymous | MapPoint 2006/2009 Discussion | 0 | 08-19-2003 09:12 AM |
| Is there any way to disable Mappoint 2002 popup menu? | Anonymous | MapPoint 2006/2009 Discussion | 2 | 12-12-2002 05:21 PM |
Bodrum Holiday
Check out the picturesque towns on your Bodrum holiday... Book through UlookUbook!