Blog Options
Archive
<< April 2024 >>-
Wednesday 24
- Expanding the StellarDS.io tooling -
Monday 22
- Easy Guide to Building a Pexels Gallery App with TMS WEB Core -
Wednesday 17
- New free component for sophisticated file uploads with TMS WEB Core -
Tuesday 16
- Closing the gap with TMS FNC UI Pack new additions -
Thursday 11
- Unveiling the Latest Enhancements in TMS VCL UI Pack -
Friday 5
- TMS components and Delphi and C++Builder 12.1 -
Wednesday 3
- Customizing the login page of your application using TMS Sphinx
- A Python library for using StellarDS.io effortlessly
- Introducing: How it Works with Holger - Building a Pexels gallery app with TMS WEB Core video series
- TMS FNC Cloud Pack with StellarDS.io backend: unparalleled productivity in VCL & FMX
Authors
- Bernard Roussely (1)
- Wagner Landgraf (82)
- Roman Yankovsky (2)
- Bart Holvoet (27)
- Aaron Decramer (18)
- Pieter Scheldeman (99)
- Nancy Lescouhier (32)
- Adrian Gallero (33)
- Bruno Fierens (404)
- Marcos Douglas B. Santos (5)
- Wagner R. Landgraf (1)
- Bradley Velghe (16)
- Bernard (2)
- Andrew Simard (86)
- Holger Flick (15)
- Gjalt Vanhouwaert (30)
- Tunde Keller (22)
- Masiha Zemarai (119)
Blog
All Blog Posts | Next Post | Previous PostThe new File Open / Save dialogs in Windows Vista
Bookmarks:Wednesday, January 21, 2009
Introduction
In Windows Vista the common File Open and File Save dialogs have got a facelift as well. Unfortunately, Microsoft didn't make the new common file dialogs 100% backwards compatible with the existing GetOpenFileName, GetSaveFileName API calls. As soon as the flag OFN_ENABLEHOOK or OFN_ENABLETEMPLATE are used, the functions fall back to their old appearance. Unfortunately, Delphi uses by default OFN_ENABLEHOOK (just to center the dialog) and optionally OFN_ENABLETEMPLATE. This means that there is not a way to use the new Windows Vista style dialogs with TOpenDialog or TSaveDialog. When TOpenDialog is used in Delphi on Windows Vista, following dialog appears:where the new Windows Vista style dialogs look like:
So, to start using the new Windows Vista Open File & Save File dialogs today from Delphi, either the VCL should be changed (which we suspect Borland will do in a future Delphi version) or a replacement function can be used. We've included here a quick replacement function for TOpenDialog and TSaveDialog that uses the new nice Windows Vista dialogs today:
function OpenSaveFileDialog(Parent: TWinControl; const DefExt, Filter, InitialDir, Title: string; var FileName: string; MustExist, OverwritePrompt, NoChangeDir, DoOpen: Boolean): Boolean; var ofn: TOpenFileName; szFile: array[0..MAX_PATH] of Char; begin Result := False; FillChar(ofn, SizeOf(TOpenFileName), 0); with ofn do begin lStructSize := SizeOf(TOpenFileName); hwndOwner := Parent.Handle; lpstrFile := szFile; nMaxFile := SizeOf(szFile); if (Title <> '') then lpstrTitle := PChar(Title); if (InitialDir <> '') then lpstrInitialDir := PChar(InitialDir); StrPCopy(lpstrFile, FileName); lpstrFilter := PChar(ReplaceStr(Filter, '|', #0)+#0#0); if DefExt <> '' then lpstrDefExt := PChar(DefExt); end; if MustExist then ofn.Flags := ofn.Flags or OFN_FILEMUSTEXIST; if OverwritePrompt then ofn.Flags := ofn.Flags or OFN_OVERWRITEPROMPT; if NoChangeDir then ofn.Flags := ofn.Flags or OFN_NOCHANGEDIR; if DoOpen then begin if GetOpenFileName(ofn) then begin Result := True; FileName := StrPas(szFile); end; end else begin if GetSaveFileName(ofn) then begin Result := True; FileName := StrPas(szFile); end; end end;
Bruno Fierens
Bookmarks:
This blog post has not received any comments yet.
All Blog Posts | Next Post | Previous Post