Click here to Skip to main content
15,887,454 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: File Deletion using SHFILEOPSTRUCT & SHFileOperation Pin
Padmanabha_M6-May-09 20:08
Padmanabha_M6-May-09 20:08 
GeneralRe: File Deletion using SHFILEOPSTRUCT & SHFileOperation Pin
David Crow7-May-09 3:31
David Crow7-May-09 3:31 
QuestionNeed help on Dock Window Pin
nick2reg6-May-09 17:22
nick2reg6-May-09 17:22 
QuestionVery difficult problem about CExplorer1. Pin
cwj_6-May-09 15:38
cwj_6-May-09 15:38 
QuestionRe: Very difficult problem about CExplorer1. Pin
Madhu Nair6-May-09 17:36
Madhu Nair6-May-09 17:36 
AnswerRe: Very difficult problem about CExplorer1. Pin
Stuart Dootson6-May-09 20:06
professionalStuart Dootson6-May-09 20:06 
AnswerRe: Very difficult problem about CExplorer1. Pin
virusest31-Dec-10 18:13
virusest31-Dec-10 18:13 
Questionmatrix in window Pin
kiemxai6-May-09 14:45
kiemxai6-May-09 14:45 
the article is, the programming window ... make the matrix of the matrix A
This is the code which i did but algorithm fails...
can you help me decode...thanks!

//	Лабораторная работа №10
#define IDC_MYBUTTON 100	// Идентификатор кнопки
#define IDC_MYEDIT1 102	// Идентификатор поля редактирования 1
#define IDC_MYEDIT2 104	// Идентификатор поля редактирования 2


#include "afxwin.h" // MFC Основные и стандартные компоненты
#include <iostream>
using namespace std;

class CMyButton: public CButton
{
public:
	afx_msg void OnLButtonDown(UINT, CPoint);
private:
	DECLARE_MESSAGE_MAP(); // таблица откликов кнопки
};

void CMyButton::OnLButtonDown(UINT, CPoint)
{
	AfxMessageBox("...");

}


BEGIN_MESSAGE_MAP(CMyButton, CButton) // таблица откликов на сообщения
	ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()

class CMainWnd : public CFrameWnd
{
public:
	CMainWnd();
	afx_msg void OnLButtonDown(UINT, CPoint);	// виртуальная процедура ответа на левую кнопку
	afx_msg void OnRButtonDblClk(UINT, CPoint);	// виртуальная процедура ответа на правую кнопку
	afx_msg void OnKeyDown(UINT, UINT, UINT);	// виртуальная процедура ответа на клавишу
	~CMainWnd();    // деструктор
	CStatic* MyStatic;
	CMyButton* MyButton;
	CEdit* MyEdit1, * MyEdit2;
	DECLARE_MESSAGE_MAP(); // таблица откликов
};


BEGIN_MESSAGE_MAP(CMainWnd, CFrameWnd)	// таблица откликов на сообщения
	ON_WM_LBUTTONDOWN()		// реакция на нажатие левой кнопки мыши
	ON_WM_RBUTTONDBLCLK()		// реакция на нажатие правой кнопки мышки
	ON_WM_KEYDOWN()			// реакция на нажатие клавиши
END_MESSAGE_MAP()

void CMainWnd::OnKeyDown(UINT, UINT, UINT)
{
	AfxMessageBox(" Key Button Down ");
}
void CMainWnd::OnRButtonDblClk(UINT, CPoint)
{
	AfxMessageBox(" Rigth Button Click ");
}
void CMainWnd::OnLButtonDown(UINT, CPoint)
{
	char buff[255];
	int count=0;
	MyEdit1->GetLine(0,buff);
	AfxMessageBox(buff);
}



CMainWnd::CMainWnd()
{
	Create(NULL,"Лабораторная работа № 10",WS_OVERLAPPEDWINDOW,CRect(500,250,800,450),
		NULL,NULL);// Создать окно программы
	// оператор new по умолчанию в случае ошибки вернет NULL
	// проверка указателя на NULL дает возможность избавиться от дальнейших ошибок
	MyStatic = new CStatic();
	if (MyStatic!=NULL) MyStatic->Create("matrix",WS_CHILD|WS_VISIBLE|SS_CENTER,
		CRect(100,10,140,50),this);	
	MyButton = new CMyButton();
	MyEdit1 = new CEdit();
	if (MyEdit1!=NULL) MyEdit1->Create(WS_CHILD|WS_VISIBLE|WS_BORDER,
		CRect(40,10,80,50),this,IDC_MYEDIT1);
	MyEdit2 = new CEdit();
	if (MyEdit2!=NULL) MyEdit2->Create(WS_CHILD|WS_VISIBLE|WS_BORDER,
		CRect(160,10,200,50),this,IDC_MYEDIT2);
	if (MyButton!=NULL) MyButton->Create("=",WS_CHILD|WS_VISIBLE|SS_CENTER,
		CRect(220,10,280,50),this,IDC_MYBUTTON);
	MyEdit1->SetWindowTextA("2");
	MyEdit2->SetWindowTextA("3");
}
CMainWnd::~CMainWnd()
{
	if (MyStatic!=NULL) delete MyStatic;	// удалить динамический объект
	if (MyButton!=NULL) delete MyButton;	// удалить динамический объект
	if (MyEdit1!=NULL) delete MyEdit1;	// удалить динамический объект
	if (MyEdit2!=NULL) delete MyEdit2;	// удалить динамический объект
}


class CMyApp : public CWinApp
{
public:
	CMyApp();			//конструктор по умолчанию
	virtual BOOL InitInstance();//стандартная инициализация
};

CMyApp::CMyApp() // конструктор главного класса приложения
{}

BOOL CMyApp::InitInstance() // стандартная инициализация
{
	m_pMainWnd=new CMainWnd();	// создать класс окна
	ASSERT(m_pMainWnd);	// проверить его правильность
	m_pMainWnd->ShowWindow(SW_SHOW);// Показать окно
	m_pMainWnd->UpdateWindow();
  // Обновить окно
  
   matrix a;
   a.inmatrix();
   cout << "beginning: "<<endl;
   a.outMaTrix();
   int i,j;
   int z =1;
   do 
   {
      cout << "enter row to delete: ";
      cin >> i;
      cout << "enter col to delete: ";
      cin >> j;
	  
      a.MaTrixdel(i,j);
      cout << "do you want to continue? 1: yes, 0: no   ";
      cin >> z;
   } while (z == 1);
   
	return TRUE;		
};


CMyApp theApp;	// запуск приложения
class matrix
{
private:
   int m_Col;
   int m_row;
   int a[100][100];
public:
   void inmatrix()
   {
      cout << "enter row: ";
      cin >> m_row;
      cout << "enter col: ";
      cin >> m_Col;
      for (int i=1; i<=m_row; i++)
      {
         for (int j=1; j<=m_Col; j++)
         {
            cout << "enter a["<<i<<"]["<<j<<"]: ";
            cin >> a[i][j];
         }
      }
   }
   void outMaTrix()
   {
      for (int i=1; i<=m_row; i++)
      {
         for (int j=1; j<=m_Col; j++)
         {
            cout << a[i][j] << "  " ;
         }
         cout <<endl;
      }
   }
   void MaTrixdel(int i, int j)
   {
      cout << "matrix after deleted: \n";
	  if ((i<=m_row)&&(j<=m_Col)) {
      for (int k=1; k<=m_row; k++)
      {
         for (int h=1; h<=m_Col;h++)
         {
            if (!(k==i||h==j))
            {
               cout<<a[k][h]<<"  ";
            }
         }
         cout <<endl;
      }
	  }
	  else cout<<"error:you are not right\n";
   }
};

AnswerRe: matrix in window Pin
Stuart Dootson6-May-09 19:41
professionalStuart Dootson6-May-09 19:41 
GeneralRe: matrix in window Pin
kiemxai6-May-09 23:19
kiemxai6-May-09 23:19 
GeneralRe: matrix in window Pin
Stuart Dootson6-May-09 23:22
professionalStuart Dootson6-May-09 23:22 
QuestionInclude order issues Pin
__DanC__6-May-09 9:53
__DanC__6-May-09 9:53 
AnswerRe: Include order issues Pin
Stuart Dootson6-May-09 10:40
professionalStuart Dootson6-May-09 10:40 
GeneralRe: Include order issues Pin
__DanC__6-May-09 11:00
__DanC__6-May-09 11:00 
GeneralRe: Include order issues Pin
Stuart Dootson6-May-09 11:14
professionalStuart Dootson6-May-09 11:14 
GeneralRe: Include order issues Pin
__DanC__6-May-09 21:06
__DanC__6-May-09 21:06 
Questionhelp extracting data Pin
dunlapjw6-May-09 7:42
dunlapjw6-May-09 7:42 
AnswerRe: help extracting data Pin
Madhu Nair6-May-09 8:41
Madhu Nair6-May-09 8:41 
QuestionRe: help extracting data Pin
David Crow6-May-09 8:42
David Crow6-May-09 8:42 
QuestionByte alignement - qt Pin
yaronillouz6-May-09 7:21
yaronillouz6-May-09 7:21 
AnswerRe: Byte alignement - qt Pin
Stuart Dootson6-May-09 8:31
professionalStuart Dootson6-May-09 8:31 
GeneralRe: Byte alignement - qt Pin
yaronillouz6-May-09 19:04
yaronillouz6-May-09 19:04 
GeneralRe: Byte alignement - qt Pin
Stuart Dootson6-May-09 19:35
professionalStuart Dootson6-May-09 19:35 
QuestionDocument/View Problem Pin
nick2reg6-May-09 6:30
nick2reg6-May-09 6:30 
AnswerRe: Document/View Problem Pin
Iain Clarke, Warrior Programmer6-May-09 7:00
Iain Clarke, Warrior Programmer6-May-09 7:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.