|
ThinkingPrometheus wrote:
much more i'm asking why it doesn't work
Because it is not supposed to work. The statement char *p = "Hello" says that p is a pointer that points to a spot in memory that holds the string constant. Trying to change the contents of p[1] is illegal because is refers to a constant spot in memory. That spot in memory has no name.
The statement char p[] = "Hello" says that 6 bytes of memory is allocated for the string constant and that spot in memory is referred to as p .
In that link that I provided, read sections 6.2 and 6.4 very carefully. The difference is explained very well, and why they can't always be interchanged.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
WOW
got it
that was the problem
thx to both of you
|
|
|
|
|
I would like to know if I can override any function such as OnApply() or OnOk() for a class derived from CPropertySheet.
The idea is i want to save some default settings property sheet whenever the user clicks apply /ok in a property sheet.
laiju
|
|
|
|
|
laiju wrote:
I would like to know if I can override any function such as OnApply() or OnOk() for a class derived from CPropertySheet.
No, since neither method belongs to the CPropertySheet class. You can, however, override the virtual OnApply() and OnOK() methods that belong to the CPropertyPage class.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Yes you can. Well, not technically "override" but you can catch the button clicks. CPropertySheet is a CWnd derived class so it has all the normal functionality of CWnd. It does receive BN_CLICKED commands from the buttons on the sheet, so you can add message handlers for the Ok and Apply buttons in you CPropertySheet derived class. Just be sure to implement the default behaviour by calling Default() in your handler.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
I am using MDI architecture enable with Doc-View architecture.
Can anyone let me know if i can hide the first MDI child which comes by default.
I want to show that window later and not as soon as the application is started
laiju
|
|
|
|
|
in the OnNewDocument in your Doc class, return FALSE and that is it
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
Thanx for the response.
But if i set OnNewDocument to FALSE then i cant create new windows using file new option.isnt it?..Even if i set this to FALSE, at run time can i later set it TRUE sO that i can click New to launch MDI CHild windows later..
Thank you. .
|
|
|
|
|
Thanx for the response.
But if i set OnNewDocument to FALSE then further i cant create new windows using file new option.isn't it?..Even if i set this to FALSE, at run time can i later set this option as TRUE so that i can click New to launch MDI CHild windows later..
Thank you. .
laiju
|
|
|
|
|
In your app's InitInstance() function you will see the line
ParseCommandLine(cmdInfo) Immediately after that line you have to check the value of cmdInfo.m_nShellCommand . If it is CCommandLineInfo::FileNew then the ProcessShellCommand(cmdInfo); line will open a new document. What you have to do is change the value of m_nShellCommand to CCommandLineInfo::FileNothing .
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew)
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
if (!ProcessShellCommand(cmdInfo))
return FALSE;
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
What I understand from ur suggestion is that I need to check
if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNothing)
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNew
So if its FileNothing I have to set FileNew as shown above. Is this what u are saying.?
If so how can I access the application?s InitInstance method after the application is loaded ..Can I set these values in some other methods may be in MainFrame in click events or some thing like that.
laiju
|
|
|
|
|
Right now I have an deskband that supports MFC. I have a button on the band that I want to create a CPropertySheet type config dialog. I used classes derived from CPropetyPage and CPropertySheet that I already had working, but the I always get a debug assertion error when creating the pages, or when I call DoModal. I thought maybe it was my classes, but I get the same problem with using the standard MFC classes. The debug assertions come from these lines:
VERIFY(AfxDeferRegisterClass(AFX_WNDCOMMCTLS_REG));<br />
AfxDeferRegisterClass(AFX_WNDCOMMCTLSNEW_REG);
Those lines are present in the constructor for CPropertyPage, and DoModal in CPropertySheet. Any ideas? Thanks!
|
|
|
|
|
I dynamically load a Dll in my Doc,it can access the variables of Doc,but not the functions,and get two errors.
CfgCom.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CMainDoc::MSCommSet(void)" (?MSCommSet@CMainDoc@@QAE_NXZ)
..\..\Bin/Cfg_Com.dll : fatal error LNK1120: 1 unresolved externals
Thanks for any help!
|
|
|
|
|
I suspect you should link your program with "your.lib" (assuming you want to use your.dll). Normally, "your.lib" is created after building "your.dll" and contains references to exported functions.
|
|
|
|
|
???,I don't use mydll.lib.
I use "AfxLoadLibrary" to dynamically load mydll.dll,and use "GetProcAddress" to call the exported functions.it works.
now ,i want mydll.dll to call public functions of doc.like "CMainDoc::MSCommSet(void)"
in fact i export a CView from this dll.
|
|
|
|
|
How To Draw Outside Window Context
|
|
|
|
|
|
char *ptr = new char[10];
memcpy(ptr,"Balkrishna",10);
//strcpy(ptr,"Balkrishna");
ptr[10]='\0';
AfxMessageBox(ptr);
delete ptr; // why does this crashes, ANy soultion??
--------------------------------------------------------
on contrary
char *ptr = new char[10];
memcpy(ptr,"Balkrishna",10);
//strcpy(ptr,"Balkrishna");
//ptr[10]='\0'; if i comment it works, but with garbage, WHY
AfxMessageBox(ptr);
delete ptr; //WONT CRASH HERE
|
|
|
|
|
"Balkrishna" contains in fact 11 characters !!!
Don't forget the trailling '\0' that "closes" your C-Style string.
So, by doing strcpy() you make an overflow and write in a memory space that is not yours...
to prevent such crash, declare char ptr[11] (or more)...
cheers,
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Dear TOXCCT,
Balkrishna is 10 character, BTW even if i take 9 char and 10th is null, still it will crash.....
|
|
|
|
|
Balkrishna is 10 characters, but i said "Balkrishna", that equals to {'B', 'a', 'l', 'k', 'r', 'i', 's', 'h', 'n', 'a', '\0'} .
however, i don't know more, but maybe you could help me a bit more by copying the error message, and also the context if necessary...
oops, Mr DavidCrow's right, i didn't see
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Balkrishna Talele wrote:
ptr[10]='\0';
You don't have "permission" to access the 11th byte of this memory location.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
O o... Thanks,...a lot
cheers
Balkrishna
|
|
|
|
|
By the way,
incorrect deletion of pointer to an array,
use
delete[] ptr;
instead of
delete ptr;
|
|
|
|
|
You're seeing a failed assert, not a crash. The assert message will say something like "damage after normal block" which means you wrote past the end of the memory block you allocated (in this case, you allocated 10 bytes but wrote to 11).
--Mike--
Visual C++ MVP
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|