?
Solved

[VB6/SP5] Why can't show the form vbModal?

Posted on 2003-03-31
8
Medium Priority
?
444 Views
Last Modified: 2010-04-07
hi,
    I have a case in which I can't show a form vbModal,

    Suppose I have three forms: Form1, Form2, Form3

     Form1 have a popup menu(MainMenu1): the action of the only menu item(SubMenu1_1) is 'Form2.show vbModal';
     Form2 have a popup menu(MainMenu1): the action of the only menu item(SubMenu1_1) is 'Form3.show vbModal';  
 
     the code list below:  

     Form1:
        ...
        Private Sub Form1_MouseDown()
            PopupMenu MainMenu1
        End Sub

        Private Sub  SubMenu1_1_Click()        
            Form2.Show vbModal
        End sub
        ....
   
     Form2:
        ...
        Private Sub Form2_MouseDown()
            PopupMenu MainMenu1                 ' here is the problem, it is executed, but no effection. That is, no menu is

popup.
        End Sub

        Private Sub  SubMenu1_1_Click()        
             Form3.Show vbModal                
        End sub
        ...

    Any suggestion or idea will be appreciated.

   -------
      lr

0
Comment
Question by:LuRen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 8242988
is there a Menu Object called MainMenu1 in Form2? or you want to call the Menu MainMenu1 from Form1?

if yes then try this instead:

PopupMenu Form1.MainMenu1

regards
0
 
LVL 1

Author Comment

by:LuRen
ID: 8243130
ryancys,
    Form1 has a menu named MainMenu1 (Private), and Form2 has a menu named MainMenu1 (Private), too.

    -- lr
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 8243547
You can only show 1 form modal.
Because you call form2 vbmodal, you can't show another form modal, even not a popupmenu (because it's also seen as a form)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Accepted Solution

by:
marconovaro earned 80 total points
ID: 8243790

This is a known bug that also caused headache to me... :-)
Here is the solution:

"BUG: PopupMenu on Modal Form Not Displayed"
http://support.microsoft.com/default.aspx?scid=kb;en-us;167839


Hope this helps
M
0
 
LVL 5

Expert Comment

by:avya2k
ID: 8243827
        'Keeps current form on top replace form1 with current form name
         lR = SetTopMostWindow(Form1.hwnd, True)
         'removes current top from on top position
         lR = SetTopMostWindow(Form1.hwnd, False)
 
On the Project menu, click Add Module, to add a new module to the project.


Add the following code to the new module:



      Option Explicit
      Public Const SWP_NOMOVE = 2
      Public Const SWP_NOSIZE = 1
      Public Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
      Public Const HWND_TOPMOST = -1
      Public Const HWND_NOTOPMOST = -2

      Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos"  _
            (ByVal hwnd As Long, _
            ByVal hWndInsertAfter As Long, _
            ByVal x As Long, _
            ByVal y As Long, _
            ByVal cx As Long, _
            ByVal cy As Long, _
            ByVal wFlags As Long  ) As Long

      Public Function SetTopMostWindow(hwnd As Long, Topmost As Boolean) _
         As Long

         If Topmost = True Then 'Make the window topmost
            SetTopMostWindow = SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, _
               0, FLAGS)
         Else
            SetTopMostWindow = SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, _
               0, 0,FLAGS)
            SetTopMostWindow = False
         End If
      End Function
 

0
 
LVL 5

Expert Comment

by:avya2k
ID: 8243831
this is equivalent of vbmodal without errors
0
 
LVL 1

Author Comment

by:LuRen
ID: 8252251
Thx a lot.  now the popupmenu is available.


 --
   lr

   
0
 
LVL 1

Author Comment

by:LuRen
ID: 8252264
ryancys,Dhaest,avya2k
 
    Thank your help , too.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month10 days, 7 hours left to enroll

764 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