Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to retrieve an Icon for a type of document?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00898645
Message ID:
00898694
Vues:
17
>>>>Hi, All,
>>>>
>>>>My application stores references to files created externally, e.g. Word documents, excel,text,PDF etc., which are tied to a user's assignment record.
>>>>
>>>>Is there an easy way to retrieve an ICON image for a document type?
>>>>For example,for documents with .txt extension I would like to retrieve the Notepad icon or whatever is registered in the OS. That way I can accurately display the document types as images to the users when they view the references on a form.
>>>>
>>>>Any help will be appreciated,
>>>>
>>>Dawa,
>>>
>>>Is this for simply display or do you want to extract the icon and save it?
>>
>>Yes, just to display.
>
>You might have some problems with stability of the image. I use this method to display my application's icon in my About dialog class.
DECLARE SHORT DrawIcon IN Win32API;
>  INTEGER Hdc, INTEGER X, INTEGER Y, INTEGER hIcon
>* You'll need to replace the following declaration
>DECLARE INTEGER ExtractIcon IN Shell32;
>  INTEGER hInst, STRING @lpszExeFileName, INTEGER nIconIndex
>* with the following.
>DECLARE INTEGER ExtractAssociatedIcon IN Shell32;
>  INTEGER hInst, STRING @lpszExeFileName, INTEGER nIconIndex
>DECLARE INTEGER GetClassLong IN Win32API;
>  INTEGER hWnd, INTEGER nIndex
>DECLARE INTEGER GetDC IN Win32API;
>  INTEGER hWnd
>DECLARE INTEGER ReleaseDC IN Win32API;
>  INTEGER hwnd, INTEGER hdc
Now you should add the following properties to the form: HInstance, HDc, and HIcon and assign them as follows
ThisForm.HInstance = GetClassLong(ThisForm.HWnd, -16)
>ThisForm.HDc = GetDC(ThisForm.HWnd)
>ThisForm.HIcon = ExtractAssociatedIcon(ThisForm.HInstance, lcfilename, 0)
Now in the Paint and Show methods of the form
= DrawIcon(This.HDc, 12, 12, This.HIcon)
This displays the icon at 12, 12 (pixels) of the form's client area.
>
>You then shoud clean up with
= ReleaseDC(This.HWnd, This.HDc)
in the form's destroy event.
>
>One problem you'll note is the if the form or desktop is minimized, the icon won't necessarily be re-drawn.
>
>If you have any other questions, let me know.

Well, this would help me extract the icon associated with an exe. This means that I need to know the application that handles the type of document that the user added to his assignment. How do get to the exe that is associated with an exe? Is this how window explorer extracts the icons for the registered documents?

Dawa
Dawa Tsering


"Do not let any unwholesome talk come out of your mouths,
but only what is helpful for building others up according to their needs,
that it may benefit those who listen."

- Ephesians 4:29-30 NIV

Dare to Question -- Care to Answer

Time is like water in a sponge, as long as you are willing you can always squeeze some.

--Lu Xun, Father of Modern Chinese Literature

Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform