home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 21.ddi / CIRC3.C_ / CIRC3.bin
Encoding:
Text File  |  1993-02-14  |  20.6 KB  |  739 lines

  1. //---------------------------------------------------------------------------
  2. //        Copyright (C) 1991-92, Microsoft Corporation
  3. //
  4. // You have a royalty-free right to use, modify, reproduce and distribute
  5. // the Sample Custom Control Files (and/or any modified version) in any way
  6. // you find useful, provided that you agree that Microsoft has no warranty,
  7. // obligation or liability for any Custom Control File.
  8. //---------------------------------------------------------------------------
  9. // Circ3.c
  10. //---------------------------------------------------------------------------
  11. // Contains control procedure for CIRC3 control
  12. //---------------------------------------------------------------------------
  13.  
  14. #include <windows.h>
  15. #include <vbapi.h>
  16. #include <string.h>
  17. #include "circ3.h"      // Declares Vb2.0 compatiable model information
  18. #include "circ3vb1.h"      // Declares Vb1.0 compatiable model information
  19.  
  20.  
  21. //---------------------------------------------------------------------------
  22. // Local Prototypes
  23. //---------------------------------------------------------------------------
  24. VOID NEAR PaintCircle(HCTL hctl, HWND hwnd, HDC hdc);
  25. VOID NEAR RecalcArea(HCTL hctl, HWND hwnd);
  26. VOID NEAR FlashCircle(HCTL hctl, HDC hdc);
  27. BOOL NEAR InCircle(HCTL hctl, SHORT xcoord, SHORT ycoord);
  28. VOID NEAR FireClickIn(HCTL hctl, HWND hwnd, SHORT x, SHORT y);
  29. VOID NEAR FireClickOut(HCTL hctl);
  30. HWND NEAR HwndInitFlashPopup(VOID);
  31. VOID NEAR DisplayHelpTopic(CHAR chKeylist, LPSTR lpszKeyword);
  32. BOOL _export FAR PASCAL FlashDlgProc(HWND hDlg, USHORT msg, USHORT wp, LONG lp);
  33.  
  34.  
  35. //---------------------------------------------------------------------------
  36. // Global Variables
  37. //---------------------------------------------------------------------------
  38. HANDLE hmodDLL;
  39. WORD   cVbxUsers = 0;
  40. BOOL   fDevTimeInited = FALSE;
  41.  
  42.  
  43. //---------------------------------------------------------------------------
  44. // Global Variables for FlashColor dialog
  45. //---------------------------------------------------------------------------
  46. BOOL   fDlgInUse = FALSE;
  47. HCTL   hctlDialog;
  48. USHORT ipropDialog;
  49. LONG   colorOldDialog;
  50.  
  51.  
  52. //---------------------------------------------------------------------------
  53. // Circle Control Procedure
  54. //---------------------------------------------------------------------------
  55. LONG FAR PASCAL _export CircleCtlProc
  56. (
  57.     HCTL   hctl,
  58.     HWND   hwnd,
  59.     USHORT msg,
  60.     USHORT wp,
  61.     LONG   lp
  62. )
  63. {
  64.     switch (msg)
  65.     {
  66.     case WM_NCCREATE:
  67.         {
  68.         LPCIRC lpcirc = (LPCIRC)VBDerefControl(hctl);
  69.  
  70.         lpcirc->CircleShape = SHAPE_CIRCLE;
  71.         lpcirc->FlashColor = 128L;
  72.         VBSetControlProperty(hctl, IPROP_CIRCLE_BACKCOLOR, 255L);
  73.         // *** lpcirc may now be invalid due to call to VB API ***
  74.         break;
  75.         }
  76.  
  77.         case WM_LBUTTONDOWN:
  78.         case WM_LBUTTONDBLCLK:
  79.         if (InCircle(hctl, (SHORT)lp, (SHORT)HIWORD(lp)))
  80.         {
  81.         HDC hdc = GetDC(hwnd);
  82.  
  83.         FlashCircle(hctl, hdc);
  84.         ReleaseDC(hwnd, hdc);
  85.         FireClickIn(hctl, hwnd, (SHORT)lp, (SHORT)HIWORD(lp));
  86.         }
  87.         else
  88.         FireClickOut(hctl);
  89.             break;
  90.  
  91.         case WM_LBUTTONUP:
  92.         if (InCircle(hctl, (SHORT)lp, (SHORT)HIWORD(lp)))
  93.         {
  94.         HDC hdc = GetDC(hwnd);
  95.  
  96.         PaintCircle(hctl, hwnd, hdc);
  97.         ReleaseDC(hwnd, hdc);
  98.         }
  99.             break;
  100.  
  101.         case WM_SETFONT:
  102.         LpcircDEREF(hctl)->hfont = (HFONT)wp;
  103.             return 0;
  104.  
  105.         case WM_GETFONT:
  106.         return LpcircDEREF(hctl)->hfont;
  107.  
  108.         case WM_SETTEXT:
  109.             {
  110.         HSZ    hsz;
  111.         LPCIRC lpcirc = LpcircDEREF(hctl);
  112.  
  113.         if (lpcirc->hszCaption)
  114.         {
  115.         VBDestroyHsz(lpcirc->hszCaption);
  116.         // *** lpcirc may now be invalid due to call to VB API ***
  117.         }
  118.         hsz = VBCreateHsz((_segment)hctl, (LPSTR)lp);
  119.         // *** lpcirc may now be invalid due to call to VB API ***
  120.         LpcircDEREF(hctl)->hszCaption = hsz;
  121.         InvalidateRect(hwnd, NULL, TRUE);
  122.         return 0L;
  123.             }
  124.  
  125.         case WM_GETTEXT:
  126.             {
  127.         LPSTR  lpstr;
  128.         USHORT cch;
  129.         LPCIRC lpcirc = LpcircDEREF(hctl);
  130.  
  131.         if (lpcirc->hszCaption == NULL)
  132.         {
  133.         *(LPSTR)lp = 0L;
  134.         wp = 1;
  135.         }
  136.         else
  137.         {
  138.         lpstr = VBDerefHsz(lpcirc->hszCaption);
  139.         cch = (USHORT)(lstrlen(lpstr) + 1);
  140.         if (wp > cch)
  141.             wp = cch;
  142.         _fstrncpy((LPSTR)lp, lpstr, wp);
  143.         ((LPSTR)lp)[wp - 1] = '\0';
  144.         }
  145.             }
  146.         return (LONG)(wp - 1);
  147.  
  148.     case WM_GETTEXTLENGTH:
  149.         {
  150.         LPCIRC lpcirc = LpcircDEREF(hctl);
  151.  
  152.         if (lpcirc->hszCaption == NULL)
  153.                 return 0L;
  154.             else
  155.         return lstrlen(VBDerefHsz(lpcirc->hszCaption));
  156.         }
  157.  
  158.  
  159.         case WM_PAINT:
  160.             if (wp)
  161.         PaintCircle(hctl, hwnd, (HDC)wp);
  162.         else
  163.         {
  164.                 PAINTSTRUCT ps;
  165.  
  166.         BeginPaint(hwnd, &ps);
  167.         PaintCircle(hctl, hwnd, ps.hdc);
  168.         EndPaint(hwnd, &ps);
  169.         }
  170.             break;
  171.  
  172.         case WM_SIZE:
  173.         RecalcArea(hctl, hwnd);
  174.             break;
  175.  
  176.         case VBM_SETPROPERTY:
  177.         switch (wp)
  178.         {
  179.                 case IPROP_CIRCLE_CIRCLESHAPE:
  180.             LpcircDEREF(hctl)->CircleShape = (ENUM)lp;
  181.             RecalcArea(hctl, hwnd);
  182.             InvalidateRect(hwnd, NULL, TRUE);
  183.             return 0L;
  184.         }
  185.             break;
  186.  
  187.     case VBM_HELP:
  188.         switch (LOBYTE(wp))
  189.         {
  190.         case VBHELP_PROP:
  191.             // High byte identifies which property.
  192.             // Keyword is: "<property>"
  193.             switch (HIBYTE(wp))
  194.             {
  195.             case IPROP_CIRCLE_CIRCLESHAPE:
  196.                 DisplayHelpTopic('P', "CircleShape");
  197.                 return 0L;
  198.  
  199.             case IPROP_CIRCLE_FLASHCOLOR:
  200.                 DisplayHelpTopic('P', "FlashColor");
  201.                 return 0L;
  202.             }
  203.             break;
  204.  
  205.         case VBHELP_EVT:
  206.             // High byte identifies which event
  207.             // Keyword is: "<event>"
  208.             switch (HIBYTE(wp))
  209.             {
  210.             case IEVENT_CIRCLE_CLICKIN:
  211.                 DisplayHelpTopic('V', "ClickIn");
  212.                 return 0L;
  213.  
  214.             case IEVENT_CIRCLE_CLICKOUT:
  215.                 DisplayHelpTopic('V', "ClickOut");
  216.                 return 0L;
  217.             }
  218.             break;
  219.  
  220.         case VBHELP_CTL:
  221.             // High byte is unused.
  222.             // Keyword is: "<classname>"
  223.             DisplayHelpTopic('C', "CIRC3");
  224.             return 0L;
  225.         }
  226.         break;
  227.  
  228.         case VBM_INITPROPPOPUP:
  229.         switch (wp)
  230.         {
  231.         // Un-commenting the following line will enable our custom
  232.         // popup instead of the color palette, when setting the
  233.         // backcolor:
  234.         // case IPROP_CIRCLE_BACKCOLOR:
  235.         case IPROP_CIRCLE_FLASHCOLOR:
  236.             {
  237.             if (fDlgInUse)
  238.               // Our dialog is already in use, so return NULL here
  239.               // to avoid bringing up a 2nd instance of the dialog.
  240.               // We could get around this restriction by storing
  241.               // hctlDialog, ipropDialog, and colorOldDialog as
  242.               // window words of hwndPopup.
  243.               // NOTE: In this specific case, because FlashColor
  244.               // is DT_COLOR, we could also just "break;" to go
  245.               // through default processing which would bring up
  246.               // the default color palette.
  247.               return NULL;
  248.  
  249.             // Tell the hwndPopup which control and iprop we want
  250.             // the dialog to change
  251.             fDlgInUse    = TRUE;
  252.             hctlDialog    = hctl;
  253.             ipropDialog = wp;
  254.  
  255.             return HwndInitFlashPopup();
  256.             }
  257.                 }
  258.             break;
  259.     }
  260.  
  261.     return VBDefControlProc(hctl, hwnd, msg, wp, lp);
  262. }
  263.  
  264.  
  265. //---------------------------------------------------------------------------
  266. // Handle painting by drawing circle into the given hdc.
  267. //---------------------------------------------------------------------------
  268. VOID NEAR PaintCircle
  269. (
  270.     HCTL hctl,
  271.     HWND hwnd,
  272.     HDC  hdc
  273. )
  274. {
  275.     HBRUSH hbr;
  276.     HBRUSH hbrOld = NULL;
  277.     LPSTR  lpstr;
  278.     LPCIRC lpcirc = LpcircDEREF(hctl);
  279.     LPRECT lprect = &lpcirc->rectDrawInto;
  280.     HFONT  hfontOld = NULL;
  281.  
  282.     hbr = (HBRUSH)SendMessage(GetParent(hwnd), WM_CTLCOLOR,
  283.                   hdc, MAKELONG(hwnd, 0));
  284.     if (hbr)
  285.     hbrOld = SelectObject(hdc, hbr);
  286.     Ellipse(hdc, lprect->left, lprect->top, lprect->right, lprect->bottom);
  287.  
  288.     if (lpcirc->hfont)
  289.       hfontOld = SelectObject(hdc, lpcirc->hfont);
  290.     lpstr = VBDerefHsz(lpcirc->hszCaption);
  291.     DrawText(hdc, lpstr, -1, lprect, DT_VCENTER | DT_CENTER | DT_SINGLELINE);
  292.  
  293.     if (hbrOld)
  294.     SelectObject(hdc, hbrOld);
  295.     if (hfontOld)
  296.     SelectObject(hdc, hfontOld);
  297. }
  298.  
  299.  
  300. //---------------------------------------------------------------------------
  301. // Paint the circle in the FlashColor.
  302. //---------------------------------------------------------------------------
  303. VOID NEAR FlashCircle
  304. (
  305.     HCTL hctl,
  306.     HDC  hdc
  307. )
  308. {
  309.     HBRUSH hbr;
  310.     HBRUSH hbrOld = NULL;
  311.     LPCIRC lpcirc = LpcircDEREF(hctl);
  312.     LPRECT lprect = &lpcirc->rectDrawInto;
  313.  
  314.     hbr = CreateSolidBrush(RGBCOLOR(lpcirc->FlashColor));
  315.     if (hbr)
  316.     hbrOld = SelectObject(hdc, hbr);
  317.     Ellipse(hdc, lprect->left, lprect->top, lprect->right, lprect->bottom);
  318.     if (hbr)
  319.     {
  320.     SelectObject(hdc, hbrOld);
  321.     DeleteObject(hbr);
  322.     }
  323. }
  324.  
  325.  
  326. //---------------------------------------------------------------------------
  327. // Use the hwnd's client size to determine the bounding rectangle for the
  328. // circle.  If CircleShape is TRUE, then we need to calculate a square
  329. // centered in lprect.
  330. //---------------------------------------------------------------------------
  331. VOID NEAR RecalcArea
  332. (
  333.     HCTL hctl,
  334.     HWND hwnd
  335. )
  336. {
  337.     LPCIRC lpcirc = LpcircDEREF(hctl);
  338.     LPRECT lprect = &lpcirc->rectDrawInto;
  339.  
  340.     GetClientRect(hwnd, lprect);
  341.     if (lpcirc->CircleShape == SHAPE_OVAL)
  342.         return;
  343.     if (lprect->right > lprect->bottom)
  344.     {
  345.     lprect->left = (lprect->right - lprect->bottom) / 2;
  346.     lprect->right = lprect->left + lprect->bottom;
  347.     }
  348.     else if (lprect->bottom > lprect->right)
  349.     {
  350.     lprect->top = (lprect->bottom - lprect->right) / 2;
  351.     lprect->bottom = lprect->top + lprect->right;
  352.     }
  353. }
  354.  
  355.  
  356. //---------------------------------------------------------------------------
  357. // Return TRUE if the given coordinates are inside of the circle.
  358. //---------------------------------------------------------------------------
  359. BOOL NEAR InCircle
  360. (
  361.     HCTL  hctl,
  362.     SHORT xcoord,
  363.     SHORT ycoord
  364. )
  365. {
  366.     double a, b;
  367.     double x, y;
  368.     LPRECT lprect = &LpcircDEREF(hctl)->rectDrawInto;
  369.  
  370.     a = (lprect->right - lprect->left) / 2;
  371.     b = (lprect->bottom - lprect->top) / 2;
  372.     x = xcoord - (lprect->left + lprect->right) / 2;
  373.     y = ycoord - (lprect->top + lprect->bottom) / 2;
  374.     return ((x * x) / (a * a) + (y * y) / (b * b) <= 1);
  375. }
  376.  
  377.  
  378. //---------------------------------------------------------------------------
  379. // TYPEDEF for parameters to the ClickIn event.
  380. //---------------------------------------------------------------------------
  381. typedef struct tagCLICKINPARMS
  382.     {
  383.     HLSTR      ClickString;
  384.     float far *Y;
  385.     float far *X;
  386.     LPVOID     Index;
  387.     } CLICKINPARMS;
  388.  
  389.  
  390. //---------------------------------------------------------------------------
  391. // Fire the ClickIn event, passing the x,y coords of the click.  Also pass
  392. // the current caption of the Circle control, to demonstrate passing strings
  393. // to event procedures.
  394. //---------------------------------------------------------------------------
  395. VOID NEAR FireClickIn
  396. (
  397.     HCTL  hctl,
  398.     HWND  hwnd,
  399.     SHORT x,
  400.     SHORT y
  401. )
  402. {
  403.     CLICKINPARMS params;
  404.     float     xTwips, yTwips;
  405.     USHORT     cbCaption, err;
  406.     char     strBuf[20];
  407.  
  408.     xTwips = (float)VBXPixelsToTwips(x);
  409.     yTwips = (float)VBYPixelsToTwips(y);
  410.     params.X = &xTwips;
  411.     params.Y = &yTwips;
  412.  
  413.     cbCaption = (USHORT)GetWindowText(hwnd, strBuf, 20);
  414.     params.ClickString = VBCreateHlstr(strBuf, cbCaption);
  415.     err = VBFireEvent(hctl, IEVENT_CIRCLE_CLICKIN, ¶ms);
  416.     VBDestroyHlstr(params.ClickString);
  417. }
  418.  
  419.  
  420. //---------------------------------------------------------------------------
  421. // Fire the ClickOut event.
  422. //---------------------------------------------------------------------------
  423. VOID NEAR FireClickOut
  424. (
  425.     HCTL hctl
  426. )
  427. {
  428.     VBFireEvent(hctl, IEVENT_CIRCLE_CLICKOUT, NULL);
  429. }
  430.  
  431.  
  432. //---------------------------------------------------------------------------
  433. // Use frame variables to "allocate" a MULTIKEYHELP structure to pass to
  434. // WinHelp().
  435. //---------------------------------------------------------------------------
  436. VOID NEAR DisplayHelpTopic
  437. (
  438.     CHAR  chKeylist,
  439.     LPSTR lpszKeyword
  440. )
  441. {
  442.     char  rgch[100];
  443.     MULTIKEYHELP FAR *lpmkh = rgch;
  444.  
  445.     lpmkh->mkSize = sizeof(MULTIKEYHELP) + lstrlen(lpszKeyword);
  446.     if (lpmkh->mkSize > sizeof(rgch))
  447.     return;
  448.  
  449.     lpmkh->mkKeylist = chKeylist;
  450.     lstrcpy((LPSTR)lpmkh->szKeyphrase, lpszKeyword);
  451.     WinHelp(GetActiveWindow(), "circ3.hlp", HELP_MULTIKEY, (DWORD)lpmkh);
  452. }
  453.  
  454.  
  455. //---------------------------------------------------------------------------
  456. // Create our property popup-window.  Since we want to put up a dialog, this
  457. // window never becomes visible.  Instead, when asked to become visible, it
  458. // will post a message to itself, remining it to put up our dialog.
  459. //
  460. // NOTE: May return NULL!
  461. //---------------------------------------------------------------------------
  462. HWND NEAR HwndInitFlashPopup
  463. (
  464.     VOID
  465. )
  466. {
  467.     return CreateWindow(CLASS_FLASHPOPUP, NULL, WS_POPUP,
  468.             0, 0, 0, 0, NULL, NULL,
  469.             hmodDLL, NULL);
  470. }
  471.  
  472.  
  473. //---------------------------------------------------------------------------
  474. // We asked to show ourself, remain invisible and post a CM_OPENFLASHDLG to
  475. // ourself.  When we receive this message, open the dialog box.
  476. //---------------------------------------------------------------------------
  477. LONG _export FAR PASCAL FlashPopupWndProc
  478. (
  479.     HWND   hwnd,
  480.     USHORT msg,
  481.     USHORT wp,
  482.     LONG   lp
  483. )
  484. {
  485.     extern HANDLE hmodDLL;
  486.  
  487.     switch (msg)
  488.     {
  489.     case WM_DESTROY:
  490.         fDlgInUse = FALSE;
  491.         break;
  492.  
  493.         case WM_SHOWWINDOW:
  494.         if (wp)
  495.         {
  496.         PostMessage(hwnd, CM_OPENFLASHDLG, 0, 0L);
  497.         return 0L;
  498.         }
  499.             break;
  500.  
  501.     case CM_OPENFLASHDLG:
  502.         VBDialogBoxParam(hmodDLL, "FlashDlg", (FARPROC)FlashDlgProc, 0L);
  503.         return 0L;
  504.     }
  505.  
  506.     return DefWindowProc(hwnd, msg, wp, lp);
  507. }
  508.  
  509.  
  510. //---------------------------------------------------------------------------
  511. // An array mapping option buttons to RGB colors.
  512. //---------------------------------------------------------------------------
  513. long mpidcolor[] = { 0xff, 0xff00, 0xff0000 };
  514.  
  515.  
  516. //---------------------------------------------------------------------------
  517. // The Dialog Procedure for the FlashColor property dialog.
  518. //---------------------------------------------------------------------------
  519. BOOL FAR PASCAL _export FlashDlgProc
  520. (
  521.     HWND   hDlg,
  522.     USHORT msg,
  523.     USHORT wp,
  524.     LONG   lp
  525. )
  526. {
  527.     switch (msg)
  528.     {
  529.     case WM_INITDIALOG:
  530.         {
  531.         RECT rect;
  532.         int  nx, ny;      // New x and y
  533.         int  width, height;
  534.         int  i;
  535.         LONG colorOld;
  536.  
  537.         // Position dialog so it looks nice:
  538.         GetWindowRect(hDlg, &rect);
  539.         width  = rect.right - rect.left;
  540.         height = rect.bottom - rect.top;
  541.         nx = (GetSystemMetrics(SM_CXSCREEN) - width)  / 2;
  542.         ny = (GetSystemMetrics(SM_CYSCREEN) - height) / 3;
  543.         MoveWindow(hDlg, nx, ny, width, height, FALSE);
  544.  
  545.         // Remember the old value of this property, so we can restore it
  546.         // on cancel:
  547.         if (VBGetControlProperty(hctlDialog, ipropDialog, &colorOld))
  548.           EndDialog(hDlg, FALSE);
  549.  
  550.         // If the current color matches one of the option button colors,
  551.         // then set that option button:
  552.         for (i=0; i<sizeof(mpidcolor); i++)
  553.         if (mpidcolor[i] == colorOld)
  554.             CheckRadioButton(hDlg, DI_REDOPT, DI_BLUEOPT, i+DI_REDOPT);
  555.  
  556.         // Save away colorOld so we can use it later
  557.         colorOldDialog = colorOld;
  558.  
  559.         return TRUE;
  560.         }
  561.  
  562.         case WM_COMMAND:
  563.         switch (wp)
  564.         {
  565.                 case IDOK:
  566.             EndDialog(hDlg, TRUE);
  567.                     return TRUE;
  568.  
  569.         case IDCANCEL:
  570.             {
  571.             // Restore the old value, since we're canceling:
  572.             VBSetControlProperty(hctlDialog, ipropDialog, colorOldDialog);
  573.  
  574.             EndDialog(hDlg, FALSE);
  575.             return TRUE;
  576.             }
  577.  
  578.                 case DI_REDOPT:
  579.                 case DI_GREENOPT:
  580.         case DI_BLUEOPT:
  581.             {
  582.             CheckRadioButton(hDlg, DI_REDOPT, DI_BLUEOPT, wp);
  583.  
  584.             VBSetControlProperty(hctlDialog, ipropDialog,
  585.                      mpidcolor[wp-DI_REDOPT]);
  586.             return TRUE;
  587.             }
  588.         }
  589.             break;
  590.     }
  591.     return FALSE;
  592. }
  593.  
  594.  
  595. //---------------------------------------------------------------------------
  596. // Register custom control. This routine is called by VB when the custom
  597. // control DLL is loaded for use.
  598. //---------------------------------------------------------------------------
  599. BOOL FAR PASCAL _export VBINITCC
  600. (
  601.     USHORT usVersion,
  602.     BOOL   fRuntime
  603. )
  604. {
  605.     // Count the number of hosts using this VBX.  A host can be vb.exe,
  606.     // any .exe compiled from vb which uses this custom control, or any
  607.     // other program which loads and uses VBX files.
  608.     ++cVbxUsers;
  609.  
  610.     // Register popup class if this is from the development environment.
  611.     if (!fRuntime && !fDevTimeInited)
  612.     {
  613.     WNDCLASS class;
  614.  
  615.     class.style        = 0;
  616.     class.lpfnWndProc   = (FARPROC)FlashPopupWndProc;
  617.     class.cbClsExtra    = 0;
  618.     class.cbWndExtra    = 0;
  619.     class.hInstance     = hmodDLL;
  620.     class.hIcon        = NULL;
  621.     class.hCursor        = NULL;
  622.         class.hbrBackground = NULL;
  623.     class.lpszMenuName  = NULL;
  624.     class.lpszClassName = CLASS_FLASHPOPUP;
  625.  
  626.     if (!RegisterClass(&class))
  627.         return FALSE;
  628.  
  629.     // We successfully initialized the stuff we need at dev time
  630.     fDevTimeInited = TRUE;
  631.     }
  632.  
  633.     // Register control(s)
  634.     if (usVersion < VB_VERSION)
  635.     return VBRegisterModel(hmodDLL, &modelCircle_Vb1);
  636.     else
  637.     return VBRegisterModel(hmodDLL, &modelCircle);
  638. }
  639.  
  640.  
  641. //---------------------------------------------------------------------------
  642. // Unregister custom control.  This routine is called by VB when the custom
  643. // control DLL is being unloaded.
  644. //---------------------------------------------------------------------------
  645. VOID FAR PASCAL _export VBTERMCC
  646. (
  647.     VOID
  648. )
  649. {
  650.     --cVbxUsers;
  651.     if (cVbxUsers == 0 && fDevTimeInited)
  652.     {
  653.     // Free any resources created for Dev environment
  654.     UnregisterClass(CLASS_FLASHPOPUP, hmodDLL);
  655.     }
  656.     return;
  657. }
  658.  
  659.  
  660. //---------------------------------------------------------------------------
  661. // Provide custom control model information to host environment.
  662. //---------------------------------------------------------------------------
  663. LPMODELINFO FAR PASCAL _export VBGetModelInfo
  664. (
  665.     USHORT usVersion
  666. )
  667. {
  668.     if (usVersion < VB_VERSION)
  669.     return &modelinfoCircle_Vb1;
  670.     else
  671.     return &modelinfoCircle;
  672. }
  673.  
  674.  
  675. //---------------------------------------------------------------------------
  676. // Initialize library.    This routine is called when the first client loads
  677. // the DLL.
  678. //---------------------------------------------------------------------------
  679. int FAR PASCAL LibMain
  680. (
  681.     HANDLE hModule,
  682.     WORD   wDataSeg,
  683.     WORD   cbHeapSize,
  684.     LPSTR  lpszCmdLine
  685. )
  686. {
  687.     // Avoid warnings on unused (but required) formal parameters
  688.     wDataSeg    = wDataSeg;
  689.     cbHeapSize    = cbHeapSize;
  690.     lpszCmdLine = lpszCmdLine;
  691.  
  692.     hmodDLL = hModule;
  693.  
  694.     return 1;
  695. }
  696.  
  697.  
  698. //---------------------------------------------------------------------------
  699. // WEP
  700. //---------------------------------------------------------------------------
  701. // C7 and QCWIN provide default a WEP:
  702. //---------------------------------------------------------------------------
  703. #if (_MSC_VER < 610)
  704.  
  705. int FAR PASCAL WEP(int fSystemExit);
  706.  
  707. //---------------------------------------------------------------------------
  708. // For Windows 3.0 it is recommended that the WEP function reside in a
  709. // FIXED code segment and be exported as RESIDENTNAME.  This is
  710. // accomplished using the alloc_text pragma below and the related EXPORTS
  711. // and SEGMENTS directives in the .DEF file.
  712. //
  713. // Read the comments section documenting the WEP function in the Windows
  714. // 3.1 SDK "Programmers Reference, Volume 2: Functions" before placing
  715. // any additional code in the WEP routine for a Windows 3.0 DLL.
  716. //---------------------------------------------------------------------------
  717. #pragma alloc_text(WEP_TEXT,WEP)
  718.  
  719. //---------------------------------------------------------------------------
  720. // Performs cleanup tasks when the DLL is unloaded.  WEP() is
  721. // called automatically by Windows when the DLL is unloaded (no
  722. // remaining tasks still have the DLL loaded).    It is strongly
  723. // recommended that a DLL have a WEP() function, even if it does
  724. // nothing but returns success (1), as in this example.
  725. //---------------------------------------------------------------------------
  726. int FAR PASCAL WEP
  727. (
  728.     int fSystemExit
  729. )
  730. {
  731.     // Avoid warnings on unused (but required) formal parameters
  732.     fSystemExit = fSystemExit;
  733.  
  734.     return 1;
  735. }
  736. #endif // C6
  737.  
  738. //---------------------------------------------------------------------------
  739.