You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
Thanks, Dave, for those encapsulations posted
on the Source Code forum for list boxes, edit boxes, etc. Is there something similar out there for the open/save file common controls?
Yes! They included already in one of the include files.
Here is the same thing but with a hook to center the dialog.
Code:
'---------------------------------------------------------
' File: CENTDLG.BAS Center the Open/Save Dialog Box
'
'
'---------------------------------------------------------
'Notifications for Open dialog control
%CDN_INITDONE = (%CDN_FIRST - 0000 )
%CDN_SELCHANGE = (%CDN_FIRST - 0001 )
%CDN_FOLDERCHANGE = (%CDN_FIRST - 0002 )
%CDN_SHAREVIOLATION = (%CDN_FIRST - 0003 )
%CDN_HELP = (%CDN_FIRST - 0004 )
%CDN_FILEOK = (%CDN_FIRST - 0005 )
%CDN_TYPECHANGE = (%CDN_FIRST - 0006 )
'%CDM_FIRST = (%WM_USER + 100 )
'%CDM_LAST = (%WM_USER + 200 )
'---
Type TAGOFNOTIFY
hdr As NMHDR
End Type
'---
Function OpenCommDlg_Proc(ByVal hWnd As LONG, ByVal wMsg As LONG, ByVal wParam As LONG, ByVal lParam As LONG ) EXPORT As LONG
DIM X As Long
DIM Y As Long
DIM R As RECT
Dim tNOTIFY As TAGOFNOTIFY PTR
Select Case wMsg
Case %WM_NOTIFY
tNOTIFY = lParam
If @tNOTIFY.hdr.Code = %CDN_INITDONE Then
GetWindowRect GetParent( hWnd ), R
X = GetSystemMetrics ( %SM_CXSCREEN )
Y = GetSystemMetrics ( %SM_CYSCREEN )
X = ( X - ( R.nRight - R.nLeft ) ) \ 2
Y = ( Y - ( R.nBottom - R.nTop ) ) \ 2
SetWindowPos GetParent( hWnd ), %NULL, X, Y, 0, 0, %SWP_NOSIZE OR %SWP_NOZORDER
End If
End Select
End Function
'---
FUNCTION OpenFileCenterDlg(BYVAL hWnd AS LONG, _ ' parent window
BYVAL Caption AS STRING, _ ' caption
Filespec AS STRING, _ ' filename
BYVAL InitialDir AS STRING, _ ' start directory
BYVAL Filter AS STRING, _ ' filename filter
BYVAL DefExtension AS STRING, _ ' default extension
Flags AS LONG) AS LONG ' flags
LOCAL Ofn AS OPENFILENAME
LOCAL zFile AS ASCIIZ * 256
LOCAL zFileTitle AS ASCIIZ * 256
LOCAL zFilter AS ASCIIZ * 256
LOCAL zInitialDir AS ASCIIZ * 256
LOCAL zTitle AS ASCIIZ * 256
LOCAL zDefExt AS ASCIIZ * 10
REPLACE "|" WITH CHR$(0) IN Filter
IF LEN(InitialDir) = 0 THEN
InitialDir = CURDIR$
END IF
zFilter = Filter + CHR$(0)
zInitialDir = InitialDir + CHR$(0)
zFile = Filespec + CHR$(0)
zDefExt = DefExtension + CHR$(0)
zTitle = Caption + CHR$(0)
ofn.lStructSize = SIZEOF(ofn)
ofn.hWndOwner = hWnd
ofn.lpstrFilter = VARPTR(zFilter)
ofn.nFilterIndex = 1
ofn.lpstrFile = VARPTR(zFile)
ofn.nMaxFile = SIZEOF(zFile)
ofn.lpstrFileTitle = VARPTR(zFileTitle)
ofn.nMaxFileTitle = SIZEOF(zFileTitle)
ofn.lpstrInitialDir = VARPTR(zInitialDir)
IF LEN(zTitle) THEN
ofn.lpstrTitle = VARPTR(zTitle)
END IF
ofn.Flags = Flags OR %OFN_ENABLEHOOK OR %OFN_EXPLORER
ofn.lpstrDefExt = VARPTR(zDefExt)
ofn.lpfnHook = CODEPTR(openCommDlg_Proc)
FUNCTION = GetOpenFilename(ofn)
Filespec = zFile
Flags = ofn.Flags
END FUNCTION
'---
FUNCTION SaveFileCenterDlg(BYVAL hWnd AS LONG, _ ' parent window
BYVAL Caption AS STRING, _ ' caption
Filespec AS STRING, _ ' filename
BYVAL InitialDir AS STRING, _ ' start directory
BYVAL Filter AS STRING, _ ' filename filter
DefExtension AS STRING, _ ' default extension
Flags AS LONG) AS LONG ' flags
LOCAL Ofn AS OPENFILENAME
LOCAL zFile AS ASCIIZ * 256
LOCAL zFileTitle AS ASCIIZ * 256
LOCAL zFilter AS ASCIIZ * 256
LOCAL zInitialDir AS ASCIIZ * 256
LOCAL zTitle AS ASCIIZ * 256
LOCAL zDefExt AS ASCIIZ * 10
REPLACE "|" WITH CHR$(0) IN Filter
IF LEN(InitialDir) = 0 THEN
InitialDir = CURDIR$
END IF
zFilter = Filter + CHR$(0)
zInitialDir = InitialDir + CHR$(0)
zFile = Filespec + CHR$(0)
zDefExt = DefExtension + CHR$(0)
zTitle = Caption + CHR$(0)
ofn.lStructSize = SIZEOF(ofn)
ofn.hWndOwner = hWnd
ofn.lpstrFilter = VARPTR(zFilter)
ofn.nFilterIndex = 1
ofn.lpstrFile = VARPTR(zFile)
ofn.nMaxFile = SIZEOF(zFile)
ofn.lpstrFileTitle = VARPTR(zFileTitle)
ofn.nMaxFileTitle = SIZEOF(zFileTitle)
ofn.lpstrInitialDir = VARPTR(zInitialDir)
IF LEN(zTitle) THEN
ofn.lpstrTitle = VARPTR(zTitle)
END IF
ofn.Flags = Flags OR %OFN_ENABLEHOOK OR %OFN_EXPLORER
ofn.lpstrDefExt = VARPTR(zDefExt)
ofn.lpfnHook = CODEPTR(openCommDlg_Proc)
FUNCTION = GetSaveFilename(ofn)
Filespec = zFile
Flags = ofn.Flags
END FUNCTION
'--------------------* End *----------------
If you have down loaded the latest API, all
of Dave's wrappers are in the 'commctl.inc'
file. No need for yet another *.inc directive
in your code. Good job Dave!!!
I feel really foolish - but I can't find anywhere on
this site to download the lastest API! (such as the commctl.inc)
The "PBDLL API Directory" under Files only has 3 choices -
encap32, excel32api, and obdc30 - no commclt.inc
Originally posted by Cecil Williams: If you have down loaded the latest API, all
of Dave's wrappers are in the 'commctl.inc'
file. No need for yet another *.inc directive
in your code. Good job Dave!!!
Sorry for not clarifing the Win32API location. Just follow
Kevin's ftp IP address and you'll be there. BTW, the open and save dlgs are in comdlg32.inc file.
You need to get familiar with the Win32API files. Powerbasic also updates these files so you need to check every so often to get the latest files. Thanx to Kevin for the IP address.
Just one thing would make those encapsulations mucho better: If there were DECLARE statements for them. Better still, if all the "non-Windows" stuff were in it's own #INCLUDE file.
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment