Internet Explorer Programming Brief (3) "Solving Favorites" dialog

xiaoxiao2021-03-06  58

About Internet Explorer's favorites, more common two questions are to call the "Final Collection" dialog and Add to Favorites dialog. There are many ways to call, but there are still some places worth discussing.

Keywords: Add to Favorites, Sash Favorites, DoorGanizefavdlg

1, finishing favorites

Call the "Solving Favorites" dialog (below), basically use the same method, that is, call the "doorganizefavdlg" function in "shdocw.dll", transfer the parent window handle and favorites path as the parameter can.

2, code

The code example is as follows, it is worth noting that the processing of "shdocvw.dll" is to avoid duplicate calls, you should check if it is already in memory.

Void CMYHTMLVIEW :: onfavorganizefav () {typedef uint (callback * lpfnorgfav) (HWND, LPTSTR);

Bool Bresult = false;

HModule hmod = :: getModuleHandle (_t ("shdocvw.dll"));

IF (hmod == null) // If "shdocvw.dll" is not loaded, load {hmod = :: loadLibrary (_t ("shdocvw.dll"));

if (hMod == NULL) {MessageBox ( ". The dynamic link library ShDocVw.DLL can not be found" _T (), _T ( "Error"), MB_OK | MB_ICONSTOP); return;} LPFNORGFAV lpfnDoOrganizeFavDlg = (LPFNORGFAV) :: GetProcaddress (HMOD, "Doorganizefavdlg");

if (lpfnDoOrganizeFavDlg == NULL) {MessageBox (_T ( "The entry point DoOrganizeFavDlg can not be found / n") _T ( "in the dynamic link library ShDocVw.DLL."), _T ( "Error"), MB_OK | MB_ICONSTOP) Return;}

Tchar Szpath [MAX_PATH]; HRESULT HR;

HR = :: ShgetspecialFolderPath (M_HWND, SZPATH, CSIDL_FAVORITES, TRUE); if (Failed (HR)) {MessageBox (_T ("The path of the favorites folder cannot be found), _t (" error "), MB_OK | MB_ICONSTOP); RETURN;}

BRESULT = (* lpfndoorganizefavdlg) (M_HWND, SZPATH)? True: false;

: FreeLibrary (HMOD);} else // If "ShDocvw.dll" has been used directly in the address space of the caller process. {LPFNORGFAV lpfnDoOrganizeFavDlg = (LPFNORGFAV) :: GetProcAddress (hMod, "DoOrganizeFavDlg"); if (lpfnDoOrganizeFavDlg == NULL) {MessageBox (_T ( "The entry point DoOrganizeFavDlg can not be found / n") _T ( "in the dynamic link library SHDOCVW.DLL. "), _T (" error "), MB_OK | MB_ICONSTOP); Return;}

Tchar Szpath [MAX_PATH]; HRESULT HR;

HR = :: ShgetspecialFolderPath (M_HWND, SZPATH, CSIDL_FAVORITES, TRUE); if (Failed (HR)) {MessageBox (_T ("The path of the favorites folder cannot be found), _t (" error "), MB_OK | MB_ICONSTOP); RETURN;}

BRESULT = (* lpfndoorganizefavdlg) (M_HWND, SZPATH)? True: false;}

Return;

}

3. Discussion In fact, the prototype declaration from the "Doorganizefavdlg" function we can see that because a path is required, the "Solving Favorites" dialog is actually not only used to organize the favorites, but also organize the directory on the disk. And the so-called finishing is also provided with a dialog that makes the user more convenient, and it is not substantial differences directly in the resource manager. Therefore, the method of calling the "Saturing Favorites" dialog has not changed from IE4.0, except for the layout of the dialog. TypeDef uint (Callback * lpfnorgfav) (HWND, LPTSTR); IE 4.0 "Solving Favorites" dialog

IE 4.0's "Solving Favorites" dialog (original design)

"Add to Favorites" is different, the "doaddtofavdlg" function is no longer like the "Doorganizefavdlg" function is available on all IE versions.

Reference:

MSDN: Adding Internet Explorer Favorites To your application

Quote address: Internet Explorer programming brief description (3) "Solving Favorites" dialog

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

New Post(0)