ImageGear for C and C++ on Windows v20.0 - Updated
LPFNIG_GUITHUMBTITLE
API Reference Guide > Core Component API Reference > Core Component Callback Functions Reference > LPFNIG_GUITHUMBTITLE

This callback function allows you to change the title of a thumbnail.

Declaration:

 
Copy Code
typedef BOOL (ACCUAPI LPFNIG_GUITHUMBTITLE)(
        LPVOID lpPrivate, 
        HWND hwndThumbnail, 
        const LPSTR lpszFileName, 
        const LPAT_DIB lpDIB, 
        UINT nPageNumber, 
        LPSTR lpszTitle
);

Arguments:

Name Type Description
lpPrivate LPVOID A far pointer to any private data that you would like to pass.
hwndThumbnail HWND The Windows handle to the Thumbnail window.
lpszFileName const LPSTR A far pointer that is set to the filename of the thumbnail just loaded.
lpDIB const LPAT_DIB A far pointer to a structure of type AT_DIB. This is set to the Thumbnail's image info.
nPageNumber UINT An integer variable that is set to the Thumbnail page number.
lpszTitle LPSTR A far pointer to the string you would like to use as a Title to use for this thumbnail. The string length must not exceed 260 characters.

Return Value:

If this callback returns TRUE, the title of a thumbnail icon is changed to the title returned by this callback function. Otherwise, if the return value is FALSE, the title will not be changed.

Supported Raster Image Formats:

All pixel formats supported by ImageGear for C and C++.

Sample:

Thumbnail

Example:

 
Copy Code
HIGEAR hIGear;          /* HIGEAR handle of image */
UINT nThumbTitle = ID_OPTIONS_SETTHUMBNAILTITLES_FILENAME;
UINT nThumbTitleHeight = 10;      /* thumbnail title height */
LPFNIG_GUITHUMBTITLE MyThumbTitleFunc; /* Callback for setting titles */
nErrCount = IG_GUI_thumbnail_title_CB_register(hwndThumb,
MyThumbTitleFunc,(LPVOID)&nThumbTitle);
nErrcount = IG_GUI_thumbnail_attribute_set(hwndThumb,IG_GUI_THUMBNAIL_TITLE_HEIGHT,
(LPVOID)(DWORD)nThumbTitleHeight);
/*************************************************************************/
/* Callback function that sets the name of a thumbnail title. */
/*************************************************************************/
BOOL ACCUAPI MyThumbTitleFunc(
   LPVOID            lpPrivate,      /* Private data passed in   */
   HWND              hwndThumbnail,  /* Thumbnail window handle  */
   const LPSTR       lpszFileName,   /* File name of thumbnail   */
   const LPAT_DIB    lpDIB,          /* Thumbnail image info     */
   UINT              nPageNumber,    /* Thumbnail page number */
   LPSTR             lpszTitle       /* Title to use for this icon*/
)
{
        UINT nThumbTitle;
        CHAR szPath[_MAX_PATH];
        LPSTR lpTitle;
        struct _stat  statBuf;
        nThumbTitle = *(LPUINT)lpPrivate;
        switch (nThumbTitle)
        {
        case ID_OPTIONS_SETTHUMBNAILTITLES_FILENAME:
                #ifndef WIN32
                        lpTitle = _fstrrchr(lpszFileName, '\\');
                #else
                        lpTitle = strrchr(lpszFileName, '\\');
                #endif
                if (lpTitle)
                        lpTitle++;
                else
                lpTitle = lpszFileName;
                lstrcpy(lpszTitle, lpTitle);
                AnsiLower(lpszTitle);
                break;
        case ID_OPTIONS_SETTHUMBNAILTITLES_FILEDATE:
                lstrcpy(szPath, lpszFileName);
                _stat(szPath, &statBuf);
lstrcpy(lpszTitle, ctime(&statBuf.st_atime));
                break;
        case ID_OPTIONS_SETTHUMBNAILTITLES_FILESIZE:
                lstrcpy(szPath, lpszFileName);
                _stat(szPath, &statBuf);
                wsprintf(lpszTitle, "%ld Bytes", statBuf.st_size);
                break;
        case ID_OPTIONS_SETTHUMBNAILTITLES_BITSPERPIXEL:
                if (lpDIB->biBitCount == 1)
                        wsprintf(lpszTitle, "%d Bit Per Pixel", lpDIB-
                                >biBitCount);
                else
                        wsprintf(lpszTitle, "%d Bits Per Pixel", 
                                lpDIB->biBitCount);
                break;
        case ID_OPTIONS_SETTHUMBNAILTITLES_PAGENUMBER:
                wsprintf(lpszTitle, "Page %d", nPageNumber);
                break;
        }
        return TRUE;
}       

Remarks:

This function is called when a thumbnail is first loaded. The default title of a thumbnail is its filename. You can override the filename with anything you want. For example, the title might include the filename followed by page number, file size, file date, etc. You must register this function first by calling the IG_GUI_thumbnail_title_CB_register() function.

Is this page helpful?
Yes No
Thanks for your feedback.