|
Can you show your code that it has problem
|
|
|
|
|
Hello,
i found my fault. I simply give the child-dialog a reference to the parent dialog (constructor) and then i can call methods of the parent without getting an access violation.
thanks anyway.
|
|
|
|
|
All I can think of off hand is:
1) Make sure both places refer to the SAME variable. For example, I occasionally make the mistake
of copy/pasting a member variable declaration with its type into code somewhere so it ends up
being a local variable where I copied it, instead of referring to the member variable
2) It's possible to overwrite an array (string, etc.) member that is positioned before the bool
member variable. There's no exception because it's still in valid memory but it trashes the bool.
I've done that one before too .
It may be helpful to put a variable-changed breakpoint on the bool variable. Then your program
will break when the bool is changed and you can look at the stack trace to see who the culprit is.
Mark
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
Hello Mark,
I'm sure that the variable is the same, so I'll check the second scenario, who knows...
Thank you for your feedback!
|
|
|
|
|
Sort of newbie question here. I've read in places that you should avoid returning large class objects (particulary the class String) or datastructures, and instead should call a function and send it back by reference. Like this (ExpressionData is a structure with 3 cstrings):
void CRatiosNewSearchStringDialog::GetExpressionData(SearchExpressionType & Expression)
{
Expression = ExpressionData;
}
as opposed to:
SearchExpressionType CRatiosNewSearchStringDialog::GetExpressionData()
{
return ExpressionData;
}
Where should I draw the line between a large and small piece of data i.e should I bother with all this for a single CString? When should I use return and when should I sent it back by reference? Advice?
|
|
|
|
|
I'm porting some code from gcc to VC++, and a macro I've used for years on gcc is giving me grief on VC++ (Visual Studio 2003).
#define swap16(x) \
({ \
unsigned __int16 __x = (x); \
((unsigned __int16)( \
(unsigned __int16)(((unsigned __int16)(__x) & (unsigned __int16)0x00ff) << 8) | \
(unsigned __int16)(((unsigned __int16)(__x) & (unsigned __int16)0xff00) >> 8) )); \
})
int _tmain(int argc, _TCHAR* argv[])
{
printf("%d\n", swap16(1);
return 0;
}
This code snippet generates several syntax errors. Any suggestions on resolving this issue are most welcome.
-Josh
|
|
|
|
|
joswr1ght wrote: Any suggestions on resolving this issue are most welcome.
Haven't used it for years but there used to be a compiler switch that produced files containing the expanded code.
led mike
|
|
|
|
|
led mike wrote: Haven't used it for years but there used to be a compiler switch that produced files containing the expanded code.
Are you referring to the /P option? It writes the preprocessor output to a .i file.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: Are you referring to the /P option? It writes the preprocessor output to a .i file.
If it works I am, if not you are.
led mike
|
|
|
|
|
Hmmm....why not just do this...
#define swap16(x) \
((unsigned __int16)( \
(unsigned __int16)(((unsigned __int16)(x) & (unsigned __int16)0x00ff) << 8) | \
(unsigned __int16)(((unsigned __int16)(x) & (unsigned __int16)0xff00) >> 8) ))
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
I have a straightforward CPropertySheet with CPropertyPages. I need to reset the contents of page "A", depending on the settings on other pages, which means I need a way to catch when pages "open" and "close"
I can catch when a page "opens" by overriding OnChildActivate but I can't catch when a Page "closes". Any suggestions on a sane way to trap these events?
(Note, I know about OnInitDialog() for "open" or OnOk() for "close". Neither of these methods are guaranteed to be called when just bouncing back and forth between pages by clicking on tabs)
Thanks in advance.
|
|
|
|
|
On the pages themselves, you can override OnSetActive and OnKillActive and do whatever you need to do to the parent PropertySheet or other Property pages.
onwards and upwards...
|
|
|
|
|
hello,
I am building an application in VC 6wherein when the user clicks ona particular button, a query is fired to SQL SErver 2000 database and a report (crystal reports 8.5) is generated based on the data retrieved. I am having multiple clients which connect to the SQL server remotely. so while retrieving, i will need to specify the IP of the machine where the DB is stored.
I have heard of a function callled SetLogonInfo which allows a user to change the databse name on the fly. But when I add an Active X control to my app, the version of SetLogonInfo takes only 2 parameters...."void SetLogonInfo(short index, LPCTSTR lpszNewValue); ...instead of 4 which i have seen in most standard implementations. Could you please give me more details regarding this function and how do I connect remotely for crystal reports? What is the code that i need to include in this function?
Awating Your Reply
Thank You
|
|
|
|
|
|
I would like to use an initialization file to set some features of how my Visual C++ API will run. I would like to be able to set these from within the API to be used next time the application is started. Is there a "simple" solution?
|
|
|
|
|
You can use INI files, but I prefer by far using XML files, they are easy to use and also you can use the DTD files in order to check the correctness of everything.
You can also use the registry, but is far more complicated and then it is also more complicated to move the program from one PC to another one.
In order to use them you should check the articles here in CP, I'm sure that you can find lots of information on that.
Hope this helps.
|
|
|
|
|
Thank you, this did confirm my thoughts that an ini file could be used. Now I just need to know how to code for useing either the INI or the XML.
|
|
|
|
|
SimplCodr wrote: Now I just need to know how to code for useing either the INI or the XML.
if (ini_file_is_present)
use_ini_file();
else if (xml_file_is_present)
use_xml_file();
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Well that is exactly what I asked for isn't it. Thanks for the chuckle. Remember, I am an idiot and simpl is all I can do at this point. Lets see... How do I use an INI file or an XML file to set variables at program start? I'm still laughing...
|
|
|
|
|
SimplCodr wrote: How do I use an INI file...to set variables at program start?
WritePrivateProfileString() et al
For XML files, check out TinyXml.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thank you. It looks like a good starting point for me.
|
|
|
|
|
Check out the appsettings class from p.j. naughter at www.naughter.com[^] Might be really close to what you want. Save and load ini, registry and xml.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
|
|
|
|
|
Thanks for the suggestion. I am going to stick with the built in windows stuff that david mentions. A good resource I was not aware of.
|
|
|
|
|
Exactly!;P
LateNightsInNewry
|
|
|
|
|
Joan Murt wrote: You can also use the registry, but is far more complicated...
In terms of what? I consider the registry very easy to use and navigate through.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|