//****************************************************************************// // // // $File name : cIconPanel.pkg // // $File title : Support of taskbaricons for visual dataflex applications // // Notice : // // $Author(s) : Oliver Nelson // // // // $Rev History // // // // SB 16/12/99 File created // // 11/03/00 CREATEDIBSECTION added to fix color problems // // // // Under Windows 95, Windows 98, and Windows NT 4.0, each application is // // associated with two icons: a small icon (16x16) and a large icon (32x32). // // The small icon is displayed in the upper-left hand corner of the // // application and on the taskbar. // // The large icon is displayed when you press the Alt-TAB key-combination // // // // Seee the readme.html for more details // //****************************************************************************// // // Use VdfBase.pkg Use Dfclient.pkg // declarations of constants needed for the API calls Define WM_SETICON For |CI$0080 Define ILD_NORMAL For |CI$0000 Define LR_LOADFROMFILE For |CI$0010 Define LR_LOADTRANSPARENT FOR |CI$0020 Define LR_CREATEDIBSECTION For |CI$2000 Define ICON_SMALL For 0 Define ICON_LARGE For 1 Define IMAGE_BITMAP For 0 Define IMAGE_ICON For 1 Define IMAGE_CURSOR For 2 External_function ImageList_GetIcon "ImageList_GetIcon" comctl32.dll Handle himl Integer iIndex Handle iStyle Returns Handle #IFDEF GET_DestroyIcon #ELSE external_function DestroyIcon "DestroyIcon" user32.dll Handle hIcon Returns Integer #ENDIF #IFDEF GET_ImageList_Destroy #ELSE External_function ImageList_Destroy "ImageList_Destroy" comctl32.dll Handle himl Returns Integer #ENDIF #IFDEF GET_ImageList_LoadImage #ELSE External_function ImageList_LoadImage "ImageList_LoadImage" comctl32.dll Handle Hi Pointer lpbmp ; Integer cx Integer cGrow Integer crMask Integer uType Integer uFlags Returns Integer #ENDIF Class cIconPanel_Mixin Is a Mixin Procedure Define_cIconPanel_Mixin Property String private.psLargeTaskbarIcon "" Property String private.psSmallTaskbarIcon "" Property Integer private.piTransparentColor (rgb(255,255,255)) Property Integer private.piTaskbarIconStyle IMAGE_BITMAP Property Handle hpLargeIL 0 Property Handle hpSmallIL 0 Property Handle hpSmallIcon 0 Property Handle hpLargeIcon 0 End_Procedure // Use this to set the filename of the large taskbaricon. This is the // icon users will see if they press the key-combination alt-tab. // Example: Set LargeTaskbarIcon To "file32.bmp" Procedure Set LargeTaskBarIcon String sFileName Set Private.psLargeTaskbarIcon To sFileName End_Procedure // Set LargeTaskBarIcon Function LargeTaskBarIcon Returns String Function_Return (private.psLargeTaskbarIcon(Self)) End_Function // LargeTaskBarIcon // Use this to set the filename of the small taskbaricon. This is the // icon that you see in the taskbar next to te start-button and in the topleft-corner // of the application. // Example: Set LargeTaskbarIcon To "file32.bmp" Procedure Set SmallTaskBarIcon String sFileName Set private.psSmallTaskbarIcon To sFileName End_Procedure // Set SmallTaskBarIcon Function SmallTaskBarIcon Returns String Function_Return (private.psSmallTaskbarIcon(Self)) End_Function // SmallTaskBarIcon // This will set the transparantcolor of the icons. You can // set it to normal rgb values. // Example: Set IcontransparantColor To clGray Procedure Set IconTransparentColor Integer iColor Set private.piTransparentColor To iColor End_Procedure // Set IconTransparentColor Function IconTransparentColor Returns Integer Function_Return (private.piTransparentColor(Self)) End_Function // IconTransparentColor // Use this to set the style of the tasskbaricon. // Valid values are: IMAGE_BITMAP, IMAGE_ICON and IMAGE_CURSOR // At the moment only the IMAGE_BITMAP style is supported. Procedure Set TaskbarIconStyle Integer iStyle Set private.piTaskbarIconStyle To iStyle End_Procedure // Set TaskbarIconStyle Function TaskbarIconStyle Returns Integer Function_Return (private.piTaskbarIconStyle(Self)) End_Function // TaskbarIconStyle // A function to retrieve the full pathname of the icon. // If a workspace is defined it will first look in the programpath and // if the icon is not present it will look into the bitmappath after that. // When no workspacename is defined the normal iconname is returned and // the program assumes that the icon resides in the same folder as the program. Function IconFullPathName String sIcon Returns String Get_File_Path sIcon To sIcon Function_Return sIcon End_Function // IconFullPathName // This procedure actually sets the taskbaricons. // Note that in here image_lists are created directly in windows. Its not necessary to // create dataflex imagelists for this. Procedure DoSetTaskBarIcon Handle hLargeIcon hWndImageList hIcon hTemp Integer iRetVal Integer iTransparentColor iTaskbarIconStyle String sFile Pointer pFile Get IconTransparentColor To iTransparentColor Get TaskbarIconStyle To iTaskbarIconStyle Move (IconFullPathName(self,(LargeTaskBarIcon(self)))) to sFile Move (sFile + (Character(0))) to sFile getaddress Of sFile to pFile Move (OemToAnsi(pFile,pFile)) to iRetVal Move (ImageList_LoadImage(0,pFile, 32, 0, iTransparentColor, ; iTaskbarIconStyle, (LR_LOADFROMFILE + LR_CREATEDIBSECTION))) To hWndImageList If hWndImageList Begin Move (ImageList_GetIcon(hWndImageList, 0, ILD_NORMAL)) To hIcon Send Windows_Message WM_SETICON ICON_LARGE hIcon Set hpLargeIL To hWndImageList Set hpLargeIcon To hIcon End // hWndImageList Move (IconFullPathName(self,(SmallTaskBarIcon(self)))) to sFile Move (sFile + (Character(0))) to sFile getaddress Of sFile to pFile Move (OemToAnsi(pFile,pFile)) to iRetVal Move (ImageList_LoadImage(0, pFile, 16, 0, iTransparentColor, ; iTaskbarIconStyle, (LR_LOADFROMFILE + LR_CREATEDIBSECTION))) To hWndImageList If hWndImageList Begin Move (ImageList_GetIcon(hWndImageList, 0, ILD_NORMAL)) To hIcon Send Windows_Message WM_SETICON ICON_SMALL hIcon Set hpSmallIL To hWndImageList Set hpSmallIcon To hIcon End // hWndImageList End_Procedure // DoSetTaskBarIcon // Release the resources that were claimed for te taskbaricons and their // imagelists. Procedure DoDestroyIconResources Integer iRet If (hpLargeIL(Self)) Begin Move (ImageList_Destroy( (hpLargeIL(self)) )) to iRet Move (DestroyIcon( (hpLargeIcon(self)) )) to iRet End If (hpSmallIL(Self)) Begin Move (ImageList_Destroy( (hpSmallIL(self)) )) to iRet Move (DestroyIcon( (hpSmallIcon(self)) )) to iRet End End_Procedure // DoDestroyIconResources End_Class // The following can be skipped if you only need the mixin and have not included the basicpanel DF class // in your program. #IFDEF U_BasicPanel Class cIconBasicPanel Is a BasicPanel Import_Class_Protocol cIconPanel_Mixin Procedure Construct_Object Property Boolean pbShuttingDown False Forward Send Construct_Object Send Define_cIconPanel_Mixin End_Procedure // Construct_Object Procedure Page_Object Integer bState Forward Send page_object bState If BuildingObjectId Eq 0 Begin If bState Eq 1 Send DoSetTaskBarIcon End End_Procedure // Page_Object // Alt-F4, X-button Procedure Exit_Application Send DoDestroyIconResources Set pbShuttingDown To True Forward Send Exit_Application End_Procedure // Exit_Application // A close_panel request has been sent. // This will quit the application, but the exit_application message is never // sent. Procedure Close_Panel Send DoDestroyIconResources Set pbShuttingDown To True Forward Send Close_Panel End_Procedure // Close_Panel End_Class // cIconPanel #ENDIF // So if you only need the mixin and dont have included the used DF classes... #IFDEF U_Panel Class cIconPanel Is a Panel Import_Class_Protocol cIconPanel_Mixin Procedure Construct_Object Property Boolean pbShuttingDown False // Set to true when the hammer is closed Property Boolean pbWorkspaceChanging False // Set to true when the hammer changes workspaces Forward Send Construct_Object Send Define_cIconPanel_Mixin End_Procedure Procedure Page_Object Integer bState Forward Send page_object bState If BuildingObjectId Eq 0 Begin If bState Eq 1 Send DoSetTaskBarIcon End End_Procedure // Alt-F4, X-button Procedure Exit_Application Send DoDestroyIconResources Set pbShuttingDown To True Forward Send Exit_Application End_Procedure // A close_panel request has been sent. // This will quit the application, but the exit_application message is never // sent. Procedure Close_Panel Send DoDestroyIconResources Set pbShuttingDown To True Forward Send Close_Panel End_Procedure End_Class #ENDIF