|
Mike the Red wrote: I may look into it when I've learned a bit more, but if I use other people's code/libraries, how will I learn for myself?
Quite correct - but at the same time, you can't implement EVERYTHING yourself (you're using a compiler you haven't written yourself, I presume ). It's most important to learn concepts, how they work, and when to apply them. Implementation? Not always so important.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hello
I am using DialogBox function to create a Modal dialog. But sometimes this dialog is behaving like a modeless dialog and let the USER click on other windows.
Is there a particular property i need to set to make sure that it behaves as a Modal itself?
Or is there any other function that i can use to create a modal dialog?
I am working on Win32 in Visual Studio 2003 environment.
Another issue is, i am using ShellExecute to open up a EXE from inside my Win32 app. Now when i have this exe open up and then open up my modal dailog, the modal dialog is always hidden behid the app i opened using ShellExecute.
Is there a way i can make sure that i can open up the modal dialog in front of the app i opened using ShellExecute?
Or do i have to close the app i opened using ShellExecute?
If i have to close that app, which function i have to use?
Do apps opened using ShellExecute run on a new process memory?
Thanks in advance.
|
|
|
|
|
A modal dialog is modal to its parent window, i.e., the parent window is disabled as long as the modal dialog is active. You will still be able to click on other windows on your desktop. What is the parent of the modal dialog?
And yes, all apps run in a new process memory irrespective of whether you opened it using ShellExecute or CreateProcess or by double clicking on the EXE from explorer.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
I've been reading a couple of articles here about using custom draw to get XP and Vista themed buttons containing a bitmap, such as
Vista themed Owner-Drawn and Full-Custom Push/Menu/Image Buttons[^]
But I would prefer my buttons to look like toolbar buttons - i.e. by default look flat and without an outline, look slightly curved and with an outline when the cursor is hovered over it, and look pushed-in with a drop shadow when clicked.
Is there a simple way to get a CButton to look like this (not on a toolbar)?
|
|
|
|
|
BigInt BigInt::add_bigint(BigInt add)
{
int carry = 0;
int temp;
bool carry2;
stack<int> answer;
vector<int> tempvector;
vector<int> add_int = add.get_bigint();
while(bigint_int.size() > add_int.size())
add_int.insert(add_int.begin(), 1, 0);
while(bigint_int.size() < add_int.size())
bigint_int.insert(bigint_int.begin(), 1, 0);
cout<<add_int.size()<<" "<<bigint_int.size()<<"\n";
for(int i = size(); i > 0 ;i--)
{
temp = add_int[i] + bigint_int[i];
if(temp >= 10)
{
temp -= 10;
carry2 = true;
}
else
carry2 = false;
answer.push(temp + carry);
if(carry2)
carry = 1;
else
carry = 0;
}
if(carry)
answer.push(carry);
while(!answer.empty())
{
tempvector.push_back(answer.top());
answer.pop();
}
BigInt ret(tempvector);
return ret;
}
|
|
|
|
|
This might be the problem:
for(int i = size(); i > 0 ;i--)
should be
for(int i = size() -1; i > -1 ;i--)
I believe this is the problem, hopefully...
|
|
|
|
|
Problem: "Debug Assert Error" in VC++.NET
1) I have a Clistctrl object placed in a dialog.
2) An mfc worker thread calls a display function to update the Clistctrl.
3) The display function uses methods such as Clistctrl::setitemtext etc to update the Clistctrl display.
The application works fine.
--------------
However ONLY when I close the application
1) i get a "debug assert error".
2) I've noticed that the mfc worker thread crashes.
--------------
This "debug assert error" happens (I believe) because:
1) When the application closes, the Clistctrl object is destroyed.
2) But the display function that is called by the worker thread continues
accessing the destroyed Clistctrl object by calling the Clistctrl::setitemtext function.
3) Thus the thread crashes leading to the debug assert error.
-------------
Question:
1) Am i correct in assuming the cause of the "debug assert error" ? If not, correct me please.
2) How do i fix the above problem ?
Any help will be greatly appreciated
|
|
|
|
|
It sounds like you're right, though I don't know all of the intricacies of your code. But assuming you're right, I suggest that when you tell the program to exit (via CAppDlg), I'd call that separate thread and tell it to stop working. I would not in this case send a message to it, but instead call a function directly. Once that function exits, your app can continue to shut down safely.
Try that, and see what happens.
|
|
|
|
|
Hi,
How do i set an event handler for when the user clicks on the close 'x' button of the application window?
Also, please note that I'm a novice in VC++.NET.
Any help will be greatly appreciated.
|
|
|
|
|
do a search on WM_CLOSE in bing or goolge or another search engine. that should help.
|
|
|
|
|
Hi,
I've tried to exit the thread on the "close" event. Unfortunately, the worker
thread seems to crash somewhere in between the following 2 instants.
a) when the user clicks on the close button 'x' of the
application window AND
b) when the "close" event handler is called.
Thus the "Debug Assert failure "problem persists.
Should i try the suggestion posted by Stuart Dootson ?
Any help will be greatly appreciated.
|
|
|
|
|
A) Is the CDialog::OnClose() method called before or after you try to shut down the thread? This could have been a quick hack to fix the problem, though not a solid solution.
B) Seriously, Stuart is right. Threads should post messages to the main application, and not to dialogs directly, that way pointers and objects that are not valid are thrown away easily by the operating system, and you don't have to worry about this sort of thing consistently. I would rework the code as suggested by Stuart. But it shouldn't be that difficult.
|
|
|
|
|
You don't want to manipulate UI from a worker thread. You can post windows messages safely enough, but calling control methods will, at best, send a message rather than posting it, which isn't a good idea, believe me.
Try posting an app-specific message to the UI threads queue using PostThreadMessage. Respond to that message in the UI by redrawing the UI.
Also, you probably want to tell the worker to stop before terminating and wait for it to do so.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hello,
I am trying to run my Win32 application in Release mode. The application breaks and it pops up a message box with title "Microsoft Visual C++ Debug Library" and the first line in message box is "Debug Error!"
Below that, there is some "Buffer overrun ........." message.
And it has 3 buttons, ABORT, RETRY, CANCEL.
Just confused why in Release mode it popos up a message box with Debug Error.
Is it a problem with Release Configuration setting?
Any help is welcome.
Thanks in advance!
|
|
|
|
|
No, it sounds more like a problem with your code - the "Buffer overrun" gives it away.
Although...why does it say "Microsoft Visual C++ Debug Library" - are you linking with a release variant of the run-time (in project properties, check C/C++->Code Generation->Runtime Library)?
Anyway - if you've got the correct runtime variant, turn on debug information (you can, even in a Release mode app) and run your app under the debugger. See where in your code the exception is raised.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Check to see if you're not initializing any pointers to 0. Debug mode will do this for you, but in release mode, a pointer may start off with a garbage value, and consequently, if you try to use it, any one of a number of weird things can happen.
|
|
|
|
|
Hello,
I am working on a Win32 application in C/C++ using Visual Studio 2003.
There is a feature to write application data to a CD. This feature works fine. The issue is with, when the User enters a CD to the drive the application should be able to auto detect that and prompt the User.
Is there a Windows function to do that?
Is there a function which will retrieve whether a CD has been inserted to the CD Drive?
Thanks in advance!
|
|
|
|
|
Handle the WM_DEVICECHANGE message. The event will be DBT_DEVICEARRIVAL .
"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
|
|
|
|
|
if I define a function like
int MakeBigger(int nVal1, int nVal2, int nMultiplier )
{
int nRetValue;
nRetValue = (nVal1+nVal2) * nMultiplier;
return (nRetValue);
}
is it necessary that the default parameter (nMultiplier) be the last parameter in the list?
For example, could the following be valid:
int MakeBigger(int nVal1, int nMultiplier, int nVal2)
{
}
or also
int MakeBigger(int nMultiplier, int nVal1, int nVal2)
{
}
ALSO
Is it valid to have more than one default parameter? AND what is the correct syntax:
int MyFn(int nDefaultParam)
OR
int MyFn(int nDefaultParam=2)
Thanks,
Johnny
|
|
|
|
|
Default parameters must be last in your function definitions.
You can have more than one default parameter:
int MyFn(int nParam1, bool bRequired = true, float fMultiplier = 2.26);
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Thanks!
I have seen two types of syntax regarding the definition of the default values:
void MyFn(int nDefault)
and
void MyFn(int nDefault=2)
Which is "proper"?
|
|
|
|
|
john john mackey wrote: Which is "proper"?
Only the latter since the former is just a comment.
"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
|
|
|
|
|
void MyFn(int nDefault=2) is necessary somewhere in the code. If you declare this function in a class, then put this code in the class. If you are declaring it before the function call and definition, you can declare it like this as well. Then, you can use void MyFn(int nDefault/*=2*/) when you define the function.
Otherwise, when you define the function, you must write void MyFn(int nDefault=2) as the function header.
|
|
|
|
|
The second one would be the prototype and the first one would be the actual function.
void MyFn(int nDefault=2);
void MyFn(int nDefault)
{ ... }
The only reason for applying the second one to the functions is so that it reflects the prototype (a.k.a. documents prototype parameter).
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Which is a bad practice. Since modification of default value would need to change two places in code...
|
|
|
|