Hello, I'm trying to get an OOP MFC application working, so far it complies and everything but nothing happens. And I cant work out why. I would post code snippets but the simple fact is the MFC lib is far too big for that stuff. I've zipped up my project but be warned its 5 mb!

Any help would be appricated and sorry if its in the wrong forum.

http://www.bsc-coding.com/GUI.zip

did you delete the debug and/or release directories before you zipped of those files? And what compiler/version did you use?

did you delete the debug and/or release directories before you zipped of those files? And what compiler/version did you use?

Acient this is MFC not normal C++ , the large file size i beleive is down to the inc libs and the visual forms, using .NET 2003

Yes, I know a lot about MFC -- the compiler creates one of two sub-directories under the directory that contains the source file(s) -- <source>/debug for debug builds and <source>/release for release builds. Both directories contain all the *.objs, *.sbrs, *.pch and several other compiler-generated files. You need to delete those directories because they are huge.

It is not necessary to add system *.lib files to the source directory.

The actual source file(s) in your project should zip up to only a few hundred K, well under one meg, unless you have a really really huge project consisting of several hundred *.cpp and *.h files.

People will be more willing to download your project if you strip it of all the unnecessary files before zipping.

Hello,

sorry for the quick harsh reply. I've updated the zip file and its less than 180kb. I've got the project to compile, but when you add a recording it doesnt seem to add, nor does it print correctly. Any assistance would be greatly appricated.

John

If you haven't already figured it out yourself, you will need to pass the array to ShowRecordingsDlg constructor so that it can have access to the information.,

// ShowRecordingsDlg.h

class CShowRecordingsDlg : public CDialog
{
	DECLARE_DYNAMIC(CShowRecordingsDlg)

public:
   CShowRecordingsDlg(CRecording* recordings,CWnd* pParent = NULL);   // standard constructor
	virtual ~CShowRecordingsDlg();

// Dialog Data
	enum { IDD = IDD_SHOWRECORDING };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	DECLARE_MESSAGE_MAP()
	CRecording* m_recordings;
public:
	CEdit ShowArtist;
	CEdit ShowTitle;
	CEdit ShowLenght;
	int m_nIndex;
	afx_msg void Forwardbtn();

	void display();
};
// ShowRecordingsDlg.cpp

CShowRecordingsDlg::CShowRecordingsDlg(CRecording* recordings,CWnd* pParent /*=NULL*/)
	: CDialog(CShowRecordingsDlg::IDD, pParent)
{
	m_nIndex = 0;
	m_recordings = recordings;
}

Make the above and the dialog will have access to the entire array. Create an OnInitDialog() event handler and populate the dialog's controls there.

Hello, thanks for the reply I've implemented the changes to match your code in the red, however something nasty happend:

c:\Documents and Settings\Administrator\Desktop\RecordingUI\ShowRecordingsDlg.h(12): error C2143: syntax error : missing ')' before '*'
c:\Documents and Settings\Administrator\Desktop\RecordingUI\ShowRecordingsDlg.h(12): error C2143: syntax error : missing ';' before '*'
c:\Documents and Settings\Administrator\Desktop\RecordingUI\ShowRecordingsDlg.h(12): error C2460: 'CShowRecordingsDlg::CRecording' : uses 'CShowRecordingsDlg', which is being defined
c:\Documents and Settings\Administrator\Desktop\RecordingUI\ShowRecordingsDlg.h(12): error C2501: 'CShowRecordingsDlg::recordings' : missing storage-class or type specifiers
c:\Documents and Settings\Administrator\Desktop\RecordingUI\ShowRecordingsDlg.h(12): error C2143: syntax error : missing ';' before '*'
c:\Documents and Settings\Administrator\Desktop\RecordingUI\ShowRecordingsDlg.h(12): error C2501: 'CShowRecordingsDlg::CWnd' : missing storage-class or type specifiers
c:\Documents and Settings\Administrator\Desktop\RecordingUI\ShowRecordingsDlg.h(12): error C2059: syntax error : ')'
c:\Documents and Settings\Administrator\Desktop\RecordingUI\ShowRecordingsDlg.h(12): error C2864: 'pParent' : only const static integral data members can be initialized inside a class or struct
c:\Documents and Settings\Administrator\Desktop\RecordingUI\ShowRecordingsDlg.h(12): error C2501: 'CShowRecordingsDlg::pParent' : missing storage-class or type specifiers
c:\Documents and Settings\Administrator\Desktop\RecordingUI\ShowRecordingsDlg.h(24): error C2143: syntax error : missing ';' before '*'
c:\Documents and Settings\Administrator\Desktop\RecordingUI\ShowRecordingsDlg.h(24): error C2501: 'CShowRecordingsDlg::CRecording' : missing storage-class or type specifiers
c:\Documents and Settings\Administrator\Desktop\RecordingUI\ShowRecordingsDlg.h(24): error C2501: 'CShowRecordingsDlg::m_recordings' : missing storage-class or type specifiers
c:\Documents and Settings\Administrator\Desktop\RecordingUI\ShowRecordingsDlg.cpp(15): error C2065: 'recordings' : undeclared identifier
c:\Documents and Settings\Administrator\Desktop\RecordingUI\ShowRecordingsDlg.cpp(15): error C2597: illegal reference to non-static member 'CShowRecordingsDlg::CRecording'
c:\Documents and Settings\Administrator\Desktop\RecordingUI\ShowRecordingsDlg.cpp(15): error C2065: 'pParent' : undeclared identifier
c:\Documents and Settings\Administrator\Desktop\RecordingUI\ShowRecordingsDlg.cpp(15): error C2275: 'CWnd' : illegal use of this type as an expression
c:\Documents and Settings\Administrator\Desktop\RecordingUI\ShowRecordingsDlg.cpp(16): error C2448: 'CShowRecordingsDlg::CShowRecordingsDlg' : function-style initializer appears to be a function definition
c:\Documents and Settings\Administrator\Desktop\RecordingUI\ShowRecordingsDlg.cpp(16): error C2143: syntax error : missing ';' before ':'
c:\Documents and Settings\Administrator\Desktop\RecordingUI\ShowRecordingsDlg.cpp(16): error C2143: syntax error : missing ')' before ','
c:\Documents and Settings\Administrator\Desktop\RecordingUI\ShowRecordingsDlg.cpp(16): error C2365: 'IDD' : redefinition; previous definition was a 'enumerator'
c:\Documents and Settings\Administrator\Desktop\RecordingUI\ShowRecordingsDlg.cpp(16): error C2244: 'IDD' : unable to match function definition to an existing declaration
c:\Documents and Settings\Administrator\Desktop\RecordingUI\ShowRecordingsDlg.cpp(16): error C2059: syntax error : ')'
c:\Documents and Settings\Administrator\Desktop\RecordingUI\ShowRecordingsDlg.cpp(17): error C2371: 'pParent' : redefinition; different basic types
c:\Documents and Settings\Administrator\Desktop\RecordingUI\ShowRecordingsDlg.cpp(17): error C2143: syntax error : missing ';' before '{'
c:\Documents and Settings\Administrator\Desktop\RecordingUI\ShowRecordingsDlg.cpp(17): error C2447: '{' : missing function header (old-style formal list?)
c:\Documents and Settings\Administrator\Desktop\RecordingUI\AddRecordingDlg.cpp(43): error C2065: 'm_nRecCount' : undeclared identifier

I forget to mention that you need to add includes in the .h file(s). Attached is the project that compiles cleanly. I didn't add anything to display the array -- just to pass the array.

I forget to mention that you need to add includes in the .h file(s). Attached is the project that compiles cleanly. I didn't add anything to display the array -- just to pass the array.

intresting , may I ask what I can change CEdit to. I've got a box that I want to update fields from rather than get details from the user.

You could still use CEdit -- make it read-only and set its value in the OnInitDialog() method (or someplate else). Alternatively you could use a CStatic control. They don't have scroll bars, so if the text is too big you won't be able to see part of it. A read-only CEdit is better for large amounts of text so that the user can use the scroll bars (set them in the property)

Ok, well I've tried to add the following changes:

showRecordingDlg.h;

public:
	[b]CStatic ShowArtist[/b];
	CEdit ShowTitle;
	CEdit ShowLenght;
	int m_nIndex;
	afx_msg void Forwardbtn();

and have tried to pass arguemnts to it:

in the .cpp file:

void CShowRecordingsDlg::Forwardbtn()
{
	[b]ShowArtist = m_recordings->m_sArtist;[/b]
	m_nIndex++;
}

but I still get this error:

c:\Documents and Settings\Administrator\Desktop\RecordingUI1\RecordingUI\ShowRecordingsDlg.cpp(43): error C2582: 'operator =' function is unavailable in 'CStatic'

it was my unstanding that you can do this with a Cstatic control?

Most controls are derived from CWnd class, and all of them have SetWindowText() method. Use the control's SetWindowText method to show text

ShowArtist.SetWindowText(m_recordings->m_sArtist);

Hello acient, thanks for your reply. I'm learning so much. However this works but it doesnt seem to get the data from the varibles.

I've added this code:

UpdateData(true); before everything else in the function. But it still prints out default values.

Hello acient, thanks for your reply. I'm learning so much. However this works but it doesnt seem to get the data from the varibles.

I've added this code:

UpdateData(true); before everything else in the function. But it still prints out default values.

how did you pass recordings? The whole array as I had in my example? or just the relevent array element?

CShowRecordingsDlg dlg(m_aRec);
or
	CShowRecordingsDlg dlg(&m_aRec[m_nRecCount]);

If you did the first example, then recordings-> will only point to the first array element. You will need to use the index of the element you want to display

ShowArtist.SetWindowText(m_recordings[index]m_sArtist);

Hello, I've used your way and changed the folowing code to read this:

void CShowRecordingsDlg::Forwardbtn()
{	
	if (m_nIndex < 99 )
	{
	//UpdateData(true);
	//MessageBox(m_recordings[m_nIndex].m_sArtist);
	m_nIndex++;
	ShowArtist.SetWindowText(m_recordings[m_nIndex].m_sArtist);
	ShowTitle.SetWindowText(m_recordings[m_nIndex].m_sTitle);
	}
	else
		MessageBox("Can't hold anymore records", "OverFlow", MB_OK);


}

it prints the title but not the artisit :S cant work out why

[edit] ok stupid me was overriding it with 2 functions :S thats most likely why and its now been fixed yippe.. time to sort out thos radar buttons.

Thanks for your help buddy, heres a pint from me ... ... ... ok they dont do an icon :P

Hello guys a new problem as pop'd up:

c:\Documents and Settings\Administrator\Desktop\RecordingUI1\RecordingUI\RecordingUIDlg.cpp(168): error C2664: 'CRecording::SetMedium' : cannot convert parameter 1 from 'int' to 'MediumType'

however MediumType is an enum:

enum MediumType { CD = 0, DAT, CASSETTE } ;

Any ideas?

I'm trying to pass an int to the function which should be correct :S

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.