p align="left">SetIcon(m_hIcon, TRUE);// Set big icon SetIcon(m_hIcon, FALSE);// Set small icon // TODO: Add extra initialization here // SetTimer(1,500,0); //-------------------------------------------------- CRect rcClient; GetClientRect(rcClient); rcClient.InflateRect(-2, -2, -2, -20); GetDlgItem(IDC_EDIT1)->MoveWindow(rcClient); //------------------------------------------------ //Акселератор m_hAccel = ::LoadAccelerators(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDR_ACCELERATOR1)); //---------------------------------------------------- // Инициализируем шрифт текста CFont *pFontText = m_Edit1.GetFont(); LOGFONT lfText; pFontText->GetLogFont(&lfText); m_fontText.CreateFontIndirect(&lfText); //m_editMain.m_menuPopup.LoadMenu(IDR_MENU_POPUP); //---------------------------------------------------- //StatusBar m_wndStatusBar.Create(WS_CHILD | WS_VISIBLE | CCS_BOTTOM | SBARS_SIZEGRIP, CRect(0, 0, 0, 0), this, IDC_STATUS_BAR); CRect rect; m_wndStatusBar.GetClientRect(&rect); int nParts[] = {rect.right - 200, - 1}; CString strPartsStatusBar; strPartsStatusBar.Format(_T("Стр %d, стлб %d"), m_nStrStatusBar = 1, m_nStolbetsStatusBar= 1); m_wndStatusBar.SetParts(sizeof(nParts)/sizeof(nParts[0]), nParts); m_wndStatusBar.SetText(strPartsStatusBar, 1, 0); m_nTimer = SetTimer(1, 100, NULL); m_wndStatusBar.ShowWindow(SW_SHOW); //------------------------------------------------------- //tray m_menuTray.LoadMenu(IDR_MENU2); m_nidTray.cbSize = sizeof(NOTIFYICONDATA); m_nidTray.hWnd = m_hWnd; m_nidTray.uID = ID_TRAYICON; m_nidTray.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; m_nidTray.hIcon = AfxGetApp()->LoadIcon(IDI_ICON1); m_nidTray.uCallbackMessage = WM_TRAYICON; _tcscpy(m_nidTray.szTip, _T("Блокнот Лехи Каменева")); //-------------------------------------------------------- CMenu* MENU = GetMenu(); CMenu* sibmenu = MENU->GetSubMenu(1); sibmenu->EnableMenuItem(ID_Otmenit, MF_BYCOMMAND | MF_GRAYED); CMenu* MENU1 = GetMenu(); CMenu* submenu = MENU1->GetSubMenu(1); submenu->EnableMenuItem(ID_Wirezat, MF_BYCOMMAND | MF_GRAYED); CMenu* MENU2 = GetMenu(); CMenu* sebmenu = MENU2->GetSubMenu(1); sebmenu->EnableMenuItem(ID_Kopirowat, MF_BYCOMMAND | MF_GRAYED); CMenu* MENU3 = GetMenu(); CMenu* sobmenu = MENU3->GetSubMenu(1); sobmenu->EnableMenuItem(ID_Udalit, MF_BYCOMMAND | MF_GRAYED); //---------------------------------------------------------------- m_pAddDlg = NULL; return TRUE; // return TRUE unless you set the focus to a control } // If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework. void CMenuDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CDialog::OnPaint(); } } // The system calls this function to obtain the cursor to display while the user drags // the minimized window. HCURSOR CMenuDlg::OnQueryDragIcon() { return static_cast<HCURSOR>(m_hIcon); } void CMenuDlg::OnSozdat()//Создать ------------------------------ { CString str_77 , strText; CString str_r; m_Edit1.GetWindowText(str_r); if (str_r == _T("")) { //Beep(1000,100); } else if (str_r != _T("")) { UINT uRes = MessageBox(_T("Текст в файле Безымянный был изменньон \n\n Сохранить изменение?"), _T("Блокнот(Alexa)"), MB_YESNOCANCEL | MB_ICONWARNING); if (uRes == IDYES) { CFileDialog fileDlg(FALSE,_T(".txt"),NULL,NULL,"Text Files(*.txt) |*.txt|",NULL); if(fileDlg.DoModal() == IDOK) { CStdioFile f; if(!f.Open(fileDlg.GetPathName(), CFile::modeCreate | CFile::modeWrite)) { MessageBox("Не могу сохранить файл"); return; } /*while (f.ReadString(str_77)) { if (!strText.IsEmpty()) strText += "\r\n"; strText += str_77; }*/ CString str; m_Edit1.GetWindowText(str); f.Write(str, str.GetLength()); f.Close(); SetDlgItemText(IDC_EDIT1, strText); m_strPath = fileDlg.GetPathName(); m_strFileName = f.GetFileName(); SetWindowText(m_strFileName + _T("-Блокнот(Alexa)")); CEdit *mEdit = (CEdit *)GetDlgItem(IDC_EDIT1); mEdit->SetSel(0,-1); mEdit->Clear(); //m_strPath = _T("Безымянный"); SetWindowText(_T("Безымянный-Блокнот(Alexa)")); } } if (uRes == IDNO) { CEdit *mEdit = (CEdit *)GetDlgItem(IDC_EDIT1); mEdit->SetSel(0,-1); mEdit->Clear(); //m_strPath = _T("Безымянный"); SetWindowText(_T("Безымянный-Блокнот(Alexa)")); } } } BOOL CMenuDlg::PreTranslateMessage(MSG* pMsg) { if (pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST) return ::TranslateAccelerator(m_hWnd, m_hAccel, pMsg); return CDialog::PreTranslateMessage(pMsg); } void CMenuDlg::OnWixod()//Выход-------------------------------------------- {CString str_77, strText; CString str_r; CStdioFile f; m_Edit1.GetWindowText(str_r); if (str_r == _T("")) { EndDialog(0); return; } else if (str_r != _T("")) { UINT uRes = MessageBox(_T("Текст в файле Безымянный был изменньон \n\n Сохранить изменение?"), _T("Блокнот"), MB_YESNOCANCEL | MB_ICONWARNING); if (uRes == IDYES) { //CString path; CFileDialog fileDlg(FALSE,_T(".txt"),NULL,NULL,"Text Files(*.txt) |*.txt|",NULL); if(fileDlg.DoModal() == IDOK) { //path = fdlg.GetPathName(); //CFile f; if(!f.Open(fileDlg.GetPathName(), CFile::modeCreate | CFile::modeWrite)) { MessageBox("Не могу сохранить файл"); return; } while (f.ReadString(str_77)) { if (!strText.IsEmpty()) strText += "\r\n"; strText += str_77; } SetDlgItemText(IDC_EDIT1, strText); m_strPath = fileDlg.GetPathName(); m_strFileName = f.GetFileName(); SetWindowText(m_strFileName + _T("-Блокнот")); } } if (uRes == IDNO) { EndDialog(0); //CDialog::OnClose(); } if (uRes == IDCANCEL) { } } } void CMenuDlg::OnOtkrit()//Открыть---------------------------------------- { CString str_77 , strText; CStdioFile f; CString str_r; m_Edit1.GetWindowText(str_r); if (str_r == _T("")) { CFileDialog fileDlg(TRUE, _T(".txt"), NULL, OFN_ALLOWMULTISELECT | OFN_FILEMUSTEXIST, _T("All Files (*.*) |*.*| Text Files(*.txt) | *.txt| Word Files(*.doc) |*.doc|")); if (fileDlg.DoModal() == IDOK) { if (!f.Open(fileDlg.GetPathName(), CFile::modeRead | CFile::typeText)) { MessageBox("Не могу открыть файл"); return; } while (f.ReadString(str_77)) { if (!strText.IsEmpty()) strText += "\r\n"; strText += str_77; } /*CString str; m_Edit1.GetWindowText(str); f.Write(str, str.GetLength()); f.Close();*/ SetDlgItemText(IDC_EDIT1, strText); m_strPath = fileDlg.GetPathName(); m_strFileName = f.GetFileName(); SetWindowText(m_strFileName + _T("-Блокнот")); } } else if (str_r != _T("")) { UINT uRes = MessageBox(_T("Текст в файле Безымянный был изменньон \n\n Сохранить изменение?"), _T("Блокнот"), MB_YESNOCANCEL | MB_ICONWARNING); if (uRes == IDYES) { //CString path; CFileDialog fileDlg(FALSE,_T(".txt"),NULL,NULL,"Text Files(*.txt) |*.txt|",NULL); if(fileDlg.DoModal() == IDOK) { //path = fdlg.GetPathName(); //CFile f; if(!f.Open(fileDlg.GetPathName(), CFile::modeCreate | CFile::modeWrite)) { MessageBox("Не могу сохранить файл"); return; } while (f.ReadString(str_77)) { if (!strText.IsEmpty()) strText += "\r\n"; strText += str_77; } SetDlgItemText(IDC_EDIT1, strText); m_strPath = fileDlg.GetPathName(); m_strFileName = f.GetFileName(); SetWindowText(m_strFileName + _T("-Блокнот")); } CFileDialog fileDlg1(TRUE, _T(".txt"), NULL, OFN_ALLOWMULTISELECT | OFN_FILEMUSTEXIST, _T("All Files (*.*) |*.*| Text Files(*.txt) | *.txt| Word Files(*.doc) |*.doc|")); if (fileDlg1.DoModal() == IDOK) { if (!f.Open(fileDlg1.GetPathName(), CFile::modeRead | CFile::typeText)) { MessageBox("Не могу открыть файл"); return; } while (f.ReadString(str_77)) { if (!strText.IsEmpty()) strText += "\r\n"; strText += str_77; } SetDlgItemText(IDC_EDIT1, strText); m_strPath = fileDlg1.GetPathName(); m_strFileName = f.GetFileName(); SetWindowText(m_strFileName + _T("-Блокнот")); } } if (uRes == IDNO) { CFileDialog fileDlg(TRUE, _T(".txt"), NULL, OFN_ALLOWMULTISELECT | OFN_FILEMUSTEXIST, _T("All Files (*.*) |*.*| Text Files(*.txt) | *.txt| Word Files(*.doc) |*.doc|")); if (fileDlg.DoModal() == IDOK) { if (!f.Open(fileDlg.GetPathName(), CFile::modeRead | CFile::typeText)) { MessageBox("Не могу открыть файл");
Страницы: 1, 2, 3, 4
|