|
I have resolved this problem by installing the latest SDK and adding some code. I'm not totally convinced that the updated SDK helped, but with the added code, the problem no longer exists. I added calls to SetGLLines() and SetPatternScale() to define the line stipple.
Gort...Klaatu, Barada Nikto!
|
|
|
|
|
Hello,
the thing is still Outlook Automation.
After I could create an new Item just as an subfolder in the Inbox I
need to store some messages in this "NewFolder".
Therfore I need a reference to this folder - but how can I get it ?
In the VB Documentation I can see a function calls
GetItemFromID(LPCTSTR EntryIDItem, const VARIANT& EntryIDStore)
The Problem by using this is the second value.
I don´t know what to do !
Is there anyone in this Forum who can give me a subtle hint in what I have to do.
I little bit code and some encouraging words would be wonderful !
The MSDN is full of VB and VBA Code; but there are only few examples for C++.
Thanks a lot,
John
|
|
|
|
|
So how comes this line VC6 actually works?
char szString[21];
cout << "Please enter a string : ";
cin.getline(szString, 25);
But if I change the 25 to 26, it crashes?
I would have thought anything beyond 21 would make it crash actually, but to my surprise you can actually increase it all the way to 25 without crashing anything.
Any ideas?
|
|
|
|
|
anonymous wrote:
So how comes this line VC6 actually works?
<br />
char szString[21];<br />
cout << "Please enter a string : ";<br />
cin.getline(szString, 25);
anonymous wrote:
I would have thought anything beyond 21 would make it crash actually, but to my surprise you can actually increase it all the way to 25 without crashing anything.
char szString[26];
<br />
Alton
|
|
|
|
|
I think you didn't get my question.
Eventhough my szString can only hold 21 characters tops, I can read in as many as 25 characters into it without crashing which I thought was a bit of surprise. I was under impression anything greater thant 22 would have crashed it,but it didn't..22,23,24 and even 25 worked just fine.
take care
|
|
|
|
|
You are being lucky, the buffer is being overrun touching other parts of the stack, though by mere coincidence the app is not crashing. Try this:
int before=0;
char szString[21];
int after=0;
cout << "Please enter a string : ";
cin.getline(szString, 25); Most likely you'll see the contents of either before or after are being changed after reading the string, which certainly can crash the program in more complex scenarios.
Do not expect crash in every situation crash might occur. Things can get worse and such a problem can go unnoticed until least expected.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Personally I'm not sure why you're purposely writing past an array, unless you're wanting to play Russian Roulette with your system. Nah, I don't think it'd be that bad, but still...
My guess is that the char array is usually made in the same block of memory every time you ran the program, assuming you didn't reboot or run any other app between your "testing" runs. This way you're writing past the end into the same chunks of memory and they were probably empty. The time you crashed it probably wrote too far and overwrote some other chunk that was slightly necessary to your system. Or I could be totally wrong, wouldn't be the first time. But also don't forget that getline has a third parameter for a delimination chararcter to look for. If you're allowing it to go 26 char 's long but only entering 19 into the istream it will see that '\n' and stop. Also, your 21 char array really should only hold a string 20 char 's long, you need the last element for '\0'.
The question "Do computers think?" is the same as "Can submarines swim?"
DragonFire Software
Jeryth
|
|
|
|
|
I am not sure this is the best place to put this thread so I apologize ahead of time if it should have been posted in the embedded section.
I have an application that I would like to port over to VC++. What is the easiest way to port the project and does anyone have any tips that I can use?
I have not used any specific methods or API that are found only in wince, but I would like to be able to have only one code base for ease of future development. Also it would be nice to be able to take advantage of the increase in screen real estate on the desktop that I didn't have on the ppc. Everything in the ppc applciation was coded using unicode also.
Thanks for the help,
-Eric
|
|
|
|
|
Hello,
the thing is still Outlook Automation.
After I could create an new Item just as an subfolder in the Inbox I
need to store some messages in this "NewFolder".
Therfore I need a reference to this folder - but how can I get it ?
In the VB Documentation I can see a function calls
GetItemFromID(LPCTSTR EntryIDItem, const VARIANT& EntryIDStore)
The Problem by using this is the second value.
I don´t know what to do !
Is there anyone in this Forum who can give me a subtle hint in what I have to do.
I little bit code and some encouraging words would be wonderful !
The MSDN is full of VB and VBA Code; but there are only few examples for C++.
Thanks a lot,
John
|
|
|
|
|
Hi guys
What I have to do to change the default file name in Save Dialog in an SDI app?
Best Regards
Doc
|
|
|
|
|
First override the OnFileSave (and OnFileSaveAs if you want to) menu handlers, then just set the name of the default file that you want into the following variable;-
m_strPathName = _T("Whatever");
m_StrPathName is used by the CDocument save functions to work out what file name is presented to the user. If the m_strPathName is empty then the name of the document is used as a basis for the file name. So alternatively you can just call
SetTitle(_T("Whatever"));
instead, although this will not necessarily put the extension you would like onto the document by default, if you have more than one anyway.
Hope this helps,
Mark
|
|
|
|
|
I have a cDialog class that I spawn with new MyClass in another class (MainClass), and I push_back this m_pMyClass pointer on a vector. Now from another location I wanted to delete and zero out the pointer and I tried:
delete myGlobalVector[i];
myGlobalVector[i]= 0;
This didnt seem to do it.
So then I did,
delete MainClass.m_pMyClass;
MainClass.m_pMyClass = 0;
and this worked.
I am puzzled. I thought the first approach would work too..............??
Thanks,
ns
|
|
|
|
|
How does the first solution not work?
Kuphryn
|
|
|
|
|
After I do the delete and NULLing I have a test:
if (!m_pMyCLass)m_button.EnableWindow(TRUE);
but my button doesnt get enabled if I delete it the first (vector) way. The debuuger tells me that indeed the pointer is not zero at this point!
Thanks for helping.
|
|
|
|
|
ns wrote:
if (!m_pMyCLass)m_button.EnableWindow(TRUE);
Please show your actual code.
What you did write here does not use your vector at all!
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
I push_back m_pDLGSettings onto the vector. Then I get rid of it as below . Then I test it:
void CImageDisplay::OnBsettings()
{
m_pDlgSettings = new CDlgSettings ;
if (m_pDlgSettings == NULL) return;
BOOL ret = m_pDlgSettings->Create(IDD_DLGSETTINGS, this);
m_pDlgSettings->ShowWindow(SW_SHOW);
pDlgSettingsVector.push_back(m_pDlgSettings);
m_bSettings.EnableWindow(FALSE);
}
In another place where I want all windows to destroy and zero out:
if( pDlgSettingsVector.size())
{
for (int i =0; i < pDlgSettingsVector.size(); i++)
{
pDlgSettingsVector[i]->DestroyWindow();
delete pDlgSettingsVector[i];
pDlgSettingsVector[i]=0;
}
pDlgSettingsVector.clear();
}
and in a function of the class that the index [i] refers to:
if (!m_pDlgSettings)
{
m_bSettings.EnableWindow(TRUE);
}
I didnt use the vector here because I dont have the location of the pointer in that vector at this point in code. Instead I access it directly, feeling assured that Ithough deleted it using an index, I can always use it by its name instead of its position in the vector. (m_pDLgSettings is a member). In the place I want to check it (last snippet) I am not using its vector position but its actual variable that I pushed onto the vector..........
Hope I am not hopelessly unclear....
Thanks,
ns
|
|
|
|
|
The item in the vector is actually a copy of the pointer. In other words, you have two pointers to the CDlgSettings object, m_pDlgSettings and pDlgSettingsVector[0].
While push_back() does pass the object by reference, it makes a copy of the object (in this case a CDlgSettings*) to place in the vector. Thus you are setting one pointer to the CDlgSettigns object to NULL, but the other one still points to the now deleted object.
Possible work around - make the vector contain pointers to pointers, thus the vector will contain a pointer to m_pDlgSettings.
Hope this helps,
Tim
|
|
|
|
|
Thanks!!!
Thats a subtle point I was unaware of. Appreciate the workaround suggestion. I am trying it out. Not quite sure what I'll be deleting if I delete the vector element. Its a pointer to a pointer so do I delete *(pDlgSettingsVector[i]) ? i.e. the contents of the pointer contained in the vector.
Thanks,
ns
|
|
|
|
|
No, No, No..
Don't do this. Do not store the pointer returned by new anywhere else except the vector.
All access to that object should be through the pointer stored in the vector. Your problem
here is that you have many copies of the pointers floating around. You need to redesign your
application so that this is not the case.
if the code is inside the class pointed to then it should not be possible to call it in any other
way except through the pointer stored in the vector, so you don't need to check it for NULL
This is how it should be done.
ANy other way and you have
Code that is very hard to maintain and very error prone.
Can you explain why and how you are possibly calling a function in a class the instantiation of
has just been deleted from memory.
|
|
|
|
|
Thanks.
To clarify, if I understand your ending question , I needed to see in some other function whether any windows of the sort I pushed onto the vector exist.
REgarding the prog structure, I later realized that I didnt need a global vector (dangerous anyways) since I was always able to get the object that had the window as a member, so I could iterate trough the parent windows and get t o the member windows (which I had been poushing back) through the pointers to the parents.
MAny thanks for the help!
ns
|
|
|
|
|
Hi,
I am using regex to lookup some data in a string. I do not have any prior experience using regular expression and would appreciate some help on the subject.
Here is my expression:
[^\.]\[(\s*\w+\s*)+\]
I am using it to match a string with square brackets where the first character is not a dot. So in the following string "[TableName].[FieldName]" I will only want to find "[TableName]". In "[Table1] INNER JOIN [Table2] ON [Table1].[Field1] = [Table2].[Field2]" I expect to find "[Table1]" and "[Table2]".
This seems to work in some cases, but miserably fails in others. For example, in the following string "[Table1], [Table2]", it only finds "[Table2]" since it expects to see some characted before the bracket.
Basically I want it to look at the first character before "[TableName]" only if there is one. I guess I need to make [^\.] optional but I was not able to find this option with regex syntax. Please help.
Thank you.
|
|
|
|
|
The part in square brackets can be matched with
\[\s*\w+\s*\]
To say "not following a dot" you need to use a look-behind assertion. With your expression, the non-dot character gets matched as part of the regex, which isn't what you're trying to get.
(?<!\.)\[\s*\w+\s*\]
This is perl 5 syntax, not sure what environment you're using.
--Mike--
Ericahist [updated Oct 26] | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber
|
|
|
|
|
Michael,
Thank you for you reply. I am using Perl5 syntax and I was using this tool to test the expression: http://jakarta.apache.org/oro/demo.html. I guess, they just did not implement it there, because I kept getting an error (Malformed Regular Expression: Sequence (?<...) not recognized. )
Do you know any other tool I can use to test the expression.
Thanks.
|
|
|
|
|
|
Im trying to allocate a string in C(non-MFC) of a specified length.
I get an error message:
illegal constant expression
when trying to create buffer.
void parse(const int size)
{
char buffer[size];
...
}
This seems very simple, but I have tried everything. How do I go about doing this?
Kevin Shaffer
kshaff03@msn.com
|
|
|
|