×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

strange window behaviour in SW x64

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

I have seen the same behavior exactly as you have stated.  I just learned to use the windows button + tab button and select the macro window.  I am on windows 7, sw2010 x64.

RE: strange window behaviour in SW x64

This is a major PIA for us using Win7 64 bit.  I'm not in any hurry to "upgrade" my home XP boxes...

RE: strange window behaviour in SW x64

so you trying to say you are running 64-bit application on a 32-bit platform? if so, may i ask why?

RE: strange window behaviour in SW x64

(OP)
ws000 - One can't install and run a 64-bit application on a 32-bit platform.

RE: strange window behaviour in SW x64

If you're talking about UserForms, there's some code that fixes this issue.  It works, but almost too well, as the windows become "always on top" and sometimes mask error messages.

http://angelsix.com/cms/forum/viewtopic.php?f=30&t=53

RE: strange window behaviour in SW x64

(OP)
Thanks gopack13 for the link. It needed a little tinkering but I got it running. I had to declare the functions private and remove "Global" in front of const.

CODE

Option Explicit

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

lRet = FindWindow(vbNullString, UserForm1.Caption)
res = SetWindowPos(lRet, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)

RE: strange window behaviour in SW x64

I have had this problem with SW2010 and 2011 on both Vista and 7 x64.

This is sofar my best solution.
Every time i have a messagebox i then have to redo it.

CODE

swApp.SendMsgToUser2 "Bla bla", swMbInformation, swMbOk
  
UserForm_Layout

CODE

Sub SetTopMost(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_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

Private Sub UserForm_Layout()
  SetTopMost Me.Caption
  UnsetTopMost Me.Caption
End Sub
This is the only way i found to bring the form to front and still not lockup solidworks totally afterwards.
 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources