{***************************************************************************

	NoMan Custom Control Library			$Version$
	Info Module Unit
	$Author$		$Date$

        Copyright 1991 Anthony M. Vitabilea

	Unit Description

	This Turbo Pascal for Windows unit contains the library's
	information procedures.  This code is common to all classes in
	the DLL.

	The library uses straight Windows calls and does NOT use Object-
	Windows.  This is to allow the control to be used by ANY Windows
	program.

	This code is adapted from the code that appeared in the July,
	1990 issue of Microsoft Systems Journal article, "Extending the
	Windows 3.0 Interface with Installable Custom Controls" by Kevin
	P. Welch.  It has been extended to comply with the format
	specified by Borland for use with their Resource Workshop
	resource editor.

***************************************************************************}

{$C DemandLoad Discardable}
Unit CtrlInfoProcs;
Interface
  Uses WinTypes, CustCntl;

  function ListClasses(szAppName:  PChar;
                       wVersion :  word;
                       fnLoad   :  TLoad;
                       fnEdit   :  TEdit):  THandle; export;
  function PercentCtrlInfo:  THandle; export;

Implementation
  Uses CtrlCommonDefs, CtrlDlgs, CtrlFlags, Strings, WinProcs;

  function ListClasses(szAppName:  PChar;
                       wVersion :  word;
                       fnLoad   :  TLoad;
                       fnEdit   :  TEdit):  THandle;
    var
      ClassList :  THandle;
      PClassList:  PCtlClassList;

    begin	{ ListClasses }
      ClassList := GlobalAlloc(gmem_Moveable or gmem_ZeroInit,
			       2 + Ctl_NoControls * sizeof(TRWCtlClass));
      if ClassList <> 0
       then
        begin
         PClassList := GlobalLock(ClassList);
         with PClassList^ do
           begin
            nClasses            := Ctl_NoControls;
            @Classes[0].fnInfo  := @PercentCtrlInfo;
            @Classes[0].fnStyle := @PercentCtrlStyle;
            @Classes[0].fnFlags := @PercentCtrlFlags;
            StrCopy(Classes[0].szClass, Pct_Name)
           end
        end;
      ListClasses := ClassList
    end		{ ListClasses };

  function PercentCtrlInfo:  THandle;
    var
      i        :  integer;
      hCtlInfo :  THandle;
      lpCtlInfo:  PRWCtlInfo;

    begin	{ PercentCtrlInfo }
		{ Allocation memory for information structure }
      hCtlInfo := GlobalAlloc(gmem_Moveable or gmem_ZeroInit,
			      sizeof(TRWCtlInfo));
      if hCtlInfo <> 0
       then
	begin
	 lpCtlInfo := GlobalLock(hCtlInfo);	{ Lock it down }
	 if lpCtlInfo = nil
	  then
	   begin
	    GlobalFree(hCtlInfo);
	    hCtlInfo := 0
	   end
	  else
	   with lpCtlInfo^ do
	    begin
	     wCtlTypes := Pct_NoVariants;
	     wVersion  := pct_Version;
	     StrCopy(szClass, Pct_Name);
	     StrCopy(szTitle, 'Percent Bar Control');
             for i := 0 to Pct_NoVariants - 1 do
               begin
	         ctType[i].wType   :=  i;
	         ctType[i].wHeight := 24;
	         ctType[i].wWidth  := 100;
	         ctType[i].dwStyle := Pct_WndStyle[i];
                 if (ctType[i].dwStyle and not PctMask) <> 0
                   then ctType[i].wHeight := ctType[i].wHeight +  8;
                 if (ctType[i].dwStyle and Pct_Axis) <> 0
                   then ctType[i].wHeight := ctType[i].wHeight + 16;
	         StrCopy(ctType[i].szDescr, Pct_Variants[i]);
                 ctType[i].hToolBit  := LoadBitmap(HInstance, MakeIntResource(501));
                 ctType[i].hDropCurs := LoadCursor(HInstance, MakeIntResource(500));
               end;
             GlobalUnlock(hCtlInfo)
	    end
	end;
      PercentCtrlInfo := hCtlInfo
    end 	{ PercentCtrlInfo };

  end.
