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

  1. /*
  2.  *
  3.  *  GetBitmapDimension
  4.  *  gbitdim.c
  5.  *  
  6.  *  This program demonstrates the use of the function GetBitmapDimension.
  7.  *  This funtion returns the width and height of the bitmap specified by 
  8.  *  the parameter.
  9.  *   
  10.  */
  11.  
  12. #include "windows.h"
  13. #include <stdio.h>
  14.  
  15. int PASCAL WinMain (hInstance, hPrevInstance, lpszCmdLine, cmdShow)
  16. HANDLE hInstance, hPrevInstance;
  17. LPSTR  lpszCmdLine;
  18. int    cmdShow;
  19.   {
  20.   HBITMAP hBitmap;          /* Handle to the loaded bitmap.   */
  21.   DWORD   dwOldDimensions;  /* Old dimensions of the bitmap.  */
  22.   DWORD   dwDimensions;     /* New dimensions of the bitmap.  */
  23.   char    szOutBuf[50];     /* Output buffer for Message Box. */
  24.  
  25.        /* Load in the bitmap to examine. */
  26.   hBitmap = LoadBitmap (hInstance, "SCOTTIE");
  27.   if (hBitmap == NULL)
  28.     {
  29.     MessageBox (GetFocus (), (LPSTR)"Cannot Find Bitmap SCOTTIE",
  30.                (LPSTR)"LoadBitmap () Error!", MB_OK | MB_ICONEXCLAMATION);
  31.     return 1;
  32.     }
  33.  
  34.        /* Set the new dimensions of the bitmap and show the old ones. */
  35.   dwOldDimensions = SetBitmapDimension (hBitmap, (short)15, (short)15);
  36.   sprintf (szOutBuf, "The old dimensions were %hu * %hu",
  37.           LOWORD (dwOldDimensions), HIWORD (dwOldDimensions));
  38.   MessageBox (GetFocus (), (LPSTR)szOutBuf,
  39.              (LPSTR)"SetBitmapDimension ()", MB_OK);
  40.  
  41.        /* Get the new dimensions. */
  42.   MessageBox (GetFocus (), (LPSTR)"Getting new dimensions.",
  43.              "GetBitmapDimension ()", MB_OK);
  44.   dwDimensions = GetBitmapDimension (hBitmap);
  45.  
  46.        /* And display them (or an error). */
  47.   sprintf (szOutBuf, "New dimensions are %hu * %hu",
  48.           LOWORD (dwDimensions), HIWORD (dwDimensions));
  49.   if (dwDimensions)
  50.     MessageBox (GetFocus (), (LPSTR)szOutBuf,
  51.                (LPSTR)"GetBitmapDimension ()", MB_OK);
  52.   else
  53.     MessageBox (GetFocus (), (LPSTR)"Function failed",
  54.                (LPSTR)"GetBitmapDimension () Error!",
  55.                MB_OK | MB_ICONEXCLAMATION);
  56.  
  57.   if (!DeleteObject (hBitmap))
  58.     {
  59.     MessageBox (GetFocus (), (LPSTR)"Bitmap Resources Not Deleted!",
  60.                (LPSTR)"DeleteObject () Error!",
  61.                MB_OK | MB_ICONEXCLAMATION);
  62.     return 1;
  63.     }
  64.  
  65.   return 0;
  66.   }
  67.