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

  1. /*
  2.  *  SetCaretBlinkTime
  3.  *  setcarbt.c
  4.  *
  5.  *  This program demonstrates the use of the function SetCaretBlinkTime.
  6.  *  It establishes the caret flash rate for the client area.
  7.  *
  8.  */
  9.  
  10. #include "windows.h"
  11.  
  12. /* Procedure called when the application is loaded for the first time */
  13. BOOL WinInit( hInstance )
  14. HANDLE hInstance;
  15. {
  16.     WNDCLASS   wcClass;
  17.  
  18.     /* registering the parent window class */
  19.     wcClass.hCursor        = LoadCursor( NULL, IDC_ARROW );
  20.     wcClass.hIcon          = LoadIcon (hInstance, (LPSTR)"WindowIcon");
  21.     wcClass.lpszMenuName   = (LPSTR)NULL;
  22.     wcClass.lpszClassName  = (LPSTR)"Setcarbt";
  23.     wcClass.hbrBackground  = (HBRUSH)GetStockObject( WHITE_BRUSH );
  24.     wcClass.hInstance      = hInstance;
  25.     wcClass.style          = CS_HREDRAW | CS_VREDRAW;
  26.     wcClass.lpfnWndProc    = DefWindowProc;
  27.     wcClass.cbClsExtra     = 0;
  28.     wcClass.cbWndExtra     = 0;
  29.  
  30.     RegisterClass( (LPWNDCLASS)&wcClass );
  31.     return TRUE;        /* Initialization succeeded */
  32. }
  33.  
  34. int PASCAL WinMain( hInstance, hPrevInstance, lpszCmdLine, cmdShow )
  35. HANDLE hInstance, hPrevInstance;
  36. LPSTR lpszCmdLine;
  37. int cmdShow;
  38. {
  39.     HWND         hWnd;                /* Handle to the parent window    */
  40.  
  41.     WinInit (hInstance);
  42.  
  43.     hWnd = CreateWindow((LPSTR)"Setcarbt",
  44.                         (LPSTR)"Setting Caret Blink Time",
  45.                         WS_OVERLAPPEDWINDOW,
  46.                         50,                /* x         */
  47.                         50,                /* y         */
  48.                         600,               /* width     */
  49.                         250,               /* height    */
  50.                         (HWND)NULL,        /* no parent */
  51.                         (HMENU)NULL,       /* use class menu */
  52.                         (HANDLE)hInstance, /* handle to window instance */
  53.                         (LPSTR)NULL        /* no params to pass on */
  54.                        );
  55.  
  56.     /* Make window visible according to the way the app is activated */
  57.     ShowWindow( hWnd, cmdShow );
  58.     UpdateWindow( hWnd );
  59.    
  60.     /* create a caret before showing it */
  61.     CreateCaret (hWnd, NULL, 8, 12);
  62.     SetCaretPos (50,50);    
  63.     ShowCaret (hWnd);
  64.     /* Message Box will make the parent window inactive */
  65.     MessageBox (hWnd, (LPSTR)"This is a slower caret blink time", 
  66.                 (LPSTR)"Before", MB_OK);
  67.  
  68.     /* make the caret blink faster by decreasing the delay time */
  69.     SetCaretBlinkTime (GetCaretBlinkTime()/2);
  70.     MessageBox (hWnd, (LPSTR)"Now the caret is twice as fast", 
  71.                 (LPSTR)"After", MB_OK);
  72.  
  73.     return 0;
  74. }
  75.