Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Adding buttons to the "Open file dialog"....

6 views
Skip to first unread message

Marcus Hansson

unread,
Feb 20, 2002, 6:30:43 AM2/20/02
to
The program Im writing is used on a large network, and everyone wants to
save the files
in different locations, very often, the same 3 or 4 locations are used, so I
was thinking of
adding some buttons to the the "Open file dialog"

I was thinking of something like 4 buttons on the right side of the dialog,
where the user could rightclick to save the current path "into" that button,
or leftclick to go to the already saved path.

Is this a though one?
Should I write my own "open dialogbox" or should I hook into the "common"
one?
Since the program should run under 95,98 NT and 2000 I thought it might be
nice to hook
on to the common dialog, and then avoiding reinventing the wheel. But Im not
sure where to start.
Does anyone have any ideas or suggestions?

Im writing in C using Borland 5.02 under win2000

Thanks alot
// Marcus

Tim Robinson

unread,
Feb 20, 2002, 6:52:23 AM2/20/02
to
"Marcus Hansson" <poub...@hotmail.com> wrote in message
news:a501gj$93l$1...@endevour.netg.se...

| Is this a though one?
| Should I write my own "open dialogbox" or should I hook into the "common"
| one?
| Since the program should run under 95,98 NT and 2000 I thought it might be
| nice to hook
| on to the common dialog, and then avoiding reinventing the wheel. But Im
not
| sure where to start.
| Does anyone have any ideas or suggestions?
|
| Im writing in C using Borland 5.02 under win2000

It's easy. The file dialogs have a mechanism where you can specify your own
dialog template and hook procedure (which will receive any relevant
messages). Look at the lpTemplateName and lpfnHook fields in the
OPENFILENAME structure.

--
Tim Robinson
http://www.themoebius.org.uk/

Lucian Wischik

unread,
Feb 20, 2002, 7:31:19 AM2/20/02
to
Tim Robinson <timothy.rem...@ic.ac.uk> wrote:
>[File dialog and shortcuts to common locations]

>It's easy. The file dialogs have a mechanism where you can specify your own
>dialog template and hook procedure (which will receive any relevant
>messages). Look at the lpTemplateName and lpfnHook fields in the
>OPENFILENAME structure.

The newer File dialogs have a load of large icon shortcuts to the left, to
My Documents and to the Desktop and to other places.

Does anyone know how to customize which shortcuts appear in this panel?

(I've always wanted to do this. Additionally, if there is a standard way,
then this customization would solve the previous poster's problem, but
without the need to do dialog templates.)

--
Lucian Wischik, Queens' College, Cambridge CB3 9ET. www.wischik.com/lu

Tim Robinson

unread,
Feb 20, 2002, 7:35:50 AM2/20/02
to
"Lucian Wischik" <ljw...@cus.cam.ac.uk> wrote in message
news:a504un$ddl$1...@pegasus.csx.cam.ac.uk...

| >[File dialog and shortcuts to common locations]
|
| The newer File dialogs have a load of large icon shortcuts to the left, to
| My Documents and to the Desktop and to other places.
|
| Does anyone know how to customize which shortcuts appear in this panel?
|
| (I've always wanted to do this. Additionally, if there is a standard way,
| then this customization would solve the previous poster's problem, but
| without the need to do dialog templates.)

The Windows 2000 version of TweakUI will allow you to change where the icons
point. I have my Projects directory as the top icon, although relatively few
applications have been recompiled for the new dialogs. I don't see why the
icons couldn't have been applied to the old dialogs as well.

Jugoslav Dujic

unread,
Feb 20, 2002, 9:40:49 AM2/20/02
to
"Tim Robinson" <timothy.rem...@ic.ac.uk> wrote in message
news:a505vf$37f4o$1...@ID-103400.news.dfncis.de...

But why leftmost icons disappear under Win2K if I utilize
a OFN_ENABLETEMPLATE (or even OFN_ENABLEHOOK IIRC)?
Here's my setup (hope it would serve as a sample for
the OP):

Ofn%lStructSize = SIZEOF(Ofn)
Ofn%hwndOwner = hSplash
Ofn%hInstance = hInst
Ofn%lpstrFilter = LOC(szFilter)
Ofn%lpstrCustomFilter = NULL
Ofn%nMaxCustFilter = NULL
Ofn%nFilterIndex = 1
Ofn%lpstrFile = LOC(szLocalFile)
Ofn%nMaxFile = LEN(szLocalFile)
Ofn%lpstrFileTitle = LOC(sNetTitle)
Ofn%nMaxFileTitle = LEN(sNetTitle)
Ofn%lpstrInitialDir = LOC(szInitDir)
Ofn%lpstrTitle = LOC(szOpen)
Ofn%Flags = OFN_HIDEREADONLY.OR.OFN_PATHMUSTEXIST.OR. &
OFN_EXPLORER .OR.OFN_ENABLEHOOK .OR. &
OFN_ENABLETEMPLATE
Ofn%nFileOffset = 0
Ofn%nFileExtension = 0
Ofn%lpstrDefExt = LOC(szExt)
Ofn%lCustData = 0
Ofn%lpfnHook = LOC(OpenHookProc)
Ofn%lpTemplateName = MAKEINTRESOURCE(IDD_DIALOG_EXTOPEN)

The sequel is a copy & paste of code handling an additional
child dialog with few radios, edit box and buttons; radios
are titled "local file" and "download from server". Note
use of GetParent() and handling CDN_SELCHANGE.

!=================================================================
INTEGER FUNCTION OpenHookProc(hWnd,Msg,wParam,lParam)
!DEC$ATTRIBUTES STDCALL:: OpenHookProc

USE DFWIN
USE COMCTL
USE GLOBALS
USE OPCCLIENT
USE REGISTRY

IMPLICIT NONE

INCLUDE "Resource.fd"

INTEGER:: hWnd,Msg,wParam,lParam
INTEGER:: iSt,iX,iY
TYPE(T_RECT):: Rect
TYPE(T_NMHDR):: Hdr; POINTER(pHdr, Hdr)

INTERFACE
LOGICAL FUNCTION OfnEnableProc(hWnd, bEnable)
!DEC$ATTRIBUTES STDCALL:: OfnEnableProc
INTEGER:: hwnd
LOGICAL:: bEnable
END FUNCTION
END INTERFACE

SELECT CASE(Msg)
CASE(WM_INITDIALOG)
iSt=GetWindowRect(GetParent(hWnd),Rect)
iX=Rect%Right-Rect%Left
iY=Rect%Bottom-Rect%Top
iSt=GetWindowRect(hFrame,Rect)

iSt=SetWindowPos(GetParent(hWnd),0,(Rect%Right-iX)/2,(Rect%Bottom-iY)/2,0,0,SWP_
NOSIZE.OR.SWP_NOZORDER)

iSt=SendMessage(GetDlgItem(hWnd,IDC_EDIT_SERVER0), WM_SETTEXT, 0,
LOC(szOPCServer))
iSt=SendMessage(GetDlgItem(hWnd, IDC_RADIO_LOCAL), BM_SETCHECK,
iServerStatus.NE.SERVER_OPC, 0)
iSt=SendMessage(GetDlgItem(hWnd, IDC_RADIO_OPC), BM_SETCHECK,
iServerStatus.EQ.SERVER_OPC, 0)
iSt=EnableWindow(GetDlgItem(hWnd,IDC_EDIT_SERVER0),
iServerStatus.EQ.SERVER_OPC)
iSt=EnableWindow(GetDlgItem(hWnd,IDC_BUTTON_BROWSE),
iServerStatus.EQ.SERVER_OPC)
iSt=EnableWindow(GetDlgItem(hWnd,IDC_BUTTON_CONNECT0),
iServerStatus.EQ.SERVER_OPC)
OpenHookProc=.FALSE.
CASE(WM_NOTIFY)
pHdr=lParam
IF (Hdr%Code.EQ.CDN_SELCHANGE) THEN
iSt=EnumChildWindows(GetParent(hWnd), LOC(OfnEnableProc),
iServerStatus.NE.SERVER_OPC)
END IF
OpenHookProc=.FALSE.

CASE(WM_COMMAND)
SELECT CASE(LOWORD(wParam))
CASE(IDC_RADIO_LOCAL, IDC_RADIO_OPC)
IF (LOWORD(wParam).EQ.IDC_RADIO_LOCAL) THEN
iServerStatus=SERVER_NONE
ELSE
iServerStatus=SERVER_OPC
END IF

iSt=SendMessage(GetDlgItem(hWnd, IDC_EDIT_SERVER0), WM_SETTEXT, 0,
LOC(szOPCServer))
iSt=SendMessage(GetDlgItem(hWnd, IDC_RADIO_LOCAL), BM_SETCHECK,
iServerStatus.NE.SERVER_OPC, 0)
iSt=SendMessage(GetDlgItem(hWnd, IDC_RADIO_OPC), BM_SETCHECK,
iServerStatus.EQ.SERVER_OPC, 0)
iSt=EnableWindow(GetDlgItem(hWnd,IDC_EDIT_SERVER0),
iServerStatus.EQ.SERVER_OPC)
iSt=EnableWindow(GetDlgItem(hWnd,IDC_BUTTON_BROWSE),
iServerStatus.EQ.SERVER_OPC)
iSt=EnableWindow(GetDlgItem(hWnd,IDC_BUTTON_CONNECT0),
iServerStatus.EQ.SERVER_OPC)

iSt=EnumChildWindows(GetParent(hWnd), LOC(OfnEnableProc),
iServerStatus.NE.SERVER_OPC)
CASE(IDC_BUTTON_BROWSE)
CALL OnOPCBrowse(hWnd)
CASE(IDC_BUTTON_CONNECT0)
iSt=GetWindowText(GetDlgItem(hWnd, IDC_EDIT_SERVER0), szOPCServer,
LEN(szOPCServer))
iSt=EnableWindow(GetDlgItem(GetParent(hWnd), IDOK), .TRUE.)
iSt=EndDialog(GetParent(hWnd),IDOK)
END SELECT
OpenHookProc=.FALSE.
CASE DEFAULT
OpenHookProc=.FALSE.
END SELECT

END FUNCTION OpenHookProc


Jugoslav
________________________
www.geocities.com/jdujic

Dave

unread,
Feb 20, 2002, 8:56:45 PM2/20/02
to
Because you are not using the correct structure size. When you use
OFN_ENABLEHOOK, you also need to specify the Windows 2000 size of the
OPENFILENAME structure. Otherwise, the places bar will not be created.


0 new messages