简体   繁体   中英

How to prevent GetSaveFileName from automatically highlighting the filename edit box

In Windows 7, the GetSaveFileName dialog automatically highlights the filename edit box. It does it when the dialog initiates, when focus is lost and regained to the dialogbox and when the filename edit box is clicked on. Its really annoying. How do I disable it?

If you look at comdlg32.dll (Windows 7 only) using W32dasm

:6F0683D3        push    FFFFFFFF
:6F0683D5        push    00000000
:6F0683D7        push    000000B1
:6F0683DC        add     ecx, FFFFFFA4
:6F0683DF        call    6F0569B8
:6F0683E4        push    eax
  • Reference To: USER32.SendMessageW, Ord:027Ch

    :6F0683E5 call dword ptr [6F051230]

You will immediately know that line 3 (push 000000B1) is calling Sendmessage EM_SETSEL to the filename editbox.

winuser.h contains the id's of the messages.

#define EM_GETSEL               0x00B0
#define EM_SETSEL               0x00B1
#define EM_SETMARGINS           0x00D3

So if you use a hex editor to change B1 to D3 it won't be calling EM_SETSEL anymore, but you do have to be careful what message you're diverting it to.

You will have to create another Windows installion on another drive to edit comdlg32.dll in the system32 folder, while that Windows installation isn't running.

That is a really annoying problem, you have to click on the filename edit box 3 times before it unhighlights and you can start using it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM