Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 449
  • Last Modified:

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

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
LuRen
Asked:
LuRen
1 Solution
 
Ryan ChongCommented:
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
 
LuRenAuthor Commented:
ryancys,
    Form1 has a menu named MainMenu1 (Private), and Form2 has a menu named MainMenu1 (Private), too.

    -- lr
0
 
DhaestCommented:
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!

 
marconovaroCommented:

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
 
avya2kCommented:
        '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
 
avya2kCommented:
this is equivalent of vbmodal without errors
0
 
LuRenAuthor Commented:
Thx a lot.  now the popupmenu is available.


 --
   lr

   
0
 
LuRenAuthor Commented:
ryancys,Dhaest,avya2k
 
    Thank your help , too.
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now