|
Do not use CloseAllDocuments. This is why:
CDocTemplate::CloseAllDocuments
virtual void CloseAllDocuments( BOOL bEndSession );
Parameters
bEndSession
Specifies whether or not the session is being ended. It is TRUE if the session is being ended; otherwise FALSE.
Remarks
Call this member function to close all open documents. This member function is typically used as part of the File Exit command. The default implementation of this function calls the CDocument::DeleteContents member function to delete the document's data and then closes the frame windows for all the views attached to the document.
Override this function if you want to require the user to perform special cleanup processing before the document is closed. For example, if the document represents a record in a database, you may want to override this function to close the database.
|
|
|
|
|
Welp it would apear I have found the problem. I adjusted the code to look like this:
CNewDSNDlg pDlg;
pDlg.DoModal();
pMyTemplate->CloseAllDocuments(FALSE);
This seamed to cure the problem. It was the dialog being opened within the funtion after the document closure. Having the dialog come up before the document closure has cured the problem. I have to admit I am not sure why and if anyone happens to know I wouldn't mind learning the reason.
Thx,
Richard
|
|
|
|
|
Wouldn't it be easier to just stop the OnFileNew procedure being called?
OnUPdateFileNew(CCmdUI *pCmdUI)
{
POSITION pos ;
pos = pDocTemplate->GetFirstDocPosition() ;
pCmdUI->Enable(pos == NULL) ;
}
Of course you need the CDocTemplate pointer for this to work.
Roger Allen
Sonork 100.10016
If I'm not breathing, I'm either dead or holding my breath.
A fool jabbers, while a wise man listens. But is he so wise to listen to the fool?
|
|
|
|
|
I'm trying to open recorset using command object, and retreve data from Access database.
m_pRds->Open(_variant_t((IDispatch *) m_pCmd, true), Parameter2, adOpenStatic ,adLockOptimistic, adCmdStoredProc);
what should I specify as Parameter2, cause when I put current connection there I'm getting error "Cannot change the ActiveConnection propery of a Recorset object which has a Command object as its source."
|
|
|
|
|
I cann't remember what exactly it was but O know you can pass it as _bstr_t(L"") .
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
why i posted (read) was because i already posted a thread just like this, and i wanted to renew it in a way. all the other responses were great, and i looked up allot of new things that helped allot. Now, the only part that i cannot seem to get to work is the rand().
If there is an artical or webpage that explains random numbers, please give me the address, or link. Thanks.
But if there is not, or you simply dont know, or dont care about giving it, or like to respond to questions. my question is... "Like the old one"
I want to generate a number in a random form. 1-10. with the number, i wanted to use if statments such as:
if (rand() == 1);
somthing
if (rand() == 2);
somthing
And so on. I dont know if that is how you declare an if statment with a rand(), just bean toying with for a long while, and that seems most correct at the moment.
on the other thread i got the response of
rand()%11 was for 1-10. But i dont think that is the end of it, what else am i suppose to add to this, or is it the end?
If that is the case, then, how do you declare a rand() to = to 0?
Thanks all.
~SilverShalkin
ps... as you can see, im at the point of hair ripping. sorry if some of this is hard to understand or unorganized. "simply tired"
"for life is to precious to spend in the dark wonders of a dream,
but without it, life simply becomes a dream." "some can relate "
|
|
|
|
|
I want to generate a number in a random form. 1-10. with the number...
That's how you do this:
#include "stdafx.h"
#include <afx.h>
#include <stdlib.h>
void main()
{
srand(0);
while (1)
{
int rnd = rand() % 10 + 1;
if (rnd < 1 || rnd > 10)
{
printf("Out of range [1-10], rnd = %d\n", rnd);
return;
}
else
{
printf("generated rnd = %d\n", rnd);
Sleep(500);
}
}
}
|
|
|
|
|
lets see,... could you do...
Serge Krynine wrote:
#include "stdafx.h" "could this be stdlib.h?"
#include
#include
void main()
{
srand(0);
while (1) "what does this do?"
{
int rnd = rand() % 10 + 1; "Do you have to do 10 + 1, or can you do 11?"
if (rnd < 1 || rnd > 10)
{
printf("Out of range [1-10], rnd = %d\n", rnd);
return;
}
else
{
printf("generated rnd = %d\n", rnd);
Sleep(500);
}
}
}
I got most of that, thanks, Ill try it out and see what happends.
~SilverShalkin
|
|
|
|
|
SilverShalkin wrote:
#include "stdafx.h" "could this be stdlib.h?"
Actually stdafx.h is the VC++ precompiled header file
SilverShalkin wrote:
while (1) "what does this do?"
that's for an endless loop
Nish
[Signature temporarily down]
|
|
|
|
|
a) Stdafx was generated by devstudio when I build a windows console app project, but yes stdio.h should do.
b) while (1) {} means “loop forever”; The idea of the test that if a random number would be out of [1-10], the test would exit; otherwise it will run forever (what I guarantee) (until you terminate it by ctrl+c or power off your PC).
c) the expression int rnd = rand() % 10; gives you random integers in the range [0-9] (from zero to nine inclusive). If you want the [1-10] range, add 1 then: int rnd = rand() % 10 + 1; Note that expression: int rnd = rand() % 11 does not give you correct range [1-10] because it can generate zero when the rand() function returns 11, so 11 % 11 gives you null.
Enjoy,
Serge
|
|
|
|
|
The two #include statements with nothing besides them are the clue - the original poster forgot to tick 'no HTML' and so the includes in < > were lost.
I think no-one has bothered to explain the % operator - it means the remainder and can be used anywhere. So rand() generates a number between 0 and rand_max(). The remainer operator says 'what's the remainder if I divide by this', so if the number divides evenly by 10 in my example, I get a 0, and a value of 10 is not possible, because the highest number that can remain if I divide by 10 is 9, as in 29/10 = 2, 9 remainder.
The point of the endless loop I think is that if you ran it, you would never see 'out of range' come up, no matter how long you waited....
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
Thats cool, while (1) is a forever loop, i just wrote:
int x=1;
do
{
}
while (x == 1)
but i gues we all can see what one is faster.
Christian Graus wrote:
rand() generates a number between 0 and rand_max().
rand_max, how do you set how big it is? 0-rand_max right?
Well, thanks a bunch, I'm on the tip of the breakthrough, "Even though its not much of a break through "
~SilverSahlkin
Tragedy is Romeo and Julyet, not a syntax error on your if statement!
|
|
|
|
|
Yes, yours is doing the same thing in a more convoluted manner.
SilverShalkin wrote:
rand_max, how do you set how big it is? 0-rand_max right?
You don't set RAND_MAX, the system does. Changing the value of the #define might break other code, but it won't change the range of rand(). That is why you need to divide by RAND_MAX and multiply by a maximum, or use the % operator.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
1.I create a atl dll project, then i insert a composite atl object in my project.
2.I insert a tree control into the dialog which are belong to the composite object.
3.it seems to be ok when a test it in the vb entironment, but ,when I build the vb proect the exe directly, it meeting an Assert error in atlctl.h at line 842.
Could somebody tell me that's why?
Thank's a lot
i am realfly
|
|
|
|
|
Did you call InitCommonControlsEx to initialize the tree control?
|
|
|
|
|
That's it!
Thank you!
i ma realfly
|
|
|
|
|
Hi All,
I'm making an MFC Extension DLL and when I try and use it in my project it wont update the members I have created to the Auto popup/complete feature of Visual C++. It has all the members for the Derived class (CObject) and the destructor for the new class, but none the new member variables/functions?
Would I need to change some setting to make it work? And where, the DLL project or the Application. Is this even possible??
When I manually type the function anyway it works, but I like this feature as it often highlights if I've made a simple error somewhere, plus I'm lazy and like to do less typing!
Thanks
-Mark
|
|
|
|
|
The autocomplete feature of VS is a bit hit and miss. I've found if I include the DLL in the same workspace as the project it is a little more reliable.
If you want to do less typing and have a little cash to spare - have a look at the Visual Assist addon for VC. There should be an ad floating around CodeProject somewhere (I can't remember the URL). It's certainly worth the investment.
Michael
|
|
|
|
|
I'm trying to find out why the program doesn't sleep for 2 seconds after the first cout.
#include <iostream.h>
#include <windows.h>
main()
{
cout << "blah\n";
Sleep(2000);
cout << "blah\n";
return 0;
}
|
|
|
|
|
Try this:
main()
{
cout << "blah\n" << endl;
Sleep(2000);
cout << "blah\n";
return 0;
}
|
|
|
|
|
Thanks, endl worked. I can't believe it was as simple as that and I couldn't figure it out. I didn't know that endl was different than \n.
|
|
|
|
|
endl also does a flush.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
Well, im not used to the sleep command, but i am used to a command like it.
you can use the clock_t command. It requires the header time.h
#include iostream
#include time.h
using namespace std;
clock_t wait // declares wait as clock_t, like declaring an int.
void main()
{
wait = clock() + 2000;
cout << "Blah\n";
if (wait <= clock() )
{
Cout << "Blah";
}
}
Hope that helps. And it may not be all completly true, but im 99% sure it will work.
Good Luck
~SilverShalkin
Stay at the hights of the language for it will grow ever more, with non stop.
|
|
|
|
|
|
I was wondering, how can I parse html with let's say C?
I want to parse a form so that I can read in the variables of the Name, Email and Message of my guestbook and then POST them.
|
|
|
|