strange window behaviour in SW x64
strange window behaviour in SW x64
(OP)
I have some VB programs and some VBA programs to help me with my work. They worked fine in SW2009 x32. After I upgraded to SW2009x64 (Windows XP) they started this annoying behaviour that the window they open goes to the bottom of the windows on my screen and I have to dig for it. Same behaviour in SW2010 x64 on Windows 7. I checked one of Tick's programs and it does the same thing. Has anyone encountered this problem and has a solution? I have SW2009 x64 installed at home on Windows Vista and don't have this issue.






RE: strange window behaviour in SW x64
RE: strange window behaviour in SW x64
RE: strange window behaviour in SW x64
RE: strange window behaviour in SW x64
RE: strange window behaviour in SW x64
http://
RE: strange window behaviour in SW x64
CODE
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 FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Dim res As Long
Dim lRet As Long
Const SWP_NOMOVE As Long = 2
Const SWP_NOSIZE As Long = 1
Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Const HWND_TOPMOST As Long = -1
Const HWND_NOTOPMOST As Long = -2
and in main() or form_load() in my case, right at the end:
CODE
res = SetWindowPos(lRet, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
RE: strange window behaviour in SW x64
This is sofar my best solution.
Every time i have a messagebox i then have to redo it.
CODE
UserForm_Layout
CODE
Const FLAG = SWP_NOSIZE + SWP_NOMOVE
Dim hWndForm As Long
On Error Resume Next
hWndForm = FindWindow(vbNullString, sCaption) 'get the handle of the userform
Call SetWindowPos(hWndForm, HWND_TOPMOST, 0, 0, 0, 0, FLAG)
End Sub
Sub UnsetTopMost(sCaption As String)
Const FLAG = SWP_NOSIZE + SWP_NOMOVE
Dim hWndForm As Long
On Error Resume Next
hWndForm = FindWindow(vbNullString, sCaption) 'get the handle of the userform
Call SetWindowPos(hWndForm, HWND_NOTOPMOST, 0, 0, 0, 0, FLAG)
End Sub
and then in the form i add
CODE
SetTopMost Me.Caption
UnsetTopMost Me.Caption
End Sub