I have a GetFileName dialog with a template and the OFNHookProc.
mov ofn.Flags,OFN_LONGNAMES or OFN_ENABLEHOOK or OFN_ENABLETEMPLATE or OFN_EXPLORER
mov ofn.lpfnHook,offset OFNHookProc
mov ofn.lpTemplateName,offset szTemplateName
The dialog opens as it should and it sends the WM_NOTIFY message to the OFNHookProc.
However the lParam seems not to be a pointer to the OFNOTIFY structure.
.if uMsg==WM_INITDIALOG
invoke GetDlgItem,hWin,IDC_TRB2
mov hTRB2,eax
mov eax,FALSE
ret
.elseif uMsg==WM_NOTIFY
mov eax,lParam
mov eax,dword ptr [eax].NMHDR.code
.if eax==CDN_INITDONE ;code=0
.elseif eax==CDN_FOLDERCHANGE ;code=2
.elseif eax==CDN_HELP ;code=4
.elseif eax==CDN_INCLUDEITEM ;code=7
.elseif eax==CDN_FILEOK ;code=5
.elseif eax==CDN_SELCHANGE ;code=1
.elseif eax==CDN_SHAREVIOLATION ;code=3
.elseif eax==CDN_TYPECHANGE ;code=6
mov eax,lParam
mov eax,dword ptr [eax].OFNOTIFY.lpOFN.OPENFILENAME.nFilterIndex
.if eax==2
invoke ShowWindow,hTRB2,SW_SHOW
.endif
.endif
mov eax,FALSE
ret
Any suggestions?
Best regards
Quote
OFNOTIFYA STRUCT
hdr NMHDR <>
lpOFN DWORD ?
pszFile DWORD ? ; May be NULL
OFNOTIFYA ENDS
FALSE
Quote
OFNOTIFY.lpOFN <--- cut it ------------------ OPENFILENAME.nFilterIndex
lpOFN must be a pointer on OPENFILENAME
mov eax,dword ptr [eax].OFNOTIFY.lpOFN
mov eax,dword ptr [eax].OPENFILENAME.nFilterIndex
Thanks for your answer.
Yes I know this was wrong but the main problem is that lParam not will send the notification notices. lParam seem not to point to an OFNOTIFY structure
Verify that the WM_NOTIFY message is send to the hookproc and not to the mother window.
To verify that create a WM_NOTIFY in the mother window and filter the handle of the dialog.
yes, I have verifyed that WM_NOTIFY is sent to hookprocess.
IT is a WM_NOTIFY but another can be send to the mother,is that you need to verify
I looked in windows.inc and this is the constants
CDN_INITDONE equ 0000h
CDN_SELCHANGE equ 0001h
CDN_FOLDERCHANGE equ 0002h
CDN_SHAREVIOLATION equ 0003h
CDN_HELP equ 0004h
CDN_FILEOK equ 0005h
CDN_TYPECHANGE equ 0006h
CDN_INCLUDEITEM equ 0007h
The same in Commdlg.h is
#define CDN_FIRST (0U-601U)
#define CDN_LAST (0U-699U)
// Notifications when Open or Save dialog status changes
#define CDN_INITDONE (CDN_FIRST - 0x0000)
#define CDN_SELCHANGE (CDN_FIRST - 0x0001)
#define CDN_FOLDERCHANGE (CDN_FIRST - 0x0002)
#define CDN_SHAREVIOLATION (CDN_FIRST - 0x0003)
#define CDN_HELP (CDN_FIRST - 0x0004)
#define CDN_FILEOK (CDN_FIRST - 0x0005)
#define CDN_TYPECHANGE (CDN_FIRST - 0x0006)
#define CDN_INCLUDEITEM (CDN_FIRST - 0x0007)
What is 0U-601U. This could be the reson to failur.
Nothing is sent to the mother.
I have this values in the ready to use SDK
Quote
CDN_FIRST equ < 0 - 601>
CDN_LAST equ < 0 - 699>
; Notifications from Open or Save dialog
CDN_INITDONE equ < CDN_FIRST - 00000h>
CDN_SELCHANGE equ < CDN_FIRST - 00001h>
CDN_FOLDERCHANGE equ < CDN_FIRST - 00002h>
CDN_SHAREVIOLATION equ < CDN_FIRST - 00003h>
CDN_HELP equ < CDN_FIRST - 00004h>
CDN_FILEOK equ < CDN_FIRST - 00005h>
CDN_TYPECHANGE equ < CDN_FIRST - 00006h>
IF ( NTDDI_VERSION GE NTDDI_WIN2K)
CDN_INCLUDEITEM equ < CDN_FIRST - 00007h>
ENDIF ; (NTDDI_VERSION >= NTDDI_WIN2K)
CDM_FIRST equ < WM_USER + 100>
CDM_LAST equ < WM_USER + 200>
seems to me that you need an ASSUME, maybe PTR ???
maybe the problem is that the assembler does not know that EAX points to the base of the structure
the forum search tool may help - "assume ptr structure"
What is the ready to use SDK and how do I use these constants?
The ready to use SDk is a translate of the WIN7 SDk made by my translator and dowloadable in the masm32 forum,windows.inc subforum.
To make a test:
Copy the values in your source:
add a A to each one to avoid redifinitions and modify your condition with the new value.
If it don't work,take care it is negative values and you need perhaps to put them in a SDWORD before used them in a condition
svalue SDWORD 0
mov eax,dword ptr [eax].NMHDR.code
mov svalue,eax
.if svalue==ACDN_TYPECHANGE
This must be tested in case of failure
l
.if uMsg==WM_INITDIALOG
invoke GetDlgItem,hWin,IDC_TRB2
mov hTRB2,eax
mov eax,FALSE
ret
.elseif uMsg==WM_NOTIFY
ASSUME eax:PTR OFNOTIFY
mov eax,lParam
mov eax,dword ptr [eax].NMHDR.code
.if eax==CDN_INITDONE ;code=0
.elseif eax==CDN_FOLDERCHANGE ;code=2
.elseif eax==CDN_HELP ;code=4
.elseif eax==CDN_INCLUDEITEM ;code=7
.elseif eax==CDN_FILEOK ;code=5
.elseif eax==CDN_SELCHANGE ;code=1
.elseif eax==CDN_SHAREVIOLATION ;code=3
.elseif eax==CDN_TYPECHANGE ;code=6
mov eax,lParam
mov eax,dword ptr [eax].lpOFN.OPENFILENAME.nFilterIndex ;note the change here
ASSUME eax:NOTHING
.if eax==2
invoke ShowWindow,hTRB2,SW_SHOW
.endif
.endif
mov eax,FALSE
ret
Before your answer I tryed this and it did work
.elseif uMsg==WM_NOTIFY
mov ecx,lParam
mov ecx,dword ptr [ecx].NMHDR.code
mov eax,CDN_FIRST
sub eax,ecx
.if eax==CDN_INITDONE ;code=0
I will try your suggestion also
edited previous post
i noticed here....
mov eax,dword ptr [eax].NMHDR.code
then, here, you had....
mov eax,dword ptr [eax].OFNOTIFY.lpOFN.OPENFILENAME.nFilterIndex
(with OFNOTIFY)
unreleated: "dword ptr" is not needed in these lines, so long as code and cnFilterIndex are dwords
moving into eax, it cannot be anything else
dedndave, your suggestion didn't work.
ToutEnMasm, your suggestion did work with sdword ptr eax.
Thank you both for your help
The issue in Windows.inc with the CDN_xxx values has been brought up before:
http://www.masm32.com/board/index.php?topic=10497.msg76918#msg76918
I could have an old version of the includes (I don't use them much) so it may well be that the equates have already been fixed but they are still incorrect in my version.
Edgar