Make Edit Controls automatically complete features.

xiaoxiao2021-03-06  71

Link: Enable Auto-Complete On your Edit Controls in VC Auto-Complete Edit and Combo, WITHOUT Platform SDK 1. Static link - (Note: IE5 or more). Here's an esample:

#include

#include

#pragma Comment (Lib, "Shlwapi.lib")

LResult Callback MyDialogProc (HWND HWND, UINT UMSG, WPARAM WPARAM, LPARAM LPARAM)

{

Switch (UMSG)

{

Case WM_INITDIALOG:

HWND HFILEPATH;

Coinitialize (NULL);

HfilePath = getdlgitem (hwnd, id_filepath);

Shautocomplete (HfilePath, Shacf_Default);

Break;

Case WM_DESTROY:

Couninitialize ();

PostquitMessage (0);

Break;

}

}

2. Dynamic call: The Wrapper Function. // See The msdn for shautocomplete for a full // description of what these options do.

#define shacf_default 0x00000000

#define shacf_filesystem 0x00000001

#define shacf_urlall (Shacf_urlhistory | SHACF_URLMRU)

#define shacf_urlhistory 0x00000002

#define shacf_urlmru 0x00000004

#define shacf_usetab 0x00000008

#define shacf_filesys_only 0x00000010

#define shacf_autosuggest_force_on 0x10000000

#define shacf_autosuggest_force_off 0x20000000

#define shacf_autoAppend_force_on 0x40000000

#define shacf_autoAppend_force_off 0x80000000

TypeDef HRESULT (WinApi * Shautocompletefn)

HWND HTARGET, DWORD DWFLAGS;

Static Hinstance HSHLWAPIDLL = NULL;

Bool SetupForautocomplete (HWND HTARGET, DWORD DWFLAGS)

{

IF (htarget == null)

{

Return False;

}

Bool OK = false;

IF (HSHLWAPIDLL == NULL)

{

HSHLWAPIDLL = LoadLibrary ("shlwapi.dll");

IF (HSHLWAPIDLL == NULL)

{

Return False;

}

}

Shautocompletefn pshac = (shautocompletefn) GetProcaddress (HSHLWapidll,

"Shautocomplete");

IF (pshac! = null)

{

OK = succeeded (pshac (htarget, dwflags);

}

Return OK;

} Call: BOOL CMYDIALOG :: OnItDialog () {... // enable auto completion for m_myedit setupForautocomplete (m_myedit.m_hwnd, shacf_filesystem); ...}

转载请注明原文地址:https://www.9cbs.com/read-60687.html

New Post(0)