?
Solved

protection fault on VB Menu

Posted on 2000-03-19
14
Medium Priority
?
159 Views
Last Modified: 2010-05-02
I have a form wich contain menu with the following items:

File
    Open
    Save

I also have a timer that call the property mnuFile.Visible = False

The problem is that if I press the File
and then place the mouse on the Open/Save sub menus, I have a "Protection Fault" the minute the timer call it's property.

How do I solve it?
 
0
Comment
Question by:ofirg
[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
  • 5
  • 4
  • 3
  • +2
14 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 2633616
I couldn't reproduce your problem; in fact when I was on the Open/Save menus, and the timer did the File menu unvisible, the submenu remained visible until i clicked it, but not Protection Fault. There must be something else.

ET: more input, more input
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2633777
I couldnt reproduce it either
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2633795
actually i found where i could get an error...if i had the menu open and then when file disappeared, if I tried to move the mouse while file was missing it would crash the program.  
0
Independent Software Vendors: 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 28

Expert Comment

by:Ark
ID: 2634202
Hi
Sorry, if I don't understand question, but what's about:
Private Sub mnuFile_Click ()
  Timer1.Enabled = False
End Sub

Cheers
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2634515
I was able to reproduce the Fault in VB5.  By calling PopupMenu before hiding the menu stops the crash:

Option Explicit

Private Sub Form_Load()
    Timer1.Enabled = False
    Timer1.Interval = 1000
End Sub

Private Sub mnuFile_Click()
    Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
    PopupMenu mnuFile
    mnuFile.Visible = False
    Timer1.Enabled = False
End Sub
0
 
LVL 1

Author Comment

by:ofirg
ID: 2636645
The PopUpMenu opens all the time
and as a meter of fact have nothing to do with the problem!
Sorry.
0
 
LVL 1

Author Comment

by:ofirg
ID: 2636646
This question has a deletion request Pending
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2637045
This question no longer is pending deletion
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2637046
Can you post the code you are using?
It is unusual to hide a menu while it is opened, if in fact this is what you are doing.

Without knowing more about what you are trying to do, everyone is speculating.

Perhaps you noticed the menu popup all the time because you did not disable the timer once the menu was hidden.

Private Sub Timer1_Timer()
    PopupMenu mnuFile
    mnuFile.Visible = False
    'Disable timer
    Timer1.Enabled = False
End Sub
0
 
LVL 1

Author Comment

by:ofirg
ID: 2637102
Ok... let us be more specific.

How can I refresh the menu with API call

I think this will close all the open sub
menus.


0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2637199
i tried the popup menu option that Erick posted and it closed the submenus for me...only thing to change is to allow for the File menu option to become visible again
0
 
LVL 32

Accepted Solution

by:
Erick37 earned 300 total points
ID: 2637742
Send the WM_CANCELMODE message to your window to close the opened submenus:

Option Explicit

Const WM_CANCELMODE = &H1F
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    (ByVal hwnd As Long, ByVal wMsg As Long, _
    ByVal wParam As Long, lParam As Any) As Long

Private Sub Command1_Click()
    mnuFile.Visible = True
    mnuFile.Enabled = True
End Sub

Private Sub Form_Load()
    Timer1.Enabled = False
    Timer1.Interval = 1000
End Sub

Private Sub mnuFile_Click()
    Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
    Call SendMessage(Me.hwnd, WM_CANCELMODE, 0, 0)
    mnuFile.Enabled = False
    mnuFile.Visible = False
    Timer1.Enabled = False
End Sub

0
 
LVL 32

Expert Comment

by:Erick37
ID: 2638051
I noticed you have a duplicate question open regarding MDI menus.  If your menu appears on the MDIMain form, you have to cancel that dropdown by calling:

Call SendMessage(MDIForm1.hwnd, WM_CANCELMODE, 0, 0)
0
 
LVL 1

Author Comment

by:ofirg
ID: 2639324
Cool! the menu refresh did help!

Joy and Happiness...
0

Featured Post

Independent Software Vendors: 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!

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month9 days, 11 hours left to enroll

762 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