$PBExportHeader$u_displayicon.sru forward global type u_displayicon from userobject end type end forward global type u_displayicon from userobject integer width = 146 integer height = 128 boolean enabled = false long backcolor = 79741120 long tabtextcolor = 33554432 long picturemaskcolor = 536870912 event redraw pbm_ncpaint end type global u_displayicon u_displayicon type prototypes Function long ExtractIcon ( & long hInst, & string lpszExeFileName, & ulong nIconIndex & ) Library "shell32.dll" Alias For "ExtractIconW" Function boolean DestroyIcon ( & long hIcon & ) Library "user32.dll" Function integer DrawIcon ( & long hDC, & long xpos, & long ypos, & long hIcon & ) Library "user32.dll" Function long GetDC ( & long hWnd & ) Library "user32.dll" Function integer ReleaseDC ( & long hWnd, & long hDC & ) Library "user32.dll" Function long GetModuleFileName ( & long hModule, & ref string lpFileName, & long nSize & ) Library "kernel32.dll" Alias For "GetModuleFileNameW" end prototypes type variables Application ia_app Long il_handle end variables forward prototypes public subroutine of_loadicon (string as_filename) public subroutine of_drawicon () public subroutine of_loadicon () public subroutine of_loadicon (string as_filename, unsignedlong aul_index) public function long of_iconcount (string as_filename) public function string of_pbvmname () end prototypes event redraw;// draw the icon Post of_DrawIcon() end event public subroutine of_loadicon (string as_filename);// load first icon from file of_LoadIcon(as_filename, 0) end subroutine public subroutine of_drawicon ();// draw the current icon Long ll_hDC ll_hDC = GetDC(Handle(This)) DrawIcon(ll_hDC, 0, 0, il_handle) ReleaseDC(Handle(This), ll_hDC) end subroutine public subroutine of_loadicon ();// load icon from current exe String ls_module Long ll_rc ls_module = Space(256) ll_rc = GetModuleFileName(Handle(ia_app), ls_module, 256) If ll_rc > 0 Then of_LoadIcon(ls_module) End If end subroutine public subroutine of_loadicon (string as_filename, unsignedlong aul_index);// load icon from file // release icon handle If il_handle > 0 Then DestroyIcon(il_handle) End If // extract icon from file and load into memory il_handle = ExtractIcon(Handle(ia_app), as_filename, aul_index) // erase the background BackColor = BackColor // draw the icon of_DrawIcon() end subroutine public function long of_iconcount (string as_filename);// return count of icons within the file Long ll_count ll_count = ExtractIcon(Handle(ia_app), as_filename, -1) Return ll_count end function public function string of_pbvmname ();// This function the name of the PowerBuilder VM file. Environment le_env String ls_vmname Integer li_major, li_minor GetEnvironment(le_env) li_major = le_env.PBMajorRevision li_minor = le_env.PBMinorRevision choose case li_major case 10, 11, 12, 17 choose case li_minor case 5 ls_vmname = "pbvm" + String(li_major) + "5.dll" case 6 ls_vmname = "pbvm" + String(li_major) + "6.dll" case else ls_vmname = "pbvm" + String(li_major) + "0.dll" end choose case 19 If li_minor < 2 Then ls_vmname = "pbvm190.dll" Else ls_vmname = "pbvm.dll" End If case else ls_vmname = "pbvm.dll" end choose Return ls_vmname end function on u_displayicon.create end on on u_displayicon.destroy end on event destructor;// release icon handle If il_handle > 0 Then DestroyIcon(il_handle) End If end event event constructor;// set backcolor to match parent window Window lw_parent UserObject lu_parent choose case GetParent().TypeOf() case UserObject! lu_parent = GetParent() this.BackColor = lu_parent.BackColor case Window! lw_parent = GetParent() this.BackColor = lw_parent.BackColor end choose ia_app = GetApplication() end event
- Sources
- TopWiz
- displayicon
- PB
- u_displayicon.sru
File: u_displayicon.sru
Size: 4016
Date: Wed, 10 Feb 2021 20:10:08 +0100
Size: 4016
Date: Wed, 10 Feb 2021 20:10:08 +0100
- userobject u_displayicon(sru)