home *** CD-ROM | disk | FTP | other *** search
/ Popular Software Hundred Flowers Garden / POPSOFT_BHW.iso / SOFTWARE / AUDIO / DUTTY++ / DUTTY / DATA.Z / Mainfrm.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-09-08  |  3.2 KB  |  143 lines

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "demo.h"
  6.  
  7. #include "MainFrm.h"
  8.  
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CMainFrame
  17.  
  18. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  19.  
  20. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  21.     //{{AFX_MSG_MAP(CMainFrame)
  22.     ON_WM_CREATE()
  23.     ON_WM_PAINT()
  24.     ON_COMMAND(ID_MENUITEM_EXIT, OnMenuitemExit)
  25.     //}}AFX_MSG_MAP
  26. END_MESSAGE_MAP()
  27.  
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CMainFrame construction/destruction
  30.  
  31. CMainFrame::CMainFrame()
  32. {
  33.     // TODO: add member initialization code here
  34.     
  35. }
  36.  
  37. CMainFrame::~CMainFrame()
  38. {
  39. }
  40.  
  41. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  42. {
  43.     // TODO: Modify the Window class or styles here by modifying
  44.     //  the CREATESTRUCT cs
  45.  
  46.     return CFrameWnd::PreCreateWindow(cs);
  47. }
  48.  
  49. /////////////////////////////////////////////////////////////////////////////
  50. // CMainFrame diagnostics
  51.  
  52. #ifdef _DEBUG
  53. void CMainFrame::AssertValid() const
  54. {
  55.     CFrameWnd::AssertValid();
  56. }
  57.  
  58. void CMainFrame::Dump(CDumpContext& dc) const
  59. {
  60.     CFrameWnd::Dump(dc);
  61. }
  62.  
  63. #endif //_DEBUG
  64.  
  65. /////////////////////////////////////////////////////////////////////////////
  66. // CMainFrame message handlers
  67.  
  68. LRESULT CMainFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
  69. {
  70.     // TODO: Add your specialized code here and/or call the base class
  71.     if(message == (WM_USER + 1001))
  72.     {
  73.         ProcessMessage(wParam, lParam);
  74.     }
  75.  
  76.     return CFrameWnd::WindowProc(message, wParam, lParam);
  77. }
  78.  
  79. void CMainFrame::ProcessMessage(WPARAM wParam, LPARAM lParam)
  80. {
  81.     
  82.     char* l[] = {"╡τ╗░","┐┤╙░╡·","╠²╥⌠└╓","═µ╙╬╧╖",
  83.         "╔╧═°┴─╠∞","┤≥╫╓","▓╗╓¬╡└╧δ╕╔╩▓├┤","╬╥╧δ╤º╡τ─╘"};
  84.     static count = 0;
  85.     CDC* pdc = GetDC();
  86.  
  87.     CBrush brush, *oldbrush;
  88.     if(count%2) brush.CreateSolidBrush(RGB(192, 192, 192));
  89.     else brush.CreateSolidBrush(RGB(255,255,0));
  90.  
  91.     oldbrush = pdc->SelectObject(&brush);
  92.  
  93.     CString L0("╩╢▒≡╜ß╣√");
  94.     CString L1(l[wParam]);
  95.  
  96.     pdc->Rectangle(100, 150, 400, 300);
  97.  
  98.     CFont font;
  99.     font.CreateFont(18, 8, 5, 5, FW_THIN, 0, 0, 0, ANSI_CHARSET, OUT_CHARACTER_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "DuttyFont" );
  100.     CFont * oldFont;
  101.     oldFont = pdc->SelectObject(&font);
  102.  
  103.  
  104.     pdc->TextOut(140, 180, L0);
  105.     pdc->TextOut(200, 220, L1);
  106.  
  107.     pdc->SelectObject(oldFont);
  108.     ReleaseDC(pdc);
  109.     count ++;
  110.  
  111. }
  112.  
  113. BOOL CMainFrame::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) 
  114. {
  115.     // TODO: Add your specialized code here and/or call the base class
  116.     
  117.     return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
  118. }
  119.  
  120. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) 
  121. {
  122.     if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  123.         return -1;
  124.     
  125.     // TODO: Add your specialized creation code here
  126.     SetWindowText("Demo Window");
  127.     return 0;
  128. }
  129.  
  130. void CMainFrame::OnPaint() 
  131. {
  132.     CPaintDC dc(this); // device context for painting
  133.     
  134.     
  135.     SetWindowText("Demo Window");
  136.     
  137. }
  138.  
  139. void CMainFrame::OnMenuitemExit() 
  140. {
  141.     DestroyWindow();
  142. }
  143.