|
Hey Mark,
very good hint to look in the call stack window. Good news is, I know now where the problem is, bad news is that I don't have a clue yet how to solve it.
I overwrote the function OnSize to adjust the size of the rich edit controls on my dialog.
void CPlainText::OnSize(UINT nType, int cx, int cy)
{
static BOOL bResize = FALSE;
CResizingDialog::OnSize(nType, cx, cy);
RECT rectDlg;
GetClientRect(&rectDlg);
if (bResize)
{
if (m_bSynchronize)
{
m_ctlPlainText.SetWindowPos(NULL, 10, 140, (rectDlg.right/2)-20, rectDlg.bottom-180, SWP_NOZORDER );
m_ctlPlainText2.SetWindowPos(NULL, (rectDlg.right/2), 140, (rectDlg.right/2)-10, rectDlg.bottom-180,SWP_NOZORDER | SWP_SHOWWINDOW);
}
else
{
m_ctlPlainText.SetWindowPos(NULL, 10, 140, rectDlg.right-20, rectDlg.bottom-180, SWP_NOZORDER | SWP_SHOWWINDOW);
}
}
bResize = TRUE;
}
I noticed that the OnSize function gets called before the dialog is completly created and causes an causes this ASSERT to fail so I tried to solve it with the little workaround with the BOOL bResize. I don't know how I could forget that. I didn't think about that the static variable is still initialised after the dialog has been closed... Do you know a more elegant solution?
Thanks for all your help so far!
|
|
|
|
|
I'd be a little concerned about relying on just one WM_SIZE message
before the child control variables become valid.
I personally just check if the controls are valid, something like:
if (::IsWindow(m_ctlPlainText) && ::IsWindow(m_ctlPlainText2))
{
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
This works perfect.
Thank you very much!!! *Thumbs up*
Armin
|
|
|
|
|
Hi all,
How to convert the Binary data into Image file(*.bmp) in MFC 9.0.
I have binary data which is conversion of image save in one file. I have read the file(binary data) and convert the binary data again in image
please kindly advice me..
modified on Tuesday, August 12, 2008 8:04 AM
|
|
|
|
|
in your problem maybe you are lack of snippet or the declaration that is in either the header or the main itself. Kindly check it
|
|
|
|
|
I have here the code:
#include <iostream>
#include <string>
#include <stack>
#include <cctype>
#include <cassert>
using namespace std;
#include <sstream>
string infixTOposfix(string);
int evaluarRPN(string);
int main ()
{
string infix,
posfixWspaces,
dummy;
double result;
char repeat;
do {
cout << "\nPlease enter the expression in INFIX: ";
getline(cin,infix);
posfixWspaces = infixTOposfix(infix);
cout << "This is the expression in POSTFIX: " << posfixWspaces << endl;
result = evaluarRPN(posfixWspaces);
cout << "The expression after the evaluation: " << result;
cout << "\nDo you want to repeat? Enter 'y' ";
cin >> repeat;
getline(cin,dummy);
} while ( repeat == 'y');
system("PAUSE");
return 0;
}
string infixTOposfix(string exp)
{
char token,
topToken;
stack<char> opStack;
string postfixExp;
const string BLANK = " ";
for (int i = 0; i < exp.length(); i++)
{
token = exp[i];
switch(token)
{
case ' ' : break;
case '(' : opStack.push(token);
break;
case ')' : for (;; )
{
assert (!opStack.empty());
topToken = opStack.top();
opStack.pop();
if (topToken == '(') break;
postfixExp.append(BLANK + topToken);
}
break;
case '+' : case '-' :
case '*' : case '/': case'%':
for (;; )
{
if (opStack.empty() ||
opStack.top() == '(' ||
(token == '*' || token == '/' || token == '%') &&
(opStack.top() == '+' || opStack.top() == '-'))
{
opStack.push(token);
break;
}
else
{
topToken = opStack.top();
opStack.pop();
postfixExp.append(BLANK + topToken);
}
}
break;
default :
postfixExp.append(BLANK + token);
for(;; )
{
if ( !isalnum(exp[i+1]) ) break;
i++;
token = exp[i];
postfixExp.append(1, token);
}
}
}
for (;; )
{
if (opStack.empty()) break;
topToken = opStack.top();
opStack.pop();
if (topToken != '(')
{
postfixExp.append(BLANK + topToken);
}
else
{
cout << " *** Error in infix expression ***\n";
break;
}
}
return postfixExp;
}
int evaluarRPN(string posfijo)
{
stack<int> numStack;
int x,
y,
toInt;
string number;
for (int i = 0; i < posfijo.length(); i++ )
{
if ( isdigit(posfijo[i]) )
{
number = posfijo[i];
stringstream ss( number );
ss >> toInt;
numStack.push( toInt );
}
else if (posfijo[i] != ' ' )
{
y = numStack.top();
numStack.pop();
x = numStack.top();
numStack.pop();
if (posfijo[i] == '+')
numStack.push( x+y );
else if (posfijo[i] == '-')
numStack.push( x-y );
else if (posfijo[i] == '*')
numStack.push( x*y );
else
numStack.push( x/y );
}
}
return numStack.top();
}
the question here is: why do i get this result...
when I put 5-5 instead of 0 the result is 1
when I put 11*5 instead of 55... the result is 5
when I put 100+100 the result is 0 instead of 200
when I put 100/100 the result is an error message box... </int></char></sstream></cassert></cctype></stack></string></iostream>
modified on Tuesday, August 12, 2008 8:13 AM
|
|
|
|
|
1) have you read the posting guidelines ? your code is too huge, and not even formatted.
2) your thread title is not really presenting what the question will be about.
3), have you stepped into the debugger and inspect the variables states, step by step ?
|
|
|
|
|
actually I'm just a new member here today. sorry for violating the rules and uhmmm... I've already solved a part of it but it only works for one digit number only do you have any tip that can also work in more than 1 digit, a decimal value and exponents?
|
|
|
|
|
Maito Gai wrote: actually I'm just a new member here today
your account says you've been a member since Tuesday, March 04, 2008...
Maito Gai wrote: sorry for violating the rules
it's not too late to read them[^] at least...
So please edit your message consequently.
|
|
|
|
|
what I mean is this is my first time to post a thread. All before this time is to read the tutorials here... like reading online books.
|
|
|
|
|
that doesn't forbid you to follow the advices I've already been given you twice now
|
|
|
|
|
|
you can read it now more better thanks to your tip for the design
|
|
|
|
|
nice try
unfortunately, the "Ignore HTML tags" checkbox forbids the <pre> and <code> tags to be shown.
uncheck it and replace the < with < instead.
|
|
|
|
|
|
But the for() loops still have smiley faces. Use the Preview button before posting.
"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
|
|
|
|
|
it's done no smiley faces anymore
|
|
|
|
|
Now what you need to do is figure out if the problem is with infixTOposfix() or evaluarRPN() . In other words, it makes no sense to post evaluarRPN() if infixTOposfix() is not working. Make sense?
"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
|
|
|
|
|
Maito Gai wrote: ...do you have any tip that can also work in more than 1 digit...
Use the debugger to step through your code. Don't just use cout to determine if your code is working.
Does infix contain the right value before calling infixTOposfix() ? Does token in infixTOposfix() have the right value with each iteraton of the for() loop?
"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
|
|
|
|
|
I don't know how to also reason out the error instead of a pop-up error message box.
|
|
|
|
|
Maito Gai wrote: I don't know how to...
Use F5 instead of Ctrl+F5. Be sure and set appropriate breakpoints.
"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
|
|
|
|
|
I've encounter this message:
'postfix validation.exe': Loaded 'C:\Documents and Settings\Aldrich Uy\My Documents\Visual Studio 2005\Projects\postfix validation\debug\postfix validation.exe', Binary was not built with debug information.
'postfix validation.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', No symbols loaded.
'postfix validation.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', No symbols loaded.
The program '[832] postfix validation.exe: Native' has exited with code -1073741811 (0xc000000d).
I couldn't believe that binary was not built with debug information
|
|
|
|
|
Maito Gai wrote: 'postfix validation.exe': Loaded 'C:\Documents and Settings\Aldrich Uy\My Documents\Visual Studio 2005\Projects\postfix validation\debug\postfix validation.exe', Binary was not built with debug information.
So why don't you just change the project setting to Debug (instead of Release)?
"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
|
|
|
|
|
either you don't read the answers you get, or you don't understand them, ... or you're a moron.
I've told you since the beginning of this thread to use your debugger[^].
now, 6 hours later, you come and say you have an error message that implicitely says that you didn't built in debug mode. Couldn't you just say it earlier ?
|
|
|
|
|
ahhh... the pop-up message says:
"No Debugging information
Debugging information for postfix validation.exe cannot be found or does not match. Binary was not built with debug information."
|
|
|
|