flat assembler
Message board for the users of flat assembler.

Index > Windows > [solved] How do I enable the Help button in file dialogs?

Author
Thread Post new topic Reply to topic
fasm14



Joined: 23 Jan 2021
Posts: 14
Location: Russia
fasm14 21 Jun 2021, 15:51
Hello! I was trying to enable the help button in an OpenFile dialog;
Code:
...
mov [_OpenFile.Flags], OFN_FILEMUSTEXIST+OFN_SHOWHELP
...
invoke GetOpenFileNameW, _OpenFile    

According to the documentation, I needed to register the help message, so I did this:
Code:
themessage du 'HELPMSGSTRING', 0
...
invoke RegisterWindowMessageW, themessage
mov [msgid], eax
...
proc DProc hwnddlg, msg, wparam, lparam 
mov eax, [msgid]
cmp [msg], eax
je ExitProgram    

but nothing happened when I clicked the help button! I tried this with RegisterWindowMessageA and an ASCII string but nothing changed... Can someone please share an example of how to use this button?
Post 21 Jun 2021, 15:51
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4079
Location: vpcmpistri
bitRAKE 22 Jun 2021, 04:29
Maybe it's an explorer style and the hook proc is getting CDN_HELP notifications?

These things have changed so much through windows versions. If I created an example it's going to be the new notification mechanism.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 22 Jun 2021, 04:29
View user's profile Send private message Visit poster's website Reply with quote
fasm14



Joined: 23 Jan 2021
Posts: 14
Location: Russia
fasm14 22 Jun 2021, 08:44
The hook flag wasn't set before, but when I added it and a pointer to a procedure, it started receiving WM_NOTIFY messages; according to this, lparam has a pointer to an OFNOTIFY structure, with the notification message being the third dword in it, but when I do this
Code:
mov ebx, [lparam]
mov eax, [ebx]    
the app crashes (access violation, I assume?); running it with admin permissions doesn't change anything... Am I misunderstanding something?
Post 22 Jun 2021, 08:44
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4079
Location: vpcmpistri
bitRAKE 22 Jun 2021, 18:40
lParam is a pointer - NOT has a pointer.

(Do you use a debugger? Just throwing an INT3 in there and running would allow you to see what is happening.)

The wording is rather brief in the English version - wonder if the Russian is any better?

https://docs.microsoft.com/ru-ru/windows/win32/dlgbox/cdn-help

Funny, enough google translation of the Russian is more exact than the English, lol!

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 22 Jun 2021, 18:40
View user's profile Send private message Visit poster's website Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 794
Location: Adelaide
sinsi 22 Jun 2021, 20:53
HELPMSGSTRING is defined in the C++ headers as
Code:
#define HELPMSGSTRING TEXT("commdlg_help")    

Shouldn't your code use this?
Code:
themessage du "commdlg_help",0
    
Post 22 Jun 2021, 20:53
View user's profile Send private message Reply with quote
fasm14



Joined: 23 Jan 2021
Posts: 14
Location: Russia
fasm14 23 Jun 2021, 13:31
bitRAKE wrote:
lParam is a pointer - NOT has a pointer.

Thanks, I managed to get the -605 (CDN_HELP) code from lparam in the hook procedure with
Code:
mov ebx, [lparam]
mov ebx, [ebx+8]    

Replacing "HELPMSGSTRING" with
sinsi wrote:
Code:
themessage du "commdlg_help",0    
also works, making it send messages to the main dialog procedure! Thanks a lot!
Post 23 Jun 2021, 13:31
View user's profile Send private message Reply with quote
fasm14



Joined: 23 Jan 2021
Posts: 14
Location: Russia
fasm14 24 Jun 2021, 08:43
I now realized that this
Code:
mov ebx, [lparam]
mov eax, [ebx]    
wasn't the problem, and the reason this
Code:
mov ebx, [lparam]
mov ebx, [ebx+8]    
worked is because I added
Code:
cmp [msg], WM_NOTIFY
je continue1
ret
continue1:    
right before it in the hook procedure; it was crashing because other WM messages set lparam to 0 and it tried to read memory there (I think)
Post 24 Jun 2021, 08:43
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4079
Location: vpcmpistri
bitRAKE 25 Jun 2021, 01:07
My comment was in error. Too much time in 64-bit. Embarassed

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 25 Jun 2021, 01:07
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.