PC Review


Reply
Thread Tools Rate Thread

Code locking up until I press the reset button

 
 
Bishop
Guest
Posts: n/a
 
      3rd Jun 2009
I have the following code:

'the following code is for the first userform that displays on _open

Option Explicit

Const GWL_STYLE = -16
Const WS_CAPTION = &HC00000
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As
Long
Private Declare Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function FindWindowA Lib "user32" (ByVal lpClassName As
String, _
ByVal lpWindowName As String) As Long

Private Sub Userform_Initialize()

Dim lngWindow As Long, lFrmHdl As Long

lFrmHdl = FindWindowA(vbNullString, Me.Caption)
lngWindow = GetWindowLong(lFrmHdl, GWL_STYLE)
lngWindow = lngWindow And (Not WS_CAPTION)

Call SetWindowLong(lFrmHdl, GWL_STYLE, lngWindow)
Call DrawMenuBar(lFrmHdl)

End Sub

'The code above does nothing more than display the userform without a title
bar

Private Sub AddButton_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)

Dim A As Integer

If Chr(KeyCode) = "A" Then
AddTitle.Show
End If

End Sub

'the following code is for the next userform that displays when you hit the
A key

Option Explicit

Const GWL_STYLE = -16
Const WS_CAPTION = &HC00000
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As
Long
Private Declare Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function FindWindowA Lib "user32" (ByVal lpClassName As
String, _
ByVal lpWindowName As String) As Long

Private Sub Userform_Initialize()

Dim lngWindow As Long, lFrmHdl As Long

lFrmHdl = FindWindowA(vbNullString, Me.Caption)
lngWindow = GetWindowLong(lFrmHdl, GWL_STYLE)
lngWindow = lngWindow And (Not WS_CAPTION)

Call SetWindowLong(lFrmHdl, GWL_STYLE, lngWindow)
Call DrawMenuBar(lFrmHdl)

End Sub

When I step through this code it works BUT once the AddTitle userform (the
last userform) displays I can't Alt-F11 to get back to VBE. I can manually
get there with the mouse but once there I have to hit the reset button to
access my code again. Why am I hanging up?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reset button code for Radio Buttons dworst@gaic.com Microsoft Excel Misc 5 6th Apr 2008 11:12 PM
Need code to press a button after un hiding form Sierras Microsoft Access Forms 4 9th Jul 2007 06:57 PM
How do I press a command button in code? =?Utf-8?B?RGFycmVsbCBXZXNsZXk=?= Microsoft VB .NET 13 27th Sep 2005 01:29 PM
Reset button code John Microsoft ASP .NET 1 8th Oct 2004 02:20 AM
how to know the user press the left button and the right button at the same time? vulgate Microsoft C# .NET 1 18th Nov 2003 08:21 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:06 PM.