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

  1. /*
  2.  *
  3.  *  GetCaretBlinkTime
  4.  *
  5.  *  This program demonstrates the use of the function GetCaretBlinkTime.
  6.  *  GetCaretBlinkTime returns the delay in milliseconds between each blink
  7.  *  of the caret. So a big Blink Time means a slow blink speed. GetCaret-
  8.  *  BlinkTime is called from WinMain in this application.
  9.  *
  10.  */
  11.  
  12. #include <stdio.h>
  13. #include <windows.h>
  14.  
  15. /* Procedure called when the application is loaded for the first time */
  16. BOOL WinInit( hInstance )
  17. HANDLE hInstance;
  18. {
  19.     WNDCLASS   wcClass;
  20.  
  21.     /* registering the parent window class */
  22.     wcClass.hCursor        = LoadCursor( NULL, IDC_ARROW );
  23.     wcClass.hIcon       = LoadIcon (hInstance, (LPSTR)NULL);
  24.     wcClass.lpszMenuName   = (LPSTR)NULL;
  25.     wcClass.lpszClassName  = (LPSTR)"Setcarbt";
  26.     wcClass.hbrBackground  = (HBRUSH)GetStockObject( WHITE_BRUSH );
  27.     wcClass.hInstance      = hInstance;
  28.     wcClass.style          = CS_HREDRAW | CS_VREDRAW;
  29.     wcClass.lpfnWndProc    = DefWindowProc;
  30.     wcClass.cbClsExtra     = 0;
  31.     wcClass.cbWndExtra     = 0;
  32.  
  33.     RegisterClass( (LPWNDCLASS)&wcClass );
  34.     return TRUE;        /* Initialization succeeded */
  35. }
  36.  
  37. int PASCAL WinMain( hInstance, hPrevInstance, lpszCmdLine, cmdShow )
  38. HANDLE hInstance, hPrevInstance;
  39. LPSTR lpszCmdLine;
  40. int cmdShow;
  41. {
  42.     HWND     hWnd;         /*    Handle to the parent window    */
  43.     WORD     wBlinkDelay;     /* return value from GetCaretBlinkTime */
  44.     char     szBuff[30];     /*      buffer for message box    */
  45.  
  46.     WinInit (hInstance);
  47.  
  48.     hWnd = CreateWindow((LPSTR)"Setcarbt",
  49.             (LPSTR)"GetCaretBlinkTime",
  50.                         WS_OVERLAPPEDWINDOW,
  51.                         50,                /* x         */
  52.                         50,                /* y         */
  53.                         600,               /* width     */
  54.                         250,               /* height    */
  55.                         (HWND)NULL,        /* no parent */
  56.                         (HMENU)NULL,       /* use class menu */
  57.                         (HANDLE)hInstance, /* handle to window instance */
  58.                         (LPSTR)NULL        /* no params to pass on */
  59.                        );
  60.  
  61.     /* Make window visible according to the way the app is activated */
  62.     ShowWindow( hWnd, cmdShow );
  63.     UpdateWindow( hWnd );
  64.    
  65.     /* create a caret before showing it */
  66.     CreateCaret (hWnd, NULL, 8, 12);
  67.     SetCaretPos (50,50);    
  68.     ShowCaret (hWnd);
  69.  
  70. /* get the delay in milliseconds of the caret blink speed */
  71.     wBlinkDelay = (WORD)GetCaretBlinkTime();
  72.  
  73.     sprintf(szBuff,"%d milliseconds",wBlinkDelay);
  74.  
  75.     MessageBox(hWnd,(LPSTR)szBuff,
  76.             (LPSTR)"The blink delay is",
  77.             MB_OK);
  78.  
  79.     MessageBox(hWnd,(LPSTR)"speed the blink up",
  80.             (LPSTR)"I am going to...",
  81.             MB_OK);
  82.  
  83.     SetCaretBlinkTime (GetCaretBlinkTime()/5);     /* cut the delay down */
  84.  
  85. /* get the delay in milliseconds of the caret blink speed */
  86.     wBlinkDelay = (WORD)GetCaretBlinkTime();
  87.  
  88.     sprintf(szBuff,"%d milliseconds",wBlinkDelay);
  89.  
  90.     MessageBox(hWnd,(LPSTR)szBuff,
  91.             (LPSTR)"The blink delay is",
  92.             MB_OK);
  93.  
  94.     return 0;
  95. }
  96.