Customizing the 'open menu'
Customizing the 'open menu'
(OP)
I have been trying to customize the open menu dialog so that the links on the left side (such as History, My Documents, Desktop, etc) would contain other links to my network. I have looked in to the possibility of creating a macro that will serve this purpose, but I have been unable to locate any literature on how to change these links. I hope I have posed my question in a clear way. Thanks in advance for any help.






RE: Customizing the 'open menu'
It's called "subclassing", and really has nothing to do with Solidworks. It requires hijacking of the Windows API messaging system, and is a considerable amount of work.
Grabbing the window when it pops up, and re-arranging/adding buttons to it is one thing, but when it comes down to actually interfacing with the events, I would not trust a macro to be able to catch even a limited subset of the event streams; even a compiled, standalone VB application cant get them all. And if you miss an event, your code will be sitting there in a loop, possibly even after the dialog is closed.
It might be a lot easier for your program to pop up its OWN custom-made file dialog window ; the VB runtime will handle the events for you. You can then pass the appropriate file name to a SW API call.
RE: Customizing the 'open menu'
Option Explicit
' declarations, used windows API calls and constants
' Deklarationen, benötigte Windows API-Calls und Konstanten
' Windows API to get the free discspace
Private Declare Function GetDiskFreeSpaceEx Lib "kernel32" Alias "GetDiskFreeSpaceExA" ( _
ByVal lpRootPathName As String, _
lpFreeBytesAvailableToCaller As Currency, _
lpTotalNumberOfBytes As Currency, _
lpTotalNumberOfFreeBytes As Currency) As Long
' Windows API for the SaveAs Filebox
Private Declare Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" _
(pOpenfilename As OPENFILENAME) As Long
' structure needed by Windows API
Private Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
' for more information on Open- or SaveAs dialogs look at
' http://www.mvps.org/vbnet/index.html?code/comdlg/filedlgsoverview.htm
' SolidWorks related declarations
Dim swApp As Object ' SolidWorks session
Dim PauseTime As Double
Dim Start As Double
Dim Finish As Double
Dim ModelDoc2 As Object ' active document
Dim filenameIn As String ' desired filename for saved bitmap
Private Sub CommandButton1_Click()
' common dialog for browse for desired filename
' Auswahl des Dateinamens für Bitmap
Dim OFName As OPENFILENAME
Dim tmp As String
'Set the structure size
OFName.lStructSize = Len(OFName)
'Set the filet
OFName.lpstrFilter = "SolidWorks Part (*.sldprt)" + Chr$(0) + "*.sldprt" + Chr$(0) + "All Files (*.*)" + Chr$(0) + "*.*" + Chr$(0)
'Create a buffer
OFName.lpstrFile = Space$(254)
'Set the maximum number of chars
OFName.nMaxFile = 255
'Create a buffer
OFName.lpstrFileTitle = Space$(254)
'Set the maximum number of chars
OFName.nMaxFileTitle = 255
'Set the initial directory (Doesn't Quite Work)
'OFName.lpstrInitialDir =
'Set the dialog title
OFName.lpstrTitle = UserForm1.Caption
'no extra flags
OFName.flags = 0
'default extension
OFName.lpstrDefExt = "sldprt" + Chr$(0)
'Show the 'Save File'-dialog
If GetSaveFileName(OFName) Then
FileName.Text = Trim$(OFName.lpstrFile)
Else
FileName.Text = ""
End If
End Sub
Private Function FileExists(strDest As String) As Boolean
' checks if file strDest exists
Dim intLen As Integer
If strDest <> vbNullString Then
On Error Resume Next
intLen = Len(Dir$(strDest))
On Error GoTo 0
FileExists = (Not Err And intLen > 0)
Else
FileExists = False
End If
End Function
Private Function GetPathPart(strPath As String) As String
'
Dim intCounter As Integer
' Parse the string backwards
For intCounter = Len(strPath) To 1 Step -1
' Short-circuit when we reach the slash
If Mid$(strPath, intCounter, 1) = "\" Then
Exit For
End If
Next intCounter
' Return the value
GetPathPart = Left$(strPath, intCounter)
End Function
This is what I have in the Userform and it pulls up an open dialog. Do you, or anyone for that matter, know how to modify this to suit a custom link on the left side with the others? Thanks
RE: Customizing the 'open menu'
I know these code lines, you got them from one of my macros from http://swtools.cad.de
All I can say: no, it is not possible to "customize" the save/open dialog with API calls.
You may want to read MS knowledgebase article 205041 ( http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q205/0/41.ASP&NoWebContent=1 ) to see how you can customize this for Office, but AFAIK it is noit possible for SolidWorks.
Bye,
Stefan
--
unofficial german SolidWorks helppage
http://solidworks.cad.de
Shareware, freeware, tools and macros
http://swtools.cad.de
RE: Customizing the 'open menu'
>> my macros from http://swtools.cad.de
.. and I know that site .. it is the one that has the code for the feature-hide/show routine that I posted on the newsgroups about a year or so ago. I think the title of the original thread/post was called 'feature snatcher' .. a good Deja news search should pull it up.
Thanx for adding the foreign language support. Was that you that also took credit for it in the subscription section on the SW site?
>>it is not possible to "customize" the save/open
>>dialog with API calls
of course it is. That is the very way solidworks does it; call the API, subclass, and add their their own controls.
I've also done it myself, (because I HAD to) on a CAM application that didnt allow scripting/automation.
RE: Customizing the 'open menu'
RE: Customizing the 'open menu'
But Im not much for doing someones complete job, homework, or macro page <wink>.
Ill see if I can re-use some code and post something tomorrow.
RE: Customizing the 'open menu'