Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 4 of 4

Multiple Forms Problem

This is a discussion on Multiple Forms Problem within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hi, This must have been discussed before, but I couldn't find anything with the Search. I have MP2002 Control on ...

  1. #1
    andrem is offline Junior Member White Belt
    Join Date
    Apr 2003
    Posts
    7

    Multiple Forms Problem

    Hi,

    This must have been discussed before, but I couldn't find anything with the Search. I have MP2002 Control on a form. Whenever I show 2 modeless instances of the form, the focus/zorder goes funny - clicking on one form brings the other forward. This does not happen when I remove the OCXes, so it must be a control code bug? Here's my code: (Click on Cammand1 twice to open two instances of Form2 (with MapPoint OCX). Then try to click any of the instances. see what I mean? HELP!

    Form1:
    Option Explicit

    Private Sub Command1_Click()
    Dim frm As Form2

    Set frm = New Form2

    frm.Show vbModeless

    End Sub

    Form2:
    Option Explicit

    Private Sub Form_Initialize()

    MapViewer.NewMap geoMapEurope

    End Sub
    Cheers

    André

  2. #2
    Ninjas is offline Junior Member White Belt
    Join Date
    Aug 2003
    Posts
    4

  3. #3
    andrem is offline Junior Member White Belt
    Join Date
    Apr 2003
    Posts
    7
    Thanks Ninjas, but I know what a modeless dialog is. In this case I have a normal modeless forms. Replace the MapPoint control with a textbox, click the button twice, and it works fine. Add back mappoint ctl and do the same - the form that loses focus jumps to the top.
    Cheers

    André

  4. #4
    Martel is offline Junior Member Yellow Belt
    Join Date
    Feb 2003
    Posts
    28

    Multiple Forms Problem

    I noticed that the problem does not exist if you use an MDIForm and your Mappoint control in the child forms. However, you can imitate this somewhat using the following code. Be forwarned that whatever window is last activated will stay on top of all other applications as well as other windows in your current application!


    Create a module:
    Code:
    Public Declare Function FindWindow Lib "user32" _
    Alias "FindWindowA" _
     (ByVal lpClassName As String, _
      ByVal lpWindowName As String) As Long
    
    
    Public Declare Function SetWindowPos Lib "user32" _
     (ByVal iWinHandle As Long, _
      ByVal hWinInsertAfter As Long, _
      ByVal X As Long, _
      ByVal Y As Long, _
      ByVal cx As Long, _
      ByVal cy As Long, _
      ByVal uFlags As Long) As Long
    
    CONST TOPMOST = -1
    CONST NOMOVE = &H2
    CONST NOSIZE = &H1
    CONST NOCHANGE = NOMOVE OR NOSIZE
    
    Public Sub SetFormOnTop(frmHandle as long)
          Call SetWindowPos(frmHandle, -1, 0, 0, 0, 0, NOCHANGE)
    End Sub

    On your form (I think you used Form2 in your example, but you will need it on ANY form that you want to have focus while your application is running) :
    Code:
    Private Sub Form_Activate()
      'Debug.Print Me.Caption & " activated " & Me.hWnd
      Call SetFormOnTop(Me.hWnd)
    End Sub

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. multiple instance problem
    By pichan81 in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 06-06-2006, 03:05 PM
  2. Multiple Routes
    By wadams in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 11-17-2005, 10:28 AM
  3. Can I use Mappoint in Web forms in VB.NET?
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 4
    Last Post: 11-11-2004, 07:42 AM
  4. Event handling- Mappoint Control in VB forms
    By EasyCoder in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 05-27-2004, 08:10 PM
  5. MP 2002/2004 Major problem with non modal forms in VB6
    By neomoon in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 10-07-2003, 05:13 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25