Function Get_Window_ID(Window)

////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
//																								
// This program is proprietary and is not to be used by or disclosed to others, nor is it to	
// be copied without written permission from SRP Computer Solutions, Inc.						
//																								
// Name       : Get_Window_ID																	
//																								
// Description: Returns the current key ID in a window											
//																								
// Notes:		When a window is showing a locked record the ID property is null. Some routines	
//				need this information, like a print routine assigned to this window, so the ID	
//				must be acquired by looking at the TEXT properties of the key controls.			
//																								
// Parameters:																					
//	Window	[in] -- The window who needs the ID returned from.									
//	ID	   [out] -- The ID of window.															
//																								
// History (Date, Initials, Notes)																
//   04/01/00  dmb   Original programmer														
//   02/01/06  dmb   Convert each ID part using the control's conversion property.				
//																								
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////

$insert APP_INSERTS

Declare function Get_Key_Controls, Get_Property

If Assigned(Window) else Window = @Window
If Get_Property(Window, "MDIACTIVE") GT "" then Window = Get_Property(Window, "MDIACTIVE")

Keys = Get_Key_Controls(Window) ; // Get the key controls for this window

Convert @FM to @RM in Keys

NumKeys = Count(Keys, @RM) + (Keys NE "")
ID = Get_Property(Keys, Str("TEXT":@RM, NumKeys - 1):"TEXT")
Convs = Get_Property(Keys, Str("CONV":@RM, NumKeys - 1):"CONV")

Convert @RM to @FM in ID
Convert @RM to @FM in Convs

For i = 1 to NumKeys
	ID<i> = Iconv(ID<i>, Convs<i>)
Next i

Convert @FM to @RM in ID

Return ID
