Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DrawIcon
Message
 
To
All
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
DrawIcon
Miscellaneous
Thread ID:
00676876
Message ID:
00676876
Views:
67
Does anybody know why the DrawIcon API does not work on a form that is set as a Top Level Form? This works great when the form is hosted by the Foxpro Top Level Form, but displays nothing if the form is a top level form.

This is code from my AssociatedIcon Class based on a picture (just to get the top and left coordinates for display).
*INIT Method:
IF !PEMSTATUS(_screen,'AssociatedIconInstanceCount',5)
	_screen.AddProperty('AssociatedIconInstanceCount',0)
ENDIF 
_screen.AssociatedIconInstanceCount = _screen.AssociatedIconInstanceCount + 1
IF _screen.AssociatedIconInstanceCount = 1
	DECLARE SHORT DrawIcon IN Win32API INTEGER Hdc, INTEGER X, INTEGER Y, INTEGER hIcon
	DECLARE INTEGER ExtractIcon 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 
	DECLARE INTEGER ExtractAssociatedIcon IN Shell32 INTEGER hInst, STRING @lpIconPath, INTEGER @lpiIcon
ENDIF 
this.Visible=.f.	&& Since the actual picture property is not drawn, make it invisible.
this.hInstance = GetClassLong(thisform.HWnd, -16)
this.hdc = GetDC(thisform.HWnd )

FilePath_Assign Method:
LPARAMETERS vNewVal
*To do: Modify this routine for the Assign method
IF VARTYPE(vNewVal)=[C] AND FILE(vNewVal)
	THIS.filepath = m.vNewVal
	LOCAL lnIndex
	lnIndex=0
	*HIcon = ExtractIcon(HInstance, lcfilename, 0)
	this.hicon = ExtractAssociatedIcon(this.hInstance,@vNewVal,@lnIndex)
	=DrawIcon(this.Hdc, OBJTOCLIENT(this,2), OBJTOCLIENT(this,1), this.HIcon)
	this.ZOrder(0)
ENDIF 
Next
Reply
Map
View

Click here to load this message in the networking platform