Advertisement
Guest User

Untitled

a guest
Dec 18th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.39 KB | None | 0 0
  1. // Okno.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "lab4.h"
  6. #include "Okno.h"
  7.  
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #endif
  11.  
  12. static UINT NEAR WM_LAB4 = RegisterWindowMessage("WM_SYSTOPER_LAB4");
  13.  
  14. // CAboutDlg dialog used for App About
  15.  
  16. class CAboutDlg : public CDialog
  17. {
  18. public:
  19. CAboutDlg();
  20.  
  21. // Dialog Data
  22. enum { IDD = IDD_ABOUTBOX };
  23.  
  24. protected:
  25. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  26.  
  27. // Implementation
  28. protected:
  29. DECLARE_MESSAGE_MAP()
  30. };
  31.  
  32. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  33. {
  34. }
  35.  
  36. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  37. {
  38. CDialog::DoDataExchange(pDX);
  39. }
  40.  
  41. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  42. END_MESSAGE_MAP()
  43.  
  44.  
  45. // COkno dialog
  46.  
  47.  
  48.  
  49. COkno::COkno(CWnd* pParent /*=NULL*/)
  50. : CDialog(COkno::IDD, pParent)
  51. {
  52. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  53. }
  54.  
  55. void COkno::DoDataExchange(CDataExchange* pDX)
  56. {
  57. CDialog::DoDataExchange(pDX);
  58. DDX_Control(pDX, IDC_EKRAN, m_ekran);
  59. DDX_Control(pDX, IDC_LISTA, m_lista);
  60. DDX_Control(pDX, IDC_ODSWIEZ, m_odswiez);
  61. }
  62.  
  63. BEGIN_MESSAGE_MAP(COkno, CDialog)
  64. ON_WM_SYSCOMMAND()
  65. ON_WM_PAINT()
  66. ON_WM_QUERYDRAGICON()
  67. //}}AFX_MSG_MAP
  68. ON_WM_TIMER()
  69. ON_REGISTERED_MESSAGE(WM_LAB4,OnWiadomosc)
  70. ON_BN_CLICKED(IDC_ODSWIEZ, OnBnClickedOdswiez)
  71. ON_BN_CLICKED(IDC_WYSLIJ, OnBnClickedWyslij)
  72. ON_BN_CLICKED(IDC_ZALICZAMY, OnBnClickedZaliczamy)
  73. ON_WM_DESTROY()
  74. ON_BN_CLICKED(IDC_KONIEC, OnBnClickedKoniec)
  75. END_MESSAGE_MAP()
  76.  
  77.  
  78. // COkno message handlers
  79.  
  80. BOOL COkno::OnInitDialog()
  81. {
  82. CDialog::OnInitDialog();
  83.  
  84. // Add "About..." menu item to system menu.
  85.  
  86. // IDM_ABOUTBOX must be in the system command range.
  87. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  88. ASSERT(IDM_ABOUTBOX < 0xF000);
  89.  
  90. CMenu* pSysMenu = GetSystemMenu(FALSE);
  91. if (pSysMenu != NULL)
  92. {
  93. CString strAboutMenu;
  94. strAboutMenu.LoadString(IDS_ABOUTBOX);
  95. if (!strAboutMenu.IsEmpty())
  96. {
  97. pSysMenu->AppendMenu(MF_SEPARATOR);
  98. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  99. }
  100. }
  101.  
  102. // Set the icon for this dialog. The framework does this automatically
  103. // when the application's main window is not a dialog
  104. SetIcon(m_hIcon, TRUE); // Set big icon
  105. SetIcon(m_hIcon, FALSE); // Set small icon
  106.  
  107. // Add extra initialization here
  108.  
  109. srand((unsigned)time(0));
  110. SetTimer(1,500,0);
  111.  
  112. //TODO: Utworzenie skrzynki pocztowej i jej rejestracja potokiem nazwanym
  113.  
  114. return TRUE; // return TRUE unless you set the focus to a control
  115. }
  116.  
  117. void COkno::OnSysCommand(UINT nID, LPARAM lParam)
  118. {
  119. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  120. {
  121. CAboutDlg dlgAbout;
  122. dlgAbout.DoModal();
  123. }
  124. else
  125. {
  126. CDialog::OnSysCommand(nID, lParam);
  127. }
  128. }
  129.  
  130. // If you add a minimize button to your dialog, you will need the code below
  131. // to draw the icon. For MFC applications using the document/view model,
  132. // this is automatically done for you by the framework.
  133.  
  134. void COkno::OnPaint()
  135. {
  136. if (IsIconic())
  137. {
  138. CPaintDC dc(this); // device context for painting
  139.  
  140. SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
  141.  
  142. // Center icon in client rectangle
  143. int cxIcon = GetSystemMetrics(SM_CXICON);
  144. int cyIcon = GetSystemMetrics(SM_CYICON);
  145. CRect rect;
  146. GetClientRect(&rect);
  147. int x = (rect.Width() - cxIcon + 1) / 2;
  148. int y = (rect.Height() - cyIcon + 1) / 2;
  149.  
  150. // Draw the icon
  151. dc.DrawIcon(x, y, m_hIcon);
  152. }
  153. else
  154. {
  155. CDialog::OnPaint();
  156. }
  157. }
  158.  
  159. // The system calls this function to obtain the cursor to display while the user drags
  160. // the minimized window.
  161. HCURSOR COkno::OnQueryDragIcon()
  162. {
  163. return static_cast<HCURSOR>(m_hIcon);
  164. }
  165.  
  166. void COkno::OnTimer(UINT nIDEvent)
  167. {
  168. //TODO: Sprawdzenie czy jest nowa wiadomosc w skrzynce
  169.  
  170. CDialog::OnTimer(nIDEvent);
  171. }
  172.  
  173. void COkno::OnBnClickedOdswiez()
  174. {
  175. char buffer[1024]="";
  176.  
  177. /*TODO: Pobranie listy zarejestrowanych skrzynek*/
  178.  
  179. }
  180.  
  181. void COkno::OnBnClickedWyslij()
  182. {
  183. char buffer[128];
  184. m_lista.GetWindowText(buffer,128);
  185.  
  186. //TODO: Wyslanie wiadomosci do wybranej skrzynki
  187.  
  188. }
  189.  
  190. afx_msg LRESULT COkno::OnWiadomosc(WPARAM n, LPARAM m)
  191. {
  192. //TODO: Odbior przeslanego kodu
  193.  
  194. return 0;
  195. }
  196.  
  197. void COkno::OnBnClickedZaliczamy()
  198. {
  199. /*TODO: Utworzenie zdarzenia "koniec ćwiczenia" i ustawienie jego stanu na dostepny*/
  200.  
  201. }
  202.  
  203. void COkno::OnDestroy()
  204. {
  205. KillTimer(1);
  206. CDialog::OnDestroy();
  207. }
  208.  
  209. void COkno::OnBnClickedKoniec()
  210. {
  211. EndDialog(1);
  212. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement