|
thanks you,
but this video does not show the crash case and how to fix it....... 
|
|
|
|
|
I trongly suspect that default icon code of MFC dialog based app is almost totally useless.
Only useful code are the 2 lines:
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
SetIcon(m_hIcon, FALSE);
After deleting message handle OnQueryDragIcon(), SetIcon(m_hIcon,TRUE); and code in OnPaint(), visual icon on dialog interface and file-manager keeps the same.
Do you think default code I deleted is usefull in some cases?
|
|
|
|
|
includeh10 wrote: Do you think default code I deleted is usefull in some cases?
This code is placed there merely to show you how to add your own icon to your program/dialog. If you are happy to accept the default system icon then you have resolved the issue for yourself.
|
|
|
|
|
Hi
When I released my left-mouse button, I always get following assertion errors in the following functions.
I found out that "m_hMenuShared" is not NULL. What kind problem will cause this?
void CMDIChildWnd::AssertValid() const
{
CFrameWnd::AssertValid();
ASSERT(m_hMenuShared == NULL || ::IsMenu(m_hMenuShared));
}
After I made following changes, the above errors show.
Changed From:
BOOL CSplitFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
return m_wndSplitter.Create( this,
2, 2,
CSize( 10, 10 ),
pContext );
}
To:
BOOL CSplitFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
return CMDIChildWnd::OnCreateClient(lpcs, pContext);
}
|
|
|
|
|
I think you are getting hopelessly lost. Your original problem[^] was that you changed your CScrollView derived class to a CView derived class, but the scroll bars did not disappear as you had expected. I am thinking that you missed something when you did the conversion and there is still a reference to CScrollView somewhere in your code. The change you just made here is so totally off base that you had better change it back before you totally destroy your whole project with all sorts of stab in the dark hacks.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
Hi
Thank you for your comments.
Actually, I don't need the split panes in my application. I think I should delete it.
I think I messed up something related with "menu".
Thanks
|
|
|
|
|
Hi, just a starter with c++. Just following along a search program but cant understand this statement
#
for(i=0;i
|
|
|
|
|
holyinferno wrote: for(i=0;i
I assume something got missed in copy/paste, as this statement will not compile.
if(adj[start][i] && !visited[i])
This statement is a compound boolean expression, which will be true if the item in the 'adj' array is true AND the item in the 'visited' array is false.
From your question I would suggest it a good idea to get a C or C++ primer (book or online) to get a basic understanding of statements, operators, arrays, etc before trying to follow a complete program.
holyinferno wrote: Sorry for being a noob.
We were all noobs once Keep at it, you are obviously making the effort to learn.
|
|
|
|
|
I am actually following this program here http://c4swimmers.net/portal/bfs[^]
The statement is at is in the program. What do you mean by true? Does it mean the item exists in the arrays ? I understand compound statements but I am confused as there is not statement like (if a=b or if a>b) involved here.
Thanks for your reply !
Mike 
|
|
|
|
|
holyinferno wrote: What do you mean by true?
Sorry for not elaborating my response. In C/C++ an element (simple, or array) is considered true if it has a non-zero value, and false if it is zero. So the statement
if (adj[root][i] && !visited[i])<br /> could be read as if the element at adj[root][i] has a non-zero value AND if the element at visited[i] has a zero value (the '!' means NOT so reverses the test).
[EDIT]edited for clarity, I hope![/EDIT]
|
|
|
|
|
Thanks mate, that cleared the confusions a little bit.
Mike.
|
|
|
|
|
holyinferno wrote: Does it mean the item exists in the arrays ?
Nope. It means: "the array element (an integer) is non-zero".
holyinferno wrote: (if a=b or if a>b)
Beware a=b is an assignment statement in C/C++ , the equality test operator is == .
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]
|
|
|
|
|
|
Your code snippet would be much easier to read like:
for (i = 0; i < N; i++)
{
if (adj[start][i] && ! visited[i])
{
q[++rear] = i;
visited[i] = 1;
}
}
holyinferno wrote: What is this if statement comparing ?
It is asking if the i th element of adj[start] is non-zero and if the i th element of visited is zero. If both of those conditions evaluate to true, the two statements within the curly brackets are executed.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hello everybody,
In the code below there's a minor mistake. I can't find it. The whole code works fine, but in fact doesn't give a right result. Number of combination
6 out of 10 equals 210, but the program shows only 209 of them. What should I do ?
Here's the complete code:
#include "IndexCombination.h"
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <map>
#include <sstream>
using namespace std;
using namespace stdcomb;
bool GetNextComb(std::vector<unsigned int> &vi);
struct Element
{
char name[6];
int numbers[30];
char chain[90];
};
const Element elements[] = {
{
"ia11",
{3,9,17,21,24,31,33,36,42,49,4,8,19,22,28,30,34,39,43,47,2,6,10,13,14,25,29,37,38,46},
"3,9,17,21,24,31,33,36,42,49,4,8,19,22,28,30,34,39,43,47,2,6,10,13,14,25,29,37,38,46"
}, {
"ia34",
{1,6,12,15,22,27,31,32,41,42,4,7,14,17,23,30,33,36,45,48,2,9,13,18,21,26,34,39,44,49},
"1,6,12,15,22,27,31,32,41,42,4,7,14,17,23,30,33,36,45,48,2,9,13,18,21,26,34,39,44,49"
}, {
"ia72",
{3,8,11,18,22,25,36,37,43,46,1,6,16,17,23,28,35,40,41,44,2,5,12,19,24,27,31,34,42,49},
"3,8,11,18,22,25,36,37,43,46,1,6,16,17,23,28,35,40,41,44,2,5,12,19,24,27,31,34,42,49"
}, {
"ia167",
{3,4,12,15,21,28,32,39,47,48,6,9,16,17,29,30,31,38,41,42,7,8,11,20,26,27,34,35,45,46},
"3,4,12,15,21,28,32,39,47,48,6,9,16,17,29,30,31,38,41,42,7,8,11,20,26,27,34,35,45,46"
}, {
"ia190",
{3,10,11,14,22,23,32,35,43,44,6,9,16,19,24,29,37,38,45,48,2,5,13,18,25,30,31,40,41,0},
"3,10,11,14,22,23,32,35,43,44,6,9,16,19,24,29,37,38,45,48,2,5,13,18,25,30,31,40,41,0"
}, {
"ia21",
{2,5,16,19,25,30,34,39,45,48,1,9,12,13,21,24,33,36,44,49,3,8,15,20,23,26,35,40,43,46},
"2,5,16,19,25,30,34,39,45,48,1,9,12,13,21,24,33,36,44,49,3,8,15,20,23,26,35,40,43,46"
}, {
"ia64",
{6,9,13,20,28,29,33,40,43,48,2,7,16,19,24,27,31,34,44,47,5,8,14,17,21,30,32,37,41,46},
"6,9,13,20,28,29,33,40,43,48,2,7,16,19,24,27,31,34,44,47,5,8,14,17,21,30,32,37,41,46"
}, {
"ia102",
{4,9,14,19,22,29,35,38,46,47,5,8,13,16,21,26,33,40,41,48,6,7,15,17,28,30,32,39,42,45},
"4,9,14,19,22,29,35,38,46,47,5,8,13,16,21,26,33,40,41,48,6,7,15,17,28,30,32,39,42,45"
}, {
"ia178",
{6,9,15,20,23,24,37,38,42,45,7,8,16,19,22,25,34,39,43,46,1,2,17,18,26,29,31,40,47,0},
"6,9,15,20,23,24,37,38,42,45,7,8,16,19,22,25,34,39,43,46,1,2,17,18,26,29,31,40,47,0"
}, {
"ia180",
{1,4,13,18,27,30,33,38,45,46,2,3,12,15,22,23,39,40,44,47,8,9,11,17,24,25,32,37,49,0},
"1,4,13,18,27,30,33,38,45,46,2,3,12,15,22,23,39,40,44,47,8,9,11,17,24,25,32,37,49,0"
}
};
int main(int argc, char *argv[])
{
CIdxComb cb;
cb.SetSizes(10,6);
vector<unsigned int> combination(6);
combination[0] = 0;
combination[1] = 1;
combination[2] = 2;
combination[3] = 3;
combination[4] = 4;
combination[5] = 5;
int Total = 0;
while(cb.GetNextComb(combination))
{
Total++;
cout << "Combination number. " << Total << endl;
for (unsigned i = 0; i < combination.size(); i++)
{
const Element &element = elements[combination[i]];
cout << element.name << ": " << element.chain << endl;
}
cout << endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}
|
|
|
|
|
Waldemar Ork wrote: GetNextComb
the function name is well chosen.
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Waldemar Ork wrote: The whole code works fine, but in fact doesn't give a right result.
In software (or anywhere else) that statement cannot be true.
Also your code is badly formatted, try using the <pre></pre> tags or the "code block" button to display it like this
while(cb.GetNextComb(combination))
{
}
In the extract you posted the function GetNextComb() is not shown, but does not appear to return a value; what do you expect from that call?
|
|
|
|
|
apparently GetNextComb modifies its parameter from one combination to the next (that is OK, it is passed by reference), and returns false when it reaches the end.
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Your remark about GetNextCombination function is precious. I think I should modify the header file. What I think of is to apply somehow the rule "one element past the last". This should help.
Anyway here's the header file with GetNextCombination function if you'd like to have a look at it :
#include "IndexCombination.h"
using namespace stdcomb;
void CIdxComb::Init( unsigned int SetSize, unsigned int CombSize )
{
// Assign CombSize
////////////////////////
if( CombSize == 0 )
CombSize = 1;
m_ArrSize = CombSize;
m_LastIdx = CombSize - 1;
// Assign SetSize
////////////////////////
if( SetSize == 0 )
SetSize = 2;
if( CombSize > SetSize )
CombSize = SetSize;
m_SetSize = SetSize;
m_LastSetIdx = SetSize - 1;
}
bool CIdxComb::SetSizes( unsigned int SetSize, unsigned int CombSize )
{
if( SetSize == 0 )
return false;
if( CombSize == 0 )
return false;
if( CombSize > SetSize )
return false;
m_ArrSize = CombSize;
m_LastIdx = CombSize - 1;
m_SetSize = SetSize;
m_LastSetIdx = SetSize - 1;
return true;
}
bool CIdxComb::GetNextComb( std::vector<unsigned int> &vi )
{
// Check if the last element is at the end
if( vi[m_LastIdx] == m_LastSetIdx )
{
if( m_ArrSize == 1 ) // Completed
return false;
// Check if the subsequent elements(counted from back)
// is also at their subsequent positions
//////////////////////////////////////////////////////
bool Completed = true;
// Incomplete Index, init value not used
unsigned int IncompIdx = m_LastIdx - 1;
bool FirstIdx = false;
unsigned int ArrIdx = m_LastIdx - 1;
unsigned int SetIdx = m_LastSetIdx - 1;
while( !FirstIdx )
{
if( vi[ArrIdx] != SetIdx )
{
Completed = false;
IncompIdx = vi[ArrIdx] + 1;
break;
}
if( SetIdx )
--SetIdx;
if( !ArrIdx )
FirstIdx = true;
else
--ArrIdx;
}
if( Completed )
return false;
else
{
for( unsigned int i=ArrIdx; i<=m_LastIdx; ++i, ++IncompIdx )
{
vi[i] = IncompIdx;
}
}
}
else if ( vi[m_LastIdx] < m_LastSetIdx )
{
(vi[m_LastIdx])++;
}
else // bigger than the m_LastIdx! Impossible!
{
return false;
}
return true;
}
|
|
|
|
|
Waldemar Ork wrote: one element past the last
I have no idea what that could mean.
I would assume GetNextComb() returns the next combination, so if there are N you can call it successfully N-1 times, I see no problem here.
I did not study your code as it is not formatted (why don't you use PRE tags?) and it also is a lot of code, much more than I would anticipate for what it is supposed to do.
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
As has been suggested before here, you need to trim this code down to just what is absolutely necessary to exhibit the problem.
If you are seeing 209 out of 210 combinations (i.e., one-off bug), check the while() and for() loops to ensure they are running the expected number of times.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Unfortunately, You all are wrong. The number of combinations has nothing to do with GetNextCombination or "for" loop. The loop "do...while" is needed instead. Here's the code:
do {
Total++;
cout << "Combination number. " << Total << endl;
for (unsigned i = 0; i < combination.size(); i++)
{
const Element &element = elements[combination[i]];
cout << element.name << ": " << element.chain << endl;
}
}
while(cb.GetNextComb(combination));
Thank you and,
Take care!
|
|
|
|
|
Hi,
I am looking for someone to help me with a problem I am having creating a Win32 Client and to help me along the way creating windows for the project which is driving me crazy.
If anyone has spare time that could help me quickly that would be great.
Thanks
Andrew
Andrew McIntyre
|
|
|
|
|
A Win32 client for what ?
Can't you simply create a "new" project with a Wizard ? either a dialog based application or a SDI/MDI application ?
This signature was proudly tested on animals.
|
|
|
|
|
For my project.
No, I have created a "new" project and went through the wizard already. But I am stuck a quarter through the code.
Andrew McIntyre
|
|
|
|
|