home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / win_lrn / caret / hide.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-11  |  2.0 KB  |  70 lines

  1. /*
  2.  *
  3.  *  HideCaret
  4.  *
  5.  *  This program demonstrates the use of the HideCaret function. The
  6.  *  HideCaret function removes the caret from the specified window.
  7.  */
  8.  
  9. #include "windows.h"
  10.  
  11. /* Procedure called when the application is loaded for the first time */
  12. BOOL WinInit (hInstance)
  13. HANDLE hInstance;
  14.   {
  15.   PWNDCLASS   pClass;
  16.  
  17.   pClass = (PWNDCLASS)LocalAlloc (LPTR, sizeof (WNDCLASS));
  18.   pClass->hCursor        = LoadCursor (NULL, IDC_ARROW);
  19.   pClass->lpszMenuName   = (LPSTR)NULL;
  20.   pClass->lpszClassName  = (LPSTR)"Window";
  21.   pClass->hbrBackground  = (HBRUSH)GetStockObject (WHITE_BRUSH);
  22.   pClass->hInstance      = hInstance;
  23.   pClass->style          = CS_HREDRAW | CS_VREDRAW;
  24.   pClass->lpfnWndProc    = DefWindowProc;
  25.  
  26.   if (!RegisterClass ( (LPWNDCLASS)pClass))
  27.     return FALSE;
  28.  
  29.   LocalFree ( (HANDLE) pClass);
  30.   return TRUE;        /* Initialization succeeded */
  31.   }
  32.  
  33. int     PASCAL WinMain (hInstance, hPrevInstance, lpszCmdLine, cmdShow)
  34. HANDLE hInstance, hPrevInstance;
  35. LPSTR lpszCmdLine;
  36. int    cmdShow;
  37.   {
  38.   HWND         hWnd;                /* Handle to the parent window    */
  39.  
  40.   WinInit (hInstance);
  41.  
  42.   hWnd = CreateWindow ( (LPSTR)"Window",
  43.       (LPSTR)"Sample Window",
  44.       WS_OVERLAPPEDWINDOW,
  45.       20, 20, 400, 200,
  46.       (HWND)NULL,        /* no parent */
  47.   (HMENU)NULL,       /* use class menu */
  48.   (HANDLE)hInstance, /* handle to window instance */
  49.   (LPSTR)NULL        /* no params to pass on */
  50.  );
  51.  
  52.   ShowWindow (hWnd, cmdShow);
  53.   UpdateWindow (hWnd);
  54.  
  55.   CreateCaret (hWnd, NULL, 8, 12);
  56.   SetCaretPos (50, 50);
  57.   ShowCaret (hWnd);
  58.   MessageBox (hWnd, (LPSTR)"Here is the caret",
  59.       (LPSTR)" ", MB_OK);
  60.   MessageBox (hWnd, (LPSTR)"The caret is going to be hid",
  61.       (LPSTR)"WARNING", MB_OK);
  62. /** hide the caret **/
  63.   HideCaret (hWnd);
  64. /** output message box so application does not end before user **/
  65. /** can see that the caret is gone                             **/
  66.   MessageBox (hWnd, (LPSTR)"It's gone!", (LPSTR)" ", MB_OK);
  67.  
  68.   return 0;
  69.   }
  70.