Programming acquisition icon

zhaozj2021-02-08  299

Programming Obtaining Icon First Agapi (2000-09-24) In the program, when you need to get an icon of other programs, we can first call the SDK function ShgetFileInfo to get information about the application, and utilize the obtained Hicon handle implement icon display. For example, if you need to display a Word board icon in the upper left corner of the program window (see Figure 1), you can add the following code in the corresponding view class onDRAW: Void CsampleView: OnDRAW (CDC  PDC) {// Get icon information if (: Shgetfileinfo (_t (c: // w w "), 0, && stfileinfo, size") {// uses the Drawicon interface of the device description table to display the obtained icon information PDC - > Drawicon (10, 10, strileinfo.hicon);}} You can also call the Extracticon function to get the icon information of the application, and call the Drawicon function of the device descriptor to complete the icon display. Void CsampleView :: Ondraw (CDC PDC) { Hicon Hicon = :: Extracticon (AFXGETITISTANCEHANDLE (), _ T ("C: // Program Files // Accessories // WordPad.exe"), 0); IF (Hicon &&& Hicon! = (HICON) -1) PDC-> Drawicon (10, 10, hicon);} Figure 1 Interested readers may wish to try.

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

New Post(0)