|
Well it is a fairly good starting point for a newbie. Why are you stuck now?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
the oso wrote: The only thing the program needs to accomplish is allow the user to enter 20 multiple choice answers A,B,C, or D and compare the user entered answers to a correct set of answers...
Isn't that what it's currently doing?
the oso wrote: ...calculate a percentage of correct answers entered.
cout << correct / NUM_QUESTIONS;
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
int count;
int correct;
char correct_answers[count] = {B, D, A, A, C, A, B, A, C, D, B, C, D, A, D, C, C, B, D, A}
This can only cause problems. correct_answers[count] should probably be correct_answers[NUM_QUESTIONS] since count is not initialized.
|
|
|
|
|
Hi,
I'm working in MFC using VS 2003.net in UNMANAGED code - MFC (not .NET).
I've a class. It has two constructors.
typedef enum calibDataType_e
{
CDT_UNKNOWN_E = 0,
CDT_REGISTER_E,
CDT_END_E
} calibDataType_t;
class CCalibEntry : public CDialog
{
public:
CString csLabel;
CString csValue;
float fValue;
enum { IDD = IDD_VALUEENTRY };
public:
CCalibEntry(CString csLabel, CWnd* pParent = NULL);
CCalibEntry(CString csLabel, calibDataType_t pt = CDT_UNKNOWN_E, CWnd* pParent = NULL);
protected:
bool IsValidEntry();
bool ValidateRegisterEntry();
virtual BOOL OnInitDialog();
virtual void OnOK();
afx_msg void OnDestroy( );
DECLARE_MESSAGE_MAP()
private:
int dataType;
};
CCalibEntry::CCalibEntry (CString csLabel, CWnd *pParent) : CDialog (IDD, pParent), dataType(CDT_UNKNOWN_E)
{
this->csLabel = csLabel;
}
CCalibEntry::CCalibEntry (CString csLabel, calibDataType_t dt, CWnd *pParent) : CDialog (IDD, pParent)
{
this->csLabel = csLabel;
dataType = dt;
if( dataType == CDT_REGISTER_E )
{
csValue = _T("0.0.0");
}
}
When this code is called via:
CCalibEntry dlg ( message, CDT_REGISTER_E, this );
It enters BOTH constructors. (Whereas, as I understand it, it should only enter:
"CCalibEntry::CCalibEntry (CString csLabel, calibDataType_t dt, CWnd *pParent) : CDialog (IDD, pParent)"
Oddly enough, it also enters OnInitDialog *after* the user presses the 'OK' key.
W...T...H?
1) Isn't just the constructor with the matching signature the *ONLY* constructor to be entered?
I've cleaned by project and rebuild from scratch, pulled from source control & rebuilt again, deleted NCB files.
2) Also, setting breakpoints in the second contructor code at, say, the top line ("this->csLabel = csLabel;") results in the breakpoint being *moved* to the line with the comment ("//provide a hint to the user") -- as if the comment line is going to execute some code. Thoughts?
Signed,
Frustrated!
|
|
|
|
|
Are all compiler optimizations turned off? Those
constructors are similar enough where the compiler may have
rearranged the code.
Like2Byte wrote: Oddly enough, it also enters OnInitDialog *after* the user presses the 'OK' key.
Not sure what class' OnInitDialog() you're referring to or where/how
this dialog gets created...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
OnInitDialog() is derived from the Base class CDialog. It's used to do any special initialization required to display the form. For instance, if you have a dropdown(DD) controlling two groups of radio buttons. Item0 in the DD displays the left hand radio buttons hides the right hand; while, item1 in the DD displays the RHS and hides the LHS.
http://msdn.microsoft.com/en-us/library/fwz35s59(VS.80).aspx
It's supposed to perform these operations BEFORE the form is displayed - in my instance, the code there is being executed AFTER I press OnOK().
It's gotta be some stale OBJ code in the project I'm working on that's causing it to refer to the wrong address locations.
Anyone else have a similar experience?
|
|
|
|
|
Right, I know how the method works. My point was, I couldn't tell
from the code you posted which dialog class you were referring to,
or how and where you are creating the dialog.
The system sends the WM_INITDIALOG message before the dialog is displayed
so it shouldn't be related to your code.
Do you have corrupt or outdated debug info hanging around somewhere? Have you cleaned
the project's intermediate and output files by hand before a full rebuild?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
OK, sorry. Misunderstood you there.
Do you have corrupt or outdated debug info hanging around somewhere?
That's been my theory all along. It's strange because I cleared all objs by hand yesterday.
I was just able to get it to clean up. There's something majorly wrong with the project I'm working in.
I actually tried all those methods:
Deleted OBJs by hand, performed "Clean Solution", Compile each project singularly via the solution explorer, 'Re-build', etc.
What I finally did was go directly to the offending file, select it and click 'Compile.' Then I right clicked on the project the file is a part of and did a "Build". Then I did a "Build Solution", debug 'Start' and performed the operations. Problem solved.
There's definitely a problem with the project settings if all files are not kept up to date WRT edit times vs compile times.
|
|
|
|
|
Cool thanks for the update!
I know I've had a similar problem in the past - I think I
gave up and re-created the project from scratch. It hasn't
happened since VS 2003 for me thankfully
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Please help me how to store an image into Ms Access with Visual C++ 2005.
ANd how to retrieve the image from database (Ms Access)?
thank in advance
|
|
|
|
|
Have you searched this forum for "access blob"?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
thx DavidCrow, following ur sugestion i searched "access blob", but all is in VC++6.0, that would be error in Visual C 2005 when i complide
|
|
|
|
|
hafini wrote: ...but all is in VC++6.0, that would be error in Visual C 2005 when i complide
That's just a result of the VS2005 compiler being more C++ compliant.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Sorry, i am stupid . I dont understand clearly what u said, could u explaint for me more detail?
In fact, some methods of VC++ 6 used in this case that is not correct way to be used in Visual C 5.
If u have ever do it with VC 2005, u have the solution in hand, could you told me?
|
|
|
|
|
Do you have an example of something that works with VS6 but does not work with VS2005?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Here is two example:
the first eg:
CFileDialog m_ldFile(TRUE, ".bmp", m_sBitmap, OFN_HIDEREADONLY+OFN_OVERWRITEPROMPT,szFilter);
if i use VC6 compile it is okei, but with VC5 it is a trouble.
the second:
from source code posted on the following link
http://www.codeproject.com/KB/database/usingblob.aspx[^]
once again, i used VC6 compile it can run, while vc5 it showed two errors.
|
|
|
|
|
Thx David, i followed ur suggestion but all is in VC++6.0 that would be error when i used Visual C 2005 to complide.
|
|
|
|
|
I have a project that will need to call the GdiplusStartup / GdiplusShutdown pair about twice a second. Has anyone had experience doing this?
|
|
|
|
|
FossilDocent wrote: I have a project that will need to call the GdiplusStartup / GdiplusShutdown pair about twice a second.
Why? They only have to be called once per process.
Twice a second isn't much overhead but it's way more overhead
than necessary
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
The code I am working with is part of a larger code base. The rest of the code is not using GDI+.
|
|
|
|
|
If performance is not an issue then making the calls every time
you use GDI+ is a valid solution.
What about adding init and cleanup functions that make the calls?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Performance is indeed an issue. I was hoping someone could tell me how much of a performance hit the code might take. Otherwise I will try to do some timing.
I guess I am being boneheaded. Could you elaborate on the init and cleanup functions you are referring to?
|
|
|
|
|
FossilDocent wrote: Could you elaborate on the init and cleanup functions you are referring to?
I mean add some functions (or methods to a class if appropriate)...
void InitGDIPlus()
{
GdiplusStartup(...
}
void CleanupGDIPlus()
{
GdiplusShutdown(...
}
These don't need to be called on the same thread. Just call
InitGDIPlus() once before using GDI+, and call CleanupGDIPlus()
once when finished with GDI+.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Once I call GdiplusStartup for my class, and before I call GdiplusShutdown, will other classes still be able to use non-GDI+ CDC drawing methods? If GdiplusStartup does not disable use of drawing such as
CDC *pDC;
pDC->LPtoDP(...);
pDC->MoveTo(...);
pDC->LineTo(...);
I can do just as you suggest.
|
|
|
|
|
Regular GDI is not affected in any way
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|