GP32 Need Help With My Coding


Splinter

Member
Joined
Jan 19, 2004
Messages
230
Age
35
Location
Donny, England (follow signs that say craphole)
Website
gp32place.150m.com
K i have been using the book 'How to code in C++ in 21 days' (or something like that) and even on the simplist tutorials i have errors that mean the program wont run. When i try to compile,build and run the application it says the exe and obj file need to be built but when i say yes it comes up with errors.

Any ideas?
 
Okay it's kind of simple:

You got your .c files. Or .cpp. These are the program source code itself. (or .cxx, .cc...)
They get compiled to .obj files.
If the .c(pp) files reference anything from other .c files, you need to declare these things. To cut down on repetition we usually have an associative .h file for every .c file that holds its stuff in a declaration form, without having any actual code in it. .h files, as they have no code, aren't compiled.

Now we have all these .obj files referencing each other, the linker takes them all and merges them to make an exe, making sure they point to each other correctly. It also links in external libraries like Allegro or OpenGL as needed.

So when you try to compile, MSVC (I assume you're using) needs to make the .obj files and from that the .exe file. A good thing is, if you only change one of your .c files, only that one needs to recompiled as the other .obj files are unchanged. When you have huge projects, this helps a LOT.

Now the problem is, your code is somehow wrong. As blipped4 points out, we can't help you without seeing the code. Without correct code the compiler cannot produce an .obj file and of course can't make the finished .exe application.

- Rico
 
blipped4 posted on Feb 8 2004 at 02:53 PM said:
Show me the source code.
I thought u couldnt code :blink:. why do you make requests for software if u could just do em urself? :ph34r:
 
Last edited by a moderator:
Heres my source code:

// Visual C ContolsDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Visual C Contols.h"
#include "Visual C ContolsDlg.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()

/////////////////////////////////////////////////////////////////////////////
// CVisualCContolsDlg dialog

CVisualCContolsDlg::CVisualCContolsDlg(CWnd* pParent /*=NULL*/)
: CDialog(CVisualCContolsDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CVisualCContolsDlg)
m_szMessage = _T("");
m_strProgToRun = _T("");
m_bEnableMsg = FALSE;
m_bEnablePgm = FALSE;
m_bShowMsg = FALSE;
m_bShowPgm = FALSE;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CVisualCContolsDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CVisualCContolsDlg)
DDX_Text(pDX, IDC_MSG, m_szMessage);
DDX_CBString(pDX, IDC_PROGTORUN, m_strProgToRun);
DDX_Check(pDX, IDC_CKENBLMSG, m_bEnableMsg);
DDX_Check(pDX, IDC_CKENBLPGM, m_bEnablePgm);
DDX_Check(pDX, IDC_CKSHWMSG, m_bShowMsg);
DDX_Check(pDX, IDC_CKSHWPGM, m_bShowPgm);
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CVisualCContolsDlg, CDialog)
//{{AFX_MSG_MAP(CVisualCContolsDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_EXIT, OnExit)
ON_BN_CLICKED(IDC_SHWMSG, OnShwmsg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CVisualCContolsDlg message handlers

BOOL CVisualCContolsDlg::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

//////////////////////
// MY CODE STARTS HERE
//////////////////////

// Put a default message in the message edit
m_str Message = "Place Message Here";

// Set all of the check boxes to be checked
m_bShowMsg = True;
m_bShowPgm = True;
m_bEnableMsg = True;
m_bEnablePgm = True;

// Update the dialog with the values
UpdateData(FALSE);

///////////////////////
// MY CODE ENDS HERE
///////////////////////

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


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

void CVisualCContolsDlg::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 CVisualCContolsDlg::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 CVisualCContolsDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}

void CVisualCContolsDlg::OnExit()
{
// TODO: Add your control notification handler code here

///////////////////////
// MY CODE STARTS HERE
///////////////////////

// Exit the program
OnOK();

///////////////////////
// MY CODE ENDS HERE
///////////////////////

}

void CVisualCContolsDlg::OnShwmsg()
{
// TODO: Add your control notification handler code here

///////////////////////
// MY CODE STARTS HERE
///////////////////////

// Updat the message variable with what the user entered
UpdateData(TRUE);

// Display the message for the user
MessageBox(m_strMessage);

///////////////////////
// MY CODE ENDS HERE
///////////////////////

}



But i guess you would need to see the e-book to know what i was trying to do in the tuturial i had to know what i was doing.

Also after i do more of these tutorials and can code for windows i dont understand how this would port to the gp32.

P.S. That may be a stupid question but come on im only 15
 
I think all this won't help you a lot with GP32 coding. Go get a plain C book, try to understand how
pointers, includes, makefiles work and then you should be ready to understand how to GP32 API is
used in your projects.
 
Splinter posted on Feb 8 2004 at 04:49 PM said:
If you think I'm going through that crap searching for errors you're misguided. Paste the errors MSVC generates as well, please.
 
Last edited by a moderator:
After a quick look through your code, I think that it is important to let you know that you are writing a lot of windows specific code. Did you create the project with the MFC Apwizard? I ask this because of the line :

// ClassWizard generated virtual function overrides

If this is so, then the book you are using is teaching you very specific code and it may be an idea to start with a different book. Probably one that just uses C, and starts by helping you make a program that prints out "Hello World" to the screen. I know its a pain starting with that, but it is the way it is.

Try looking for a C for dummies book, or somthing along those lines - they a pretty good.
 
Back
Top