Results 1 to 3 of 3

Thread: Opening Explorer Window with focus, on top of the AutoCAD window?

  1. #1
    100 Club amaser's Avatar
    Join Date
    2006-05
    Location
    Joliet, IL
    Posts
    105
    Login to Give a bone
    0

    Default Opening Explorer Window with focus, on top of the AutoCAD window?

    i have code that extracts the project name and opens explorer to the project direcotry. is there a way to get the explorer window to appear with focus, on top of the ACAD window?
    the code (below) opens the directory, but it opens at the bottom of the stack. how do i bring the explorer window to the front?

    thanx

    Private Sub cmdBrowse_Click()
    'Declare variables
    Dim strYearFolder As String
    Dim lngPos As Long
    Dim ProjNum As String
    Dim strDwgName As String
    Dim path As String
    Dim windowHandle As Long

    'get project number / path
    strDwgName = ThisDrawing.Name
    lngPos = InStr(1, strDwgName, "_", vbTextCompare)
    If lngPos > 0 Then
    ProjNum = Left$(strDwgName, lngPos - 1)
    strYearFolder = Left$(ProjNum, 2)
    Select Case strYearFolder
    Case "05"
    path = " m:\2005\" & ProjNum
    Case "06"
    path = "m:\2006\" & ProjNum
    Case "01"
    path = "m:\2001\" & ProjNum
    Case "02"
    path = "M:\2002\" & ProjNum
    Case "03"
    path = "m:\2003\" & ProjNum
    Case "04"
    path = "m:\2004\" & ProjNum
    Case "07"
    path = "m:\2007\" & ProjNum
    Case Else
    path = "m:\1965-1999\" & ProjNum
    End Select
    Shell ("c:\windows\explorer.exe" & path)
    Else
    MsgBox "You cannot use this feature unless the drawing name is per MEI Standard", , "McBride Engineering"
    End If

    windowHandle = FindWindow(vbNullString, path)
    SetWindowPos windowHandle, HWND_TOPMOST, 0, 0, 0, 0, SWP_SHOWWINDOW
    SendMessage windowHandle, TCM_SETCURFOCUS, 0, ByVal 0&
    End Sub

  2. #2
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,420
    Login to Give a bone
    0

    Default Re: Opening Explorer Window with focus, on top of the AutoCAD window?

    Take another look at the Shell function. It has an arg for the window style.

    Code:
    Public Sub Browse(Optional URL As String, Optional winstyle As VbAppWinStyle)
        'opens IE in last WinStyle if WinStyle is not supplied
        
        'Nav to home page if url is blank
        If Not URL = "" Then URL = " " & URL
        'make sure your path to IE is correct
        Shell "C:\Program Files\Internet Explorer\IEXPLORE.EXE" & URL, winstyle
    End Sub
    C:> ED WORKING....


    LinkedIn

  3. #3
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,805
    Login to Give a bone
    0

    Smile Re: Opening Explorer Window with focus, on top of the AutoCAD window?

    I know this is the VBA group, but just in case you are looking for another alternative, this menu macro will work.

    Code:
    (STARTAPP (strcat "EXPLORER /e," (getvar "dwgprefix")))
    R.K. McSwain | CAD Panacea |

Similar Threads

  1. VBA - Change User Focus From Form to AutoCAD Window
    By bsardeson in forum VBA/COM Interop
    Replies: 7
    Last Post: 2011-02-22, 04:37 PM
  2. AutoCAD stealing Window focus
    By .chad in forum CAD Management - General
    Replies: 2
    Last Post: 2010-06-29, 08:25 PM
  3. hiding window removes the opening for the window as well
    By JH75 in forum Revit Structure - General
    Replies: 4
    Last Post: 2008-09-15, 10:09 PM
  4. Prevent AutoCAD Text Window from opening
    By PRSMAIL in forum AutoLISP
    Replies: 1
    Last Post: 2007-06-11, 12:32 PM
  5. Thumbnail in Window Explorer
    By bill.shultz in forum AutoCAD General
    Replies: 2
    Last Post: 2005-04-27, 09:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •