keepITcool, I'm sure you 're correct. I just couldn't get the darn form to
repaint without all the RECT stuff, or the DrawMenuBar routine used by
Stephen Bullen.
Don't mean to sound defensive, but I was trying to get a quick answer to the
OP while waiting for a flight at the airport <g. As I acknowledged, it was
pretty ugly. Never thought about SetFocus.
Regards,
Vasant
"keepITcool" wrote in message
ft.com...
Vasant, I ink you overcomplicate things:
all the rectangles and setwindowpos can go.
after the SetWindowLong you just need a SetFocus
Declare Function SetFocus Lib "user32.dll" (ByVal hWnd As Long) As Long
--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam
Vasant Nanavati wrote :
If you don't mind some complicated API stuff:
Option Explicit
Private Declare Function FindWindowA Lib "user32" _
(ByVal lpClassName As String, ByVal lpWindowName _
As String) 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 GetWindowLong Lib "user32" _
Alias "GetWindowLongA" (ByVal hwnd As Long, _
ByVal nindex As Long) As Long
Private Declare Function SetWindowPos Lib "user32" _
(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
Private Declare Function GetWindowRect Lib "user32" ( _
ByVal hwnd As Long, lpRect As RECT) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Enum ESetWindowPosStyles
SWP_SHOWWINDOW = &H40
SWP_HIDEWINDOW = &H80
SWP_FRAMECHANGED = &H20
SWP_NOACTIVATE = &H10
SWP_NOCOPYBITS = &H100
SWP_NOMOVE = &H2
SWP_NOOWNERZORDER = &H200
SWP_NOREDRAW = &H8
SWP_NOREPOSITION = SWP_NOOWNERZORDER
SWP_NOSIZE = &H1
SWP_NOZORDER = &H4
SWP_DRAWFRAME = SWP_FRAMECHANGED
HWND_NOTOPMOST = -2
End Enum
Private Const WS_SYSMENU = &H80000
Private Const WS_CAPTION = &HC00000
Private Const GWL_STYLE = (-16)
Private Sub UserForm_Initialize()
Dim lStyle As Long, hwnd As Long, tR As RECT
hwnd = FindWindowA(vbNullString, Me.Caption)
GetWindowRect hwnd, tR
Me.Caption = ""
lStyle = GetWindowLong(hwnd, GWL_STYLE)
lStyle = lStyle And Not WS_SYSMENU
lStyle = lStyle And Not WS_CAPTION
SetWindowLong hwnd, GWL_STYLE, lStyle
SetWindowPos hwnd, _
0, tR.Left, tR.Top, _
tR.Right - tR.Left, tR.Bottom - tR.Top, _
SWP_NOREPOSITION Or SWP_NOZORDER Or SWP_FRAMECHANGED
Me.Repaint
End Sub
Kind of ugly but I just slapped it together from a variety of sources.
I'm assuming you have some OnTime code to dismiss the form.