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

  1. /*
  2.  *
  3.  *  GetClassWord
  4.  *  
  5.  *  This program demonstrates the use of the function GetClassWord.
  6.  *  This function retrieves the word that is specified by the last para-
  7.  *  meter form the WNDCLASS stucture of the window specified by the 
  8.  *  first parameter.
  9.  *
  10.  *  Windows Version 2.0 function demonstration application
  11.  *
  12.  */
  13.  
  14. #include <windows.h>
  15.  
  16. static HANDLE hWnd;
  17.  
  18. int PASCAL WinMain( hInstance, hPrevInstance, lpszCmdLine, cmdShow )
  19. HANDLE hInstance, hPrevInstance;
  20. LPSTR  lpszCmdLine;
  21. int    cmdShow;
  22. {
  23.   WORD wClassWord;
  24.   char szbuff[80];
  25.   
  26.   if ( !hPrevInstance )
  27.      {
  28.      WNDCLASS rClass;
  29.  
  30.      rClass.lpszClassName = ( LPSTR ) "getcword";
  31.      rClass.hInstance     = hInstance;
  32.      rClass.lpfnWndProc   = DefWindowProc;
  33.      rClass.hCursor       = LoadCursor ( NULL , IDC_ARROW );
  34.      rClass.hIcon         = LoadIcon ( hInstance, IDI_APPLICATION );
  35.      rClass.lpszMenuName  = ( LPSTR ) NULL;
  36.      rClass.hbrBackground = GetStockObject ( WHITE_BRUSH );
  37.      rClass.style         = CS_HREDRAW | CS_VREDRAW;
  38.      rClass.cbClsExtra    = 0;
  39.      rClass.cbWndExtra    = 0;
  40.    
  41.      RegisterClass ( ( LPWNDCLASS ) &rClass );
  42.      }
  43.  
  44.   hWnd = CreateWindow ( ( LPSTR ) "getcword", ( LPSTR ) "GetClassWord",
  45.                       WS_OVERLAPPEDWINDOW,
  46.                       CW_USEDEFAULT, CW_USEDEFAULT,
  47.                       CW_USEDEFAULT, CW_USEDEFAULT,
  48.                       ( HWND ) NULL, ( HMENU ) NULL,
  49.                       ( HANDLE ) hInstance, ( LPSTR ) NULL );
  50.  
  51.   ShowWindow ( hWnd , cmdShow );
  52.  
  53.   MessageBox (NULL, (LPSTR)"Getting windows style bits",
  54.      (LPSTR)"GetClassWord", MB_OK);
  55.  
  56.   wClassWord = GetClassWord ( hWnd, GCW_STYLE );
  57.  
  58.   sprintf ( szbuff, "%s%d\0", "Style bits are ", wClassWord );
  59.  
  60.   MessageBox (NULL, (LPSTR) szbuff, (LPSTR)"GetClassWord", MB_OK);
  61.  
  62.   return 0;
  63. }
  64.