» »

[C++] preprosto risanje

[C++] preprosto risanje

Cizimizi ::

upam da mi lahko nekdo pomaga s problemom ki ga imam
sem cisti zacetnik pri programeranju zato se ucim iz tutoriala
zdajle me uci kako narest preprost risalni program v visual C++, ki uporablja premik miske in rise crto od ene pike do druge
ko probam testirati program mi napise ta error:

----------------------------------------------------------------------------------
MouseManDlg.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\MouseMan\MouseManDlg.cpp(183) : error C2664: 'class CPoint __thiscall CDC::MoveTo(int,int)' : cannot convert parameter 1 from 'int (void)' to 'int'
Conversion is a valid standard conversion, which can be performed implicitly or by use of static_cast, C-style cast or function-style cast
C:\Program Files\Microsoft Visual Studio\MyProjects\MouseMan\MouseManDlg.cpp(189) : error C2659: '=' : overloaded function as left operand
C:\Program Files\Microsoft Visual Studio\MyProjects\MouseMan\MouseManDlg.cpp(190) : error C2659: '=' : overloaded function as left operand
Generating Code...
Error executing cl.exe.

MouseMan.exe - 4 error(s), 0 warning(s)
------------------------------------------------------------------------------------

mi lahko kdo pomaga najti napako ki sem jo naredil
sem sel po navodilih tutoriala a sem ocitno nekje zasral

------------------------------------------------------------------------------------

// MouseManDlg.cpp : implementation file
//

#include "stdafx.h"
#include "MouseMan.h"
#include "MouseManDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
CAboutDlg();

// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA

// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL

// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMouseManDlg dialog

CMouseManDlg::CMouseManDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMouseManDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CMouseManDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CMouseManDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMouseManDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CMouseManDlg, CDialog)
//{{AFX_MSG_MAP(CMouseManDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_MOUSEMOVE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMouseManDlg message handlers

BOOL CMouseManDlg::OnInitDialog()
{
CDialog::OnInitDialog();

// Add "About..." menu item to system menu.

// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);

CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}

// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon

// TODO: Add extra initialization here

return TRUE; // return TRUE unless you set the focus to a control
}

void CMouseManDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}

// 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 CMouseManDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, (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 to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CMouseManDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}






//MY CODE STARTS HERE//


void CMouseManDlg::OnMouseMove(UINT nFlags, CPoint point)
{
if ((nFlags & MK_LBUTTON) == MK_LBUTTON)
{


// Get the Device Context
CClientDC dc(this);

// Draw a line from the previous point to the current point
dc.MoveTo(m_iPrevX, m_iPrevY);


dc.LineTo(point.x, point.y);

// Save the current point as the previous point
m_iPrevX = point.x;
m_iPrevY = point.y;
}

CDialog::OnMouseMove(nFlags, point);
}

int CMouseManDlg::m_iPrevY()
{
}

int CMouseManDlg::m_iPrevX()
{
}
----------------------------------------------------------------


tisti del kjer je nehalo delat ko sem testiral se zacne kjer sem napisal //MY CODE STARTS HERE//
mislim da je nekaj manjka pri m_iPrevY in m_iPrevX
ampak ker sem sele zacetnik nimam pojma kaj

ce bi mi lahko kdo pomagal bi bil zelo hvalezen! :)

kihc ::

Lahko prosim daš link do tutoriala. Thnx.
x

Cizimizi ::

PagesfromTeachYourselfVisualC++.pdf
o programu za risanje se zacne pri DAY 3 na strani 47

Zgodovina sprememb…

  • spremenil: Cizimizi ()

OwcA ::

 int CMouseManDlg::m_iPrevY()
{
}

int CMouseManDlg::m_iPrevX()
{
}

Tole ne bo vredu. Glede na kdo, bi morali biti m_iPrevY in m_iPrevX spremenljivki (atributa), ne metodi.
Otroška radovednost - gonilo napredka.

Cizimizi ::

:(
torej naj napisem.....

Gundolf ::

Morda bi si ti pustil tael tutorial za kasneje in bi zaenkrat še prešaltal na kak lažji tutorial, ki je bolj osredotočen na C++ in manj na visal studio in grafiko.

snow ::

Prvo si poglej kaj so to razredi, metode itd.

Oziroma sploh osnove C++ če še ne znaš.

Veliko povezav: najdeš tukaj.
Random mutation plus nonrandom cumulative natural selection - Richard Dawkins

popec ::

Lahko bi poslal se mousemandlg.h. Vsaj tistih par vrstic, kjer imaš deklaracijo m_iPrevX in m_iPrevY.

Glede na to, da imata ti dve entiteti prefiks m_, bi sklepal, da nista mišljeni kot metodi, ampak podatkovna člana razreda.
Po prefiksu m_i bi sklepal, da gre za tip int, iz tvoje kode pa je razvidno, da si ju definiral (in tudi deklariral) kot metodi, ki vračata int.

Najpreprosteje bi bilo nadomestiti deklaracijo m_iPrevX in m_iPrevY v mousemandlg.h z nečim takim:
private:
  int m_iPrevX, m_iPrevY;

...nato pa pobrisati iz mousemandlg.cpp:
int CMouseManDlg::m_iPrevY()
{
}

int CMouseManDlg::m_iPrevX()
{
}
h$^


Vredno ogleda ...

TemaSporočilaOglediZadnje sporočilo
TemaSporočilaOglediZadnje sporočilo
»

python -slovar

Oddelek: Programiranje
223135 (2114) Valex86
»

[VC++, MFC] OnPaint

Oddelek: Programiranje
51007 (974) whatever
»

[Visual c++] DoModal()

Oddelek: Programiranje
8862 (783) fogl
»

c++ zapis funkcije

Oddelek: Programiranje
81203 (1126) Vesoljc
»

Win32 API in C++

Oddelek: Programiranje
131573 (1444) Monster

Več podobnih tem