|
Nick Parker wrote:
I guess I must be having a case of the Mondays.
Thank goodness it's only a 24-hour bug!
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
|
We all seem to have one of those once in a while!
Ant.
|
|
|
|
|
If you could dump the link errors here may be it would bemore usefull to comment on.
I'll write a suicide note on a hundred dollar bill - Dire Straits
|
|
|
|
|
If Value is NULL trying to set nValue to 0
is _com_error correct
TRY
{
nValue = recordset2->Fields->GetItem("Value")->GetValue();
}
CATCH_ALL(_com_error, e)
{
nValue = 0;
}
END_CATCH_ALL
|
|
|
|
|
CATCH_ALL only takes one parameter.
If you want to do want you suggest change thus
try<br />
{<br />
nValue = recordset2->Fields->GetItem("Value")->GetValue();<br />
}<br />
catch(_com_error& e)<br />
{<br />
nValue = 0;<br />
}
Other than that it will definately set nValue to 0 when a com error is thrown while reading the "Value" field.
Ant.
|
|
|
|
|
How to build a DataBase of data types (int, char, struct, …)?
I would like to build an ACCESS DataBase, containing information about all the data types we use.
For example:
Suppose, we have the following C/C++ code;
typedef char ARRAY_8_BYTES[8];
struct Foo1
{
int a[20];
int b;
ARRAY_8_BYTES a6;
char a[8];
};
struct Foo2
{
Foo1 foo1;
Foo1 *pFoo1;
char c[12];
};
Ideally, I’d like to have an ACCESS DataBase, containing data about the Foo1, Foo2 structures. So, I would be able to build a program, which uses this data base and (for instance) generates automatically the C code structure definitions above.
The questions I ask myself are:
1) How to organize data which is hierarchical by nature using a relational
data base such as ACCESS?
2) Are they better solutions than using ACCESS to solve this kind of
problem?
3) Do you know about other databases or commercial softwares that permit to
do this?
4) Could you please give me either a precise answer or links which can help
me?
Many, many Thanks.
|
|
|
|
|
It sounds like you need to preface each of your struct/class types with a specially-formatted comment. Then you could write a parser that would scan .h and .cpp files looking for known types (e.g., int , bool , char ) and the aforementioned comments.
While not directly related, back in the mid 90s, I started using a product by Eric Artzt called AutoDuck. It was a utility he developed while working for Microsoft. It scanned source files for special comments and created .hlp files for developers to use.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
The problem is NOT how to parse the .cpp, .h in order to build the DataBase, but how to build the data base.
I've just given (as an example only) the possibility to read the data base and to generate .cpp and .h files (and not the opposite)
Thank you anyway
|
|
|
|
|
Michigan1854 wrote:
...but how to build the data base.
Ahh, I overlooked that minor detail.
I would create an empty database, with all relevant tables, from within Access. Then create a DSN (from the ODBC applet in Control Panel). Next, derive a class from CRecordset , which will ask you for the name of the DSN previously created. When you need to add a record to the database, simply use the AddNew() and Update() methods of this class.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I know how to access a data base, create by ACCESS from C++ (Using either ODBC, DAO or ADO).
What I do NOT know is how to organize data which is hierarchical by nature using a relational data base such as ACCESS?
If I had to deal with relational data, such as: (Table 1 related to Table 2)
Table 1: Client ID, Client Name, Client address
Table 2: Order number, Client ID
Client ID connects Table 1 to Table 2.
But how to organize in such tables recursive data.
struct FOO1
{
int a;
int b;
int c;
};
struct FOO2
{
struct FOO1 f1;
struct FOO3 f3;
....
};
|
|
|
|
|
Hello guys,
I need some suggestions on this.
I have two dialogs CDialog1 and CDialog2. CDialog1 has a ComboBox that contains a list of values. CDialog2 has a ListBox. The CDialog1 calls up CDialog2 using DoModal(). When the CDialog2 is up, its ListBox should be filled with the listed values in the ComboBox of the CDialog1 (of course, this would be done in the CDialog2's OnInitDialog()). Then in the CDialog2, the items in the ListBox can be changed and as soon as this dialog is closed (EndDialog()), the values in the ListBox will go back and replace the ones in the CDialog1's ComboBox.
As you can see, I need to either share these two members (likely via the use of DDX control) between the two dialogs or have the CDialog1's ComboBox fully accessible by the CDialog2.
I tried to create paired members (CComboBox or CListBox) in the other dialog for the original member, duplicate a copy and create functions to update the list on both sides whenever necessary. But the copying didn't work. I couldn't go, for example, in CDialog1 before calling DoModal,
CDialog2 dlg2;
dlg2.m_ComboBox = dlg1.m_ComboBox;
</code>
The other way I could think of is to use SendMessage() to retieve/update the ComboBox' values from CDialog2 to CDialog1. Or, I could simply make the ComboBox globally accessible through pointer for CDialog2.
Before I try anything, I'd really like to hear from anyone. What would be the best way (MS recommended way?)to go about it? Or could my first method be corrected?
Thanks alot
|
|
|
|
|
J.B.
I can only suggest the method that I have used in the past, so this may not ideally fit your requirements exactly.
J.B. wrote:
As you can see, I need to either share these two members (likely via the use of DDX control) between the two dialogs or have the CDialog1's ComboBox fully accessible by the CDialog2.
Directly accessing another objects UI control is for me a general no, no! This applies to worker threads as well as separate UI classes.
Share your information via a public member variable, declared in the dialog class being called. Since you are dealing with a number of distinct items, I would go for a container variable, such as an stl's vector class.
- Before calling DoModal(), fill the instantiated dialog class's vector collection with the list of items.
- In your OnInitDialog() overridden function, populate your now valid listbox/list control, with this member vector.
- On successful termination of your dialog (OnOk), modify the public vector variable, if any changes are needed.
- In your calling dialog function, use the returned vector of items to modify its control display.
This method has worked for me in the past, so you may find it useful in your solution.
I Dream of Absolute Zero
|
|
|
|
|
Thanks RChin!
I shall try that~
|
|
|
|
|
I'd use a public CStringArray object. It would save all the entries in the CDialog1 and you should write something like this for the CDialog2::OnInitDialog():
(Imagine that your CStringArray object has been called "my_array")
for (int i=0; i<my_array.GetCount(); i++)
{
my_list_object.Add(my_array[i]);
}
Bye !!
<hr><div style="width:100%; filter:Glow(color=003FB0, strength=5, strength=2);"><font color="#FFFFFF">Written by: Rafael Fernández López.</p>
Visit: <a href="http://www.maestroprogramador.com" target=_blank><font color="#FFFFFF">http://www.maestroprogramador.com</a></div>
|
|
|
|
|
Thanks Rafael, for the suggestion.
at the end I use std::vector as that way I'm able to not specify the size and that gives a bit more freedom to implement the number of elements restriction on ComboBox, if required.
|
|
|
|
|
Hi everybody,
We have a large scale C++ project compiled with Intel C++ 8.0 compiler.The project has excessive use of customized array class invloving pointers etc,pass by reference mechanism for function calls,floating point arithmetic, etc.The final output data is correct for debug version,but when we make the release version using Intel specific switches like O3,Qip etc the data is not matching.The difference is not visible in decimal values,but in last 1 or 2 bits of hexadecimal values of the variables.We checked even by disabling the optimizations for release version but still the results are not matching.We have come across situations like A = B + c - D * F all double values.B,C,D,F are correct but A is wrong.If we print B,C,D,F for debugging reasons suddenly A also gets corrected.Reasons??.We feel there may be similar situations elsewhere and instead of debugging if we get to know the reason behind this behavior of release version or any other probable cause of our failure we would be in a better position.
Thanx in advance
Chandra Prakash
|
|
|
|
|
Such errors are usually due to memory being overwritten. It is no easy task tracking down a problem though.
The following could be some of the causes:
1. Some data is being overwritten by another memory operation.
2. The double values are "spilling over".
3. If using printf() or similar function for debug output, it is possible the format specifiers are incorrect. Make sure the format specifiers are correct for the data type being printed.
4. Look for code using typecasts. Especially, code that tries to typecast and assign a value at the same time: (*(int*)&var) = 0;
Bikram
|
|
|
|
|
Hi
I've succesfully coded a Visual C++ .DLL that has some exported functions.
Now i'm having some problems using Centura strings and modifiying them.
I use the type 'LPSTR' as following:
In centura -> External declaration:
Function: GetFirmName
Parameters .. Receive string: LPSTR
In .DLL:
void GetFirmName(LPSTR pFrm)
{
strcpy(pFrm, "IMTESTINGAROUND");
}
Is this the right way to deal with strings in .DLL to Centura? I ask this in the VC++ forum because it is Visual C++ code but has to interact with a Centura program.
Greetings,
Jens
|
|
|
|
|
How to change the window title text font?
i want to change the font of the caption text in the window title?
were rgrtgrtvrtrt rtrtb brt tyuhjghj hbhbnh hnjm 1234567?
|
|
|
|
|
This article Custom captions[^] should be of help.
Roger Allen - Sonork 100.10016
Strong Sad: I am sad I am flying
Who is your favorite Strong?
|
|
|
|
|
This is the code:
showed = sessionsettings->showed_inpat;
sortcol = sessionsettings->sortcol_inpat;
m_combosort.SetCurSel(sortcol-2);
m_combocolumn.SetCurSel(sessionsettings->filtercol_inpat);
m_editcolumnvalue.SetWindowText(sessionsettings->filtervalue_inpat);
activeRow = sessionsettings->selectedrow_inpat;
concrete example:
sessionsettings->selectedrow_inpat has value 4 which is correct.
However, when m_editcolumnvalue.SetWindowText(sessionsettings->filtervalue_inpat); is performed, this value magically changes to a random integer.
can anyone explain this? I already thought about pointers, but how is this possible?
(sessionsettings->selectedrow_inpat = integer, sessionsettings->filtervalue_inpat = CString, CString is made empty in constructor and is empty at the time when it comes to this part.)
(yes I know a solution would be to switch the lines, but I just want to know why why why??)
tnx!
|
|
|
|
|
Hi there,
I use VC Studio .net 2003. I have a project using math.h, which compiles without problems as Release project, but when I switch to debug mode I get 368 compiler errors for math.h
starting at line 182
_CRTIMP double __cdecl tanh(double);
_CRTIMP double __cdecl sqrt(double);
#else
int __cdecl abs(int); -> C2059 syntax error
double __cdecl acos(double);
double __cdecl asin(double);
Anyone got an Idea where this errors come from ? I would guess it has to do with project settings but couldnt sort it out so far.
thanks
ch
|
|
|
|
|
Its probably not that line, but the line previous to it that has the problem. It only get exposed in debug due to the way the #ifdef gets evaluated.
Take a look at the file that is including math.h and see what is just before it. Also, try getting the preprocessor to give you a file you can examine to see what the C++ compiler is actually getting. My bet is that you have a missing ";" in one of the files including math.h
Roger Allen - Sonork 100.10016
Strong Sad: I am sad I am flying
Who is your favorite Strong?
|
|
|
|
|
Hi Roger,
I am afraid that is not the case, i checked the files including the math.h file and there is no ; missing. Anyway, how could this correlate with the problem solution by switching to the release mode ?
I am almost certain that it has to do with environment settings, since the project worked on my old machine, but after I set up my computer anew i can only run under release mode. It really pisses me off,
thanks anyway
ch
|
|
|
|