473,394 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Replace comdlg32 and/or mscomctl

Is there any code out there to replace the Open File dialog in the
common controls? Or, I would like to just make sure that the Explorer
item in the context menu doesn't appear when the user right clicks on a
folder. Any ideas?
Thanks!

Matthew Hanna

Jul 17 '05 #1
7 4100
On Fri, 05 Dec 2003 16:05:28 -0500, Matthew Hanna
<mh************@appsci.com> wrote:
Is there any code out there to replace the Open File dialog in the
common controls? Or, I would like to just make sure that the Explorer
item in the context menu doesn't appear when the user right clicks on a
folder. Any ideas?
Thanks!

Matthew Hanna


As mercilessly hacked from www.AllAPI.net :-

VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "cOpenDlg"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

' cOpenDlg.cls - J French 18/11/01 - From KPD

' Dim OD As New cOpenDlg
' OD.Parent = Me (Optional)
' OD.Path = "C:\test"
' OD.Title = "Open File :"
' OD.FileName = "The File Name"
' OD.Filter = "Text Files (*.txt)|*.txt|"
'
' FullFile = OD.FileNameToOpen
'
' OD.FileName is now "A Test File"
' OD.Path is now "C:\TEST\DEV"

' --- Open File Constants - added 25/3/01 JF
Private Const OFN_ALLOWMULTISELECT = &H200
Private Const OFN_CREATEPROMPT = &H2000
Private Const OFN_DONTADDTORECENT = &H2000000
Private Const OFN_ENABLEHOOK = &H20
Private Const OFN_ENABLEINCLUDENOTIFY = &H400000
Private Const OFN_ENABLESIZING = &H800000
Private Const OFN_ENABLETEMPLATE = &H40
Private Const OFN_ENABLETEMPLATEHANDLE = &H80
Private Const OFN_EX_NOPLACESBAR = &H1
Private Const OFN_EXPLORER = &H80000 ' new look commdlg - default
Private Const OFN_EXTENSIONDIFFERENT = &H400
Private Const OFN_FILEMUSTEXIST = &H1000
Private Const OFN_FORCESHOWHIDDEN = &H10000000
Private Const OFN_HIDEREADONLY = &H4
Private Const OFN_LONGNAMES = &H200000 ' force long names for 3.x
modules
Private Const OFN_NOCHANGEDIR = &H8
Private Const OFN_NODEREFERENCELINKS = &H100000
Private Const OFN_NOLONGNAMES = &H40000 ' force no long names for 4.x
modules
Private Const OFN_NONETWORKBUTTON = &H20000
Private Const OFN_NOREADONLYRETURN = &H8000
Private Const OFN_NOTESTFILECREATE = &H10000
Private Const OFN_NOVALIDATE = &H100
Private Const OFN_OVERWRITEPROMPT = &H2
Private Const OFN_PATHMUSTEXIST = &H800
Private Const OFN_READONLY = &H1
Private Const OFN_SHAREAWARE = &H4000
Private Const OFN_SHAREFALLTHROUGH = 2
Private Const OFN_SHARENOWARN = 1
Private Const OFN_SHAREWARN = 0
Private Const OFN_SHOWHELP = &H10
Private Const OFN_USEMONIKERS = &H1000000
Private Type TOPENFILENAME
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
lpstrFileExcPathBack 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

Private Declare Function GetOpenFileName _
Lib "comdlg32.dll" _
Alias "GetOpenFileNameA" _
(pOpenfilename As TOPENFILENAME) As Long

Private Type TM
OwnerHWnd As Long
Filter As String
FileName As String
Path As String
Title As String
End Type

Dim OF As TOPENFILENAME, m As TM

Public Function FileNameToOpen$()
FileNameToOpen = LF_ShowOpen
End Function
' ---
Public Property Let Filter(Value$)
m.Filter = Value
End Property
Public Property Get Filter$()
Filter = m.Filter
End Property
' ---
Public Property Let FileName(Value$)
m.FileName = Value
End Property
Public Property Get FileName$()
FileName = m.FileName
End Property
' ---
Public Property Let Path(Value$)
m.Path = Value
End Property
Public Property Get Path$()
Path = m.Path
End Property
' ---
Public Property Let Title(Value$)
m.Title = Value
End Property
Public Property Get Title$()
Title = m.Title
End Property
' ---
Public Property Let Parent(Value As Form)
m.OwnerHWnd = 0
If Not Value Is Nothing Then
m.OwnerHWnd = Value.hwnd
End If
End Property

' --- Main Routine
Private Function LF_ShowOpen() As String
Dim S$
Dim ActiveForms As Collection
Dim F As Form

' --- Disable all Enabled and Visible Forms
If m.OwnerHWnd = 0 Then
Set ActiveForms = New Collection
For Each F In Forms
If F.Visible Then
If F.Enabled Then
ActiveForms.Add F
F.Enabled = False
End If
End If
Next
End If

'Set the structure size
OF.lStructSize = Len(OF)
'Set the owner window
OF.hwndOwner = m.OwnerHWnd

'Set the application's instance
OF.hInstance = App.hInstance
'Set the filter
S$ = m.Filter
Call StrReplaceStr(S$, "|", Chr$(0))
OF.lpstrFilter = S$ + Chr$(0)
'Create a buffer - File Name In - Full File & Path Out
OF.lpstrFile = m.FileName + Space$(255)
'Set the maximum number of chars
OF.nMaxFile = 255
'Create a buffer
OF.lpstrFileExcPathBack = Space$(254)
'Set the maximum number of chars
OF.nMaxFileTitle = 255
'Set the initial directory
OF.lpstrInitialDir = m.Path
'Set the dialog title
OF.lpstrTitle = m.Title
'extra flags - Hide Read Only Option
' - File MUST exist
' - Do not change App's CurDir on exit
OF.flags = OFN_HIDEREADONLY _
Or OFN_FILEMUSTEXIST _
Or OFN_NOCHANGEDIR

'Show the 'Open File'-dialog
If GetOpenFileName(OF) Then
LF_ShowOpen = StrExtStr(OF.lpstrFile, Chr$(0), 1)
m.FileName = StrExtStr(OF.lpstrFileExcPathBack, Chr$(0), 1)
m.Path = ExtractFilePath(LF_ShowOpen)
Else
LF_ShowOpen = ""
End If

' --- Re-Enable Forms
If m.OwnerHWnd = 0 Then
For Each F In ActiveForms
F.Enabled = True
Next
Set ActiveForms = Nothing
End If
End Function

Private Sub Class_Initialize()
m.Filter = "All Files (*.*)|*.*|"
m.Title = "Open File:"
m.Path = CurDir
End Sub


Jul 17 '05 #2
I must be missing something here. How does that code prevent a user's
right-clicking on a folder in the OpenFile dialog and then selecting
Explore?

--

Randy Birch
MVP Visual Basic
http://www.mvps.org/vbnet/
Please respond only to the newsgroups so all can benefit.

<snip>
Jul 17 '05 #3

"Matthew Hanna" <mh************@appsci.com> wrote in message
news:sq6Ab.84904$yJ.40467@okepread02...
Is there any code out there to replace the Open File dialog in the
common controls? Or, I would like to just make sure that the Explorer
item in the context menu doesn't appear when the user right clicks on a folder. Any ideas?
Thanks!

Matthew Hanna

On my machine (XP), all the Explore option does on the context menu is
open a new window on the folder. I can do this anyway using Windows
Explorer, My Computer, etc. I could do it ahead of time if you manage to
disable it in your dialog.

What difference could it make whether I happen to have a folder view
open while selecting a file in your app?
Jul 17 '05 #4
We are using Citrix to allow others to access our main application. It
worked great until we found out that people could access our entire
network. With some additional programming we filled all the holes so
there was no access to the network except for what we offer in the main
application. Then, someone pointed out that they could still get to the
network by getting a file dialog box (Open or Save) and then right
clicking to get explorer. From there the network was wide open. I want
to just watch for explorer to appear and then shut it down but that
isn't an option in my bosses opinion.

Any ideas?

Thanks!
Matthew Hanna

Steve Gerrard wrote:
"Matthew Hanna" <mh************@appsci.com> wrote in message
news:sq6Ab.84904$yJ.40467@okepread02...
Is there any code out there to replace the Open File dialog in the
common controls? Or, I would like to just make sure that the Explorer
item in the context menu doesn't appear when the user right clicks on


a
folder. Any ideas?
Thanks!

Matthew Hanna


On my machine (XP), all the Explore option does on the context menu is
open a new window on the folder. I can do this anyway using Windows
Explorer, My Computer, etc. I could do it ahead of time if you manage to
disable it in your dialog.

What difference could it make whether I happen to have a folder view
open while selecting a file in your app?


Jul 17 '05 #5

"Matthew Hanna" <mh************@appsci.com> wrote in message
news:ZZmBb.93159$yJ.48120@okepread02...
We are using Citrix to allow others to access our main application. It worked great until we found out that people could access our entire
network. With some additional programming we filled all the holes so
there was no access to the network except for what we offer in the main application. Then, someone pointed out that they could still get to the network by getting a file dialog box (Open or Save) and then right
clicking to get explorer. From there the network was wide open. I want to just watch for explorer to appear and then shut it down but that
isn't an option in my bosses opinion.

Any ideas?

Thanks!
Matthew Hanna


Oh yeah, Citrix, I forgot about that possibility. They were talking
about that at work a few years ago...

Somehow I don't think you will ever be able to disable features of a
common dialog and be confident that you have permanently filled in the
hole...

You could make your own OpenFile dialog, maybe using the Drive, Dir, and
File list boxes of VB. It is not as pretty, but it would allow as much
(or as little) navigation as you want, and prevent users from doing
anything but picking a location and file name.
Jul 17 '05 #6
On Tue, 09 Dec 2003 11:44:41 -0500, Matthew Hanna
<mh************@appsci.com> wrote:
We are using Citrix to allow others to access our main application. It
worked great until we found out that people could access our entire
network. With some additional programming we filled all the holes so
there was no access to the network except for what we offer in the main
application. Then, someone pointed out that they could still get to the
network by getting a file dialog box (Open or Save) and then right
clicking to get explorer. From there the network was wide open. I want
to just watch for explorer to appear and then shut it down but that
isn't an option in my bosses opinion.

Any ideas?


Yes, roll your own Open/Save Dialogs
Jul 17 '05 #7
On Sat, 06 Dec 2003 15:45:36 GMT, "Randy Birch"
<rg************@mvps.org> wrote:
I must be missing something here. How does that code prevent a user's
right-clicking on a folder in the OpenFile dialog and then selecting
Explore?


You are absolutely right, I did not read the post correctly

The solution looks profoundly nasty
- subclassing theCommonDialog
- or sneaking Mouse Events using SetWindowsHookEx

Painful ...
Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Craig Keightley | last post by:
Can these lines of sql statements be consolidated into one sql statement (possibly using reg exps??) BEGIN CODE ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Update...
0
by: Randy Birch | last post by:
re: MSComCtl Listview control cashes after installing VB6/VS6 SP6 I have been advised that this problem has been reproduced and a hotfix has been prepared. The supporting KB article and hotfix...
2
by: Randy Birch | last post by:
Reposted as the original is reported as deleted from the server. re: MSComCtl Listview control cashes after installing VB6/VS6 SP6 I have been advised that this problem has been reproduced...
12
by: Barnes | last post by:
Does anyone know of a good way to use the JavaScript string.replace() method in an ASP form? Here is the scenario: I have a form that cannot accept apostrophes. I want to use the replace() so...
6
by: Danny | last post by:
I need an asp command to strip out from a string all extra punctuation such as apostrophe, comma, period, spaces dashes, etc etc and just leave the letters. Can anybody give me some ideas? ...
4
by: Cor | last post by:
Hi Newsgroup, I have given an answer in this newsgroup about a "Replace". There came an answer on that I did not understand, so I have done some tests. I got the idea that someone said,...
6
by: JackpipE | last post by:
Here is my replace query and I need to run this on every column in my table. Right now I manually enter the column name (_LANGUAGES_SPOKEN) but this is time consuming and would like to automate...
2
by: Veggis | last post by:
Hi I have a large access application, it registers information on funerals. And this is sold on as runtime apps to other customers. One of my customers got new pcs recently, and now certain...
3
by: Kerem Gümrükcü | last post by:
Hi, does anybody have ready-to-go PInvoke Signatures and/or Prototypes for the FindText Function from comdlg32.dll? C# would be great, any other DotNet Code would also be very helpfull. ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.