home *** CD-ROM | disk | FTP | other *** search
/ Windows Graphics Programming / Feng_Yuan_Win32_GDI_DirectX.iso / Samples / Chapt_05 / Ellipse / Ellipse.cpp next >
Encoding:
C/C++ Source or Header  |  2000-05-20  |  2.3 KB  |  66 lines

  1. //-----------------------------------------------------------------------------------//
  2. //              Windows Graphics Programming: Win32 GDI and DirectDraw               //
  3. //                             ISBN  0-13-086985-6                                   //
  4. //                                                                                   //
  5. //  Written            by  Yuan, Feng                             www.fengyuan.com   //
  6. //  Copyright (c) 2000 by  Hewlett-Packard Company                www.hp.com         //
  7. //  Published          by  Prentice Hall PTR, Prentice-Hall, Inc. www.phptr.com      //
  8. //                                                                                   //
  9. //  FileName   : ellipse.cpp                                                         //
  10. //  Description: Simple non-rectangular window demo, Chapter 5                       //
  11. //  Version    : 1.00.000, May 31, 2000                                              //
  12. //-----------------------------------------------------------------------------------//
  13.  
  14. #define STRICT
  15. #define WIN32_LEAN_AND_MEAN
  16.  
  17. #include <windows.h>
  18. #include <tchar.h>
  19.  
  20. #include "resource.h"
  21.  
  22. int MyMessageBox(HWND hWnd, const TCHAR * text, const TCHAR * caption, DWORD style)
  23. {
  24.     MSGBOXPARAMS param;
  25.  
  26.     memset(& param, 0, sizeof(param));
  27.     param.cbSize      = sizeof(param);
  28.     param.hwndOwner   = hWnd;
  29.     param.hInstance   = GetModuleHandle(NULL);
  30.     param.lpszText    = text;
  31.     param.lpszCaption = caption;
  32.     param.dwStyle     = style | MB_USERICON;
  33.     param.lpszIcon    = MAKEINTRESOURCE(IDI_GRAPH);
  34.  
  35.     return MessageBoxIndirect(¶m);
  36. }
  37.  
  38.  
  39. const TCHAR szProgram [] = _T("Window Region");
  40. const TCHAR szRectWin [] = _T("Rectangular Window");
  41. const TCHAR szEptcWin [] = _T("Elliptic Window");
  42.  
  43.  
  44. int WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, int)
  45. {
  46.     HWND hWnd = CreateWindow(_T("EDIT"), NULL, WS_OVERLAPPEDWINDOW,
  47.         10, 10, 200, 100, GetDesktopWindow(), NULL, hInst, NULL);
  48.     ShowWindow(hWnd, SW_SHOW);
  49.  
  50.     SetWindowText(hWnd, szRectWin);
  51.  
  52.     MyMessageBox(NULL, szRectWin, szProgram, MB_OK);
  53.  
  54.     HRGN hRgn = CreateEllipticRgn(0, 0, 200, 100);
  55.     SetWindowRgn(hWnd, hRgn, TRUE);
  56.     DeleteObject(hRgn);
  57.  
  58.     SetWindowText(hWnd, szEptcWin);
  59.     MyMessageBox(NULL, szEptcWin, szProgram, MB_OK);
  60.  
  61.     DestroyWindow(hWnd);
  62.  
  63.     return 0;
  64. }
  65.  
  66.