|
I am initializing the variable when I instantiate my class. The problem seems to be in the while loop. If I turn off optimization, or just have the default, for my release configuration it runs. When I optimize for "maximum speed" the program hangs. It must be how the compiler is dealing with the "empty" while loop.
Any ideas? Thanks.
|
|
|
|
|
masnu wrote: While in the debug configuration this works without a problem but when I change to release and run the program it hangs. Any ideas?
Refer this[^] article by Joseph M. Newcomer.
Prasad
MS MVP - VC++
|
|
|
|
|
Thanks Prasad (and Joseph). I found the answer in his article.
For those who are curious the problem came about in the declaration of tx_in_progress. It was declared as int tx_in_progress . When I wrote while (pCom->tx_in_progress) {;} and optimized for speed the compiler assumed nothing in the loop modified the variable so it never checked it again, creating an endless loop. The solution is to declare it as volatile int which tells the compiler not to make any assumptions about the variable. I'm pretty sure that is the cause of it. If anyone has something different please let me know.
Great article by Joseph. Thanks.
|
|
|
|
|
please ..source code for program in oop in c++
i can't write program in c++ in oop please i want to be expert in oop
LORAN
To Be Or Not To Be
(KARFER)
|
|
|
|
|
Do you know C++ ? see MFC/C++ [^] is helpfuls?
|
|
|
|
|
You should search the definition for the "class" word, once you've read that you'll understand what is the oop about...
Then making that code will be easy (at the beggining) of course you can make it as hard as you want, but for example, look for the CButton source code or any other control in the MFC, and then you'll understand.
Hope this helps.
|
|
|
|
|
how can i check the stack-overflow through my programme.
|
|
|
|
|
|
thank you,i am reading it now!
|
|
|
|
|
I hope it solved your problem.
|
|
|
|
|
//this is add to stack function
<br />
void push (int x)<br />
{<br />
if (top >size -1)
cout <<"Stack is full";<br />
else<br />
<br />
stack[top++]=x;
}<br />
<br />
int pop ()<br />
{<br />
if (top >0)<br />
return stack[top--];<br />
else<br />
cout <<"stack is empty";<br />
}<br />
O.K ...
Go Head ...
To Be Or Not To Be
(KARFER)
|
|
|
|
|
loran1986 wrote: please ..source code for program in oop in c++
#include <iostream>
int main()
{
std::cout << "I've a long way to go...\n";
}
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Try a google search for object oriented scribble. Read through that code and you'll be an expert in no time.
|
|
|
|
|
Rick York wrote: Try a google search for object oriented scribble. Read through that code and you'll be an expert in no time.
Some testimonials of satisfied users of your suggestion:
1. I went through the code for a couple of minutes and now I am very confident. I am currently re-writing Linux - Mr. XYZ
2. Scribble code is the best. I wrote a mail server, right after going through the code. - Mr. ABCD
3. I wrote an ERP package for our company in C++, immediately after having a look at scribble code. - Mr. GHIJ
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
I know I should be posting code snippet but my program is on a classified network. It is very difficult to transfer the code and I don't want to have to type everything needed here. So let's give it a try without the code snippet first.
When I open one of my dialog window, one of my radio-button is being handled right away after OnInitDialog{} completes. In OnInitDialog() I call SetCheck(FALSE) for that particular button. And then after OnInitDialog() completes, my handler for that button is called by the framework without any of my code sending a message. I have checked the parameter values of the OnCommand function and they are as follows:
1. wParam low word contains the control ID of my radio-button.
2. wParam high word contains 0.
3. lParam low word contains a 4 digit number. This number changes every time I open the window.
3. lParam high word contains a 3 digit number. This number changes every time I open the window.
The numbers in lParam do not relate whatsoever to the controls on my dialog.
Also there is no way the message is being sent from somewhere else in my code.
Where is this message coming from?
Anybody has an idea?
Thanks!
jpyp
|
|
|
|
|
In a WM_COMMAND notification, the LPARAM is the handle of the control sending the message.
If you create a new control everytime you open the window, then there's no guarantee the control's
HWND will be the same every time.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Sorry but maybe I was not clear enough.
I open this dialog window by clicking on a menu choice in my main window. When the dialog opens, OnInitDialog() completes then the handler of the radio-button, which is in the window just opened, is being called. I break in the handler and I move to the OnCommand function using the Context window of the debugger. Then I check the value of lParam and it changes everytime I close and reopen the dialog window using the menu choice of my main window.
If what you say is true regarding lParam containing the handle of the control sending the message, then the value in lParam should always be the same because I am always using the menu choice to open the dialog window.
Maybe I am missing something here!
Thanks!
jpyp
|
|
|
|
|
The radio button is a child of the dialog, right?
The handler you break in is a command message to the dialog, right?
If yes to both, then every time you create this new dialog window, a new radio button is created.
Its window handle (HWND) which is passed in the LParam of its command messages to its parent
(the dialog) can (probably will) be different for every new instance of the dialog.
You use the ID of the radio button to identify it in a WM_COMMAND message from the radio button,
not its HWND.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Got you! Thanks for the explanation.
Now considering my answer to DavidCrow, what do you think could cause this message to be generated?
As I previously said, I am not sending this message anywhere in my code. The call stack proves it and looks like this:
Message handler
... (a number of DLL and OS functions)
OnCommand
... (a number of DLL and OS functions)
Function where I call Create() to create the dialog (stopped at the Create() call).
Thanks!
jpyp
|
|
|
|
|
WM_COMMAND messages which come from a control are notifications from the control to the parent.
For a radio button, see Button Messages[^]
The section "Notification Messages from Buttons" lists the BN_xxx notifications that a
button sends to its parent in the form of a WM_COMMAND message.
You should be able to match the high WORD of the WPARAM in the command message to one of those
BN_xx codes. If not, maybe it's an undocumented message
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Thanks for your reply and info.
As I stated in my original post, the high word of wParam is 0. I still can't figure out where this message is coming from. This is driving me crazy.
If you can think of anything else, please let me know. If not thanks anyway for your help.
jpyp
|
|
|
|
|
jpyp wrote: As I stated in my original post, the high word of wParam is 0
I never claimed I could read
That's a BN_CLICKED notification.
It could be because the control received a WM_SETFOCUS message.
I can't recall if a BN_CLICKED gets sent when you send a BM_SETCHECK - if you comment out
that call, do you still get the notification?
I'm not sure why you're worried about it. There's lots of messages that most of us don't handle
or care about. It's much more of a problem when you expect a message and get none
I thought I posted this link, but in case I didn't: Button Messages[^]
This documents how messages are processed by and from a button control (this is documented for
pretty much all Windows controls).
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I do get the same problem if I comment out the SetCheck call. I'll investigate the WM_SETFOCUS idea. I don't that is it but you never know.
The reason I worry so much about it is that I have other controls on this dialog that are supposed to be disabled when the dialog opens. When the user click on the button that I have problem with, these controls are then enabled. My problem is that when I receive this "irritating" message when the dialog opens, these controls get enabled when they should not be yet because the user has not click on it yet.
Hope I'm making some sense.
Thanks!
jpyp
|
|
|
|
|
jpyp wrote: I'll investigate the WM_SETFOCUS idea. I don't that is it but you never know.
I just know what I read about how the default window proc for a button control handles the
WM_SETFOCUS message:
"Draws a focus rectangle on the button getting the focus. For radio buttons and automatic radio
buttons, the parent window is sent a BN_CLICKED notification message."
So, to back up, you are calling SetCheck(BST_UNCHECKED) for the radio button in question?
Is this an automatic radio button? If so, maybe calling SetCheck(BST_CHECKED) on the radio
button you DO want initially checked would be more appropriate.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
jpyp wrote: I have other controls on this dialog that are supposed to be disabled when the dialog opens.
Unless your resource(s) are frozen (that's a concept with my product), shouldn't you be disabling those at design time, and only enabling them when said button is clicked?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|