|
Hi,
I'm currently experiencing quite an odd problem.
I have this dialog (CDialog) which, among other things, contain a tree control and a property sheet. That is, I create the CPropertySheet dynamically by doing something like this:
<br />
m_interactionSheet.Construct("HEHE", this);<br />
<br />
m_actionPage.Construct(IDD_ACTIONS);<br />
m_eventPage.Construct(IDD_EVENTS);<br />
m_interactionSheet.AddPage(&m_actionPage);<br />
m_interactionSheet.AddPage(&m_eventPage);<br />
<br />
m_interactionSheet.Create(this, WS_CHILD | WS_VISIBLE);
The above code works without any problems. However, if I try to show another dialog after having called CPropertySheet's Create() function, the application locks up. It's like it goes into an infinite message loop or something :S
If I comment out the m_interactionSheet.Create() part I can create and display CDialogs again.. otherwise not.
EDIT: I have reproduced the behaviour in an ordinary SDI application. PLEASE have a look at it here:
http://www.blacksmith-studios.dk/PropertyTest.zip[^]
The problem is in the CInteraction::OnInitDialog() function. (BTW, this is just a test program so everything might be messy and all.. this problem is just killing me )
Any idea what might be causing this as I'm all blank
Thanks,
|
|
|
|
|
m_actionPage
m_eventPage
are these member variables of type CPropertyPage or a class derived from PropertyPage.
If so , i dont think construct is required, you can remove all three calls to constructs.
Then try. see if it works.
God is Real, unless declared Integer.
|
|
|
|
|
Hmm.. you're probably right about the Contruct() thing since both m_actionPage and m_eventPage are classes derived from CPropertyPage.
However, it didn't work. The application still locks up if I try to display another dialog.
I did observe something strange though. If I comment out the m_actionPage part and only go for the m_eventPage part, everything works :S
I did just discover, however, that if I put controls on the property page dialog template THEN it locks up again.
What the hell is going on here?
|
|
|
|
|
humm, things are going out of my hand now, did you enable the propertypage as popup window.
God is Real, unless declared Integer.
|
|
|
|
|
Yes, no difference there
Do you mind if I add you to my MSN contact list? Just so we can discuss this more directly (if you have the time and want to, of course )
Thanks for your time so far!
|
|
|
|
|
Halloko wrote:
Do you mind if I add you to my MSN contact list?
no not at all, go ahead. my msn id is prakashnadar@msn.com
God is Real, unless declared Integer.
|
|
|
|
|
|
I have the following declaration
CMap<CString*, CString*, CStringArrayEx*, CStringArrayEx*> *m_EnhancementArray;<br />
What I am trying to accomplish is create a Map so I can take a string and get in return an array of other strings. I liked CStringArray but needed a copy constructor so that is what CStringArrayEx is all about.
The problem is when I set a value to this map using the following
m_EnhancementArray->SetAt(&returnVal, &EnhancementArray);<br />
returnVal is of course the string I have made as my key and EnhancementArray is my CStringArrayEx of strings. This call seems to work fine. When I iterate through the map, from the function where I called SetAt, I can see the data. However once I leave the function where SetAt is called, the data becomes corrupted in the CMap. I tried this without using a pointer and I still get the same thing to happen. Does anyone know what might be causing my data to disappear?
Thanks!
|
|
|
|
|
could you give a piece of your code so that we can see where could have been your fault...
TOXCCT >>> GEII power
|
|
|
|
|
In a sense, you kinda got it. I cut out the gory details cause they didn't make a shread of difference but I will try to put in the details I think would.
MyClassCls.cpp
<br />
CString CMyClass::StoreEnhancements() <br />
{<br />
<dd> CString returnVal = _T("");<br />
<dd> CString Description = _T("");<br />
<dd> CString Enhancement = _T("");<br />
<dd> int Enhanced = 0;<br />
<dd> int NumEnchs = 0;<br />
<br />
<dd> CStringArrayEx EnhancementArray;<br />
<br />
<dd> SQL.Format("SELECT * FROM MYTABLE WHERE TableCode = 1);<br />
<dd> if(m_pRs.Open((const char *)SQL))<br />
<dd> {<br />
<dd><dd> m_pRs.GetFieldValue("Enhanced", Enhanced);<br />
<dd><dd> m_pRs.GetFieldValue("NumEnhs", NumEnhs);<br />
<dd><dd> m_pRs.GetFieldValue("Description", Description);<br />
<br />
<dd><dd> if(Enhanced)<br />
<dd><dd> {<br />
<dd><dd><dd> SQL.Format("SELECT * FROM ENHANCMENTS WHERE TableCode = 1);<br />
<dd><dd><dd> if(m_pRs.Open((const char *)SQL))<br />
<dd><dd><dd> {<br />
<dd><dd><dd><dd> m_pRs.GetFieldValue("Enhancement ", Enhancement );<br />
<dd><dd><dd><dd> EnhancementArray.Add(Enhancement );<br />
<dd><dd><dd> }<br />
<dd><dd> }<br />
<br />
<dd> }<br />
<br />
<dd> returnVal.Format("[Enhanced] %s", Description);<br />
<br />
<dd> m_EnhancementArray->SetAt(&returnVal, &EnhancementArray);<br />
<br />
<dd> return returnVal;<br />
<dd>
}<br />
<br />
CString CMyClass::GetEnhancement() <br />
{<br />
<dd> FullDescription = StoreEnhancements();<br />
<dd> POSITION p = m_EnhancementArray->GetStartPosition();<br />
<dd> CString *Keys;<br />
<dd> CStringArrayEx *Values = new CStringArrayEx();<br />
<dd> m_EnhancementArray->GetNextAssoc(p, Keys, Values);<br />
<br />
<dd>
<br />
<dd> return FullDescription;<br />
}<br />
<br />
CStringArrayEx& CStringArrayEx::operator =(const CStringArrayEx& pCopy)<br />
{<br />
<dd> for(int i=0; i<pCopy.GetSize(); i++)<br />
<dd><dd> Add(pCopy.GetAt(i));<br />
<br />
<dd> return *this;<br />
}<br />
<br />
MyClassCls.h
<br />
class CStringArrayEx : public CStringArray<br />
{<br />
public:<br />
<dd> CStringArrayEx(){}<br />
<dd> virtual ~CStringArrayEx(){}<br />
<dd> CStringArrayEx(const CStringArrayEx &pCopy)<br />
<dd> {<br />
<dd><dd> operator= (pCopy);<br />
<dd> }<br />
<br />
<dd> CStringArrayEx& operator =(const CStringArrayEx& pCopy);<br />
};<br />
<br />
class AFX_EXT_CLASS CMyClass: public CObList <br />
{<br />
public:<br />
<dd> CMyClass();<br />
<dd> CMyClass(CString DatabaseFile);<br />
<dd> virtual ~CMyClass();<br />
<br />
...
<br />
<dd> CMap<CString*, CString*, CStringArrayEx*, CStringArrayEx*> *m_EnhancementArray;<br />
<br />
};<br />
I hope this helps.
|
|
|
|
|
something to add. I can now see the data when I am outside the function. I can iterate through and actually get the first key and the value associated with it. however when I try Lookup, it fails. The only difference I can spot is that when I iterate I am using a CString *var; When I am using lookup it is a CString var, however if you notice I am sending the address pointer Lookup(&stringVar, ArrayVar).
Does this make any sense?
Thanks
|
|
|
|
|
Why are you using CString* as the KEY and the ARG_KEY parameters of the CMap template. Declare it as CMap<CString, LPCTSTR, CStringArrarEx*, CStringArrayEx*> *m_EnhancementArray in your class declaration.
In your StoreEnhancements function, change m_EnhancementArray->SetAt(&returnVal, &EnhancementArray) to m_EnhancementArray->SetAt(returnVal, &EnhancementArray) .
And, in your GetEnhancement function, change CString *Keys to CString Keys .
Gurmeet S. Kochar If you believe in God, it's because of the Devil
My CodeProject Articles: HTML Reader C++ Class Library, Numeric Edit Control
|
|
|
|
|
It looks like that did it. Thanks! I actually did try changing the CMap to CString but I did for both parameters. I never thought of using LRCTSTR however.
|
|
|
|
|
I have this project which I worked on a year ago. I copy it from one CD to my PC, I make some modifications to the dialogs in the resource editor and I try to compile it and this is what I get:
e:\program files\microsoft sdk\include\iphlpapi.h(183) : error C2065: 'PMIB_ICMP_EX' : undeclared identifier
e:\program files\microsoft sdk\include\iphlpapi.h(183) : error C2146: syntax error : missing ')' before identifier 'pStats'
e:\program files\microsoft sdk\include\iphlpapi.h(183) : warning C4229: anachronism used : modifiers on data are ignored
e:\program files\microsoft sdk\include\iphlpapi.h(185) : error C2059: syntax error : ')'
The begining of the header file where iphlpapi.h is looks like this:
#include <stdafx.h>
#include <iphlpapi.h>
#include <ctype.h>
#include "MacNSn.h"
Can someone tell me where this error is coming from and what steps should I take to fix it? This project used to compile and run just fine.
// Afterall, I realized that even my comment lines have bugs
If the sun were to blow up, it would take us 7-8 minutes to realize it.
|
|
|
|
|
may be iphlpapi.h utilizes types declared in some other header.
i suggest you to check APIs used by your app
and make sure that all necessary headers in right sequence are included.
|
|
|
|
|
|
hi everybody,
i wanted to test a functionnality of my own, and i nedded to open a file. as i was quite in a hurry, i decided to use fopen which is easy to use.
but i really don't know why, it doesn't want at all to open my file !
i tried this : FILE* src = fopen("source.txt", "r"); but it always returs NULL.
does anybody have an idea ?
thanks...
TOXCCT >>> GEII power
|
|
|
|
|
try giving the absolute path like "c:\\yourprojectdir\\source.txt"
God is Real, unless declared Integer.
|
|
|
|
|
will it appreciate white spaces and long names ?
(E:\Nicolas\Projets Visual C++\CPParser\Debug)
TOXCCT >>> GEII power
|
|
|
|
|
damn it, it works !!
hem, in fact, i'll need later to pass theses paths to main directly, and the user won't necessarily give the entire path...
what can i do ?
TOXCCT >>> GEII power
|
|
|
|
|
humm, well i dont know exactly, but i would not like to have relative paths, i prefer complete path... there are ways you can make the user give the complete path. like using the fileopen dialog to ask the user to select the file.
God is Real, unless declared Integer.
|
|
|
|
|
erf, yes of course, but i am writing a little console project...
no dialog so.
TOXCCT >>> GEII power
|
|
|
|
|
if the path is relative then current directory is cosidered as the working directory.
so if you just specify the file name like test.txt then test.txt should be in the same directory as the .exe file that you are invoking.
But invoking it from the visual c++ editor(i.e ! button) will not work as it sets the current working directory to something else (i dont know what, may be the project directory, one below debug)
God is Real, unless declared Integer.
|
|
|
|
|
that's what i was thinking too.
thanks for your answer guy.
i can now continue
TOXCCT >>> GEII power
|
|
|
|
|
One thing to remember is that the current directory is not the same as the program directory. This is a very common mistake made by programmers.
In your case, I don't think that will be an issue since it doesn't look like you are trying to open a file in the same directory as the program.
BTW, with VS7 (and maybe 6), the working directory is not the "debug" or "release" directory. It is the project directory.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|