|
Hi!.
Ok, this is the serialize method of the object that have problems when I read:
<br />
void CTabla::Serialize(CArchive& ar)<br />
{<br />
<br />
TRACE(_T("Serialize of CTabla\n"));<br />
<br />
CObject::Serialize(ar);<br />
if(ar.IsStoring())<br />
{<br />
ar<<cantidadCodigos<<idTabla; ->here I see the right values<br />
}<br />
else<br />
{<br />
ar>>cantidadCodigos>>idTabla; <- but here I get always 0<br />
}<br />
<br />
m_Codigos->Serialize(ar); <br />
<br />
}<br />
I have a object called CDecDatabase that have an array of objects CMarcas. CMarcas have three arrays: an array of CSistemas, (that also have arrays of other objects, but that work fine), an array of CTabla and an array of CCategorias.
I have write, up there, the Serialize method of CTabla, when I have problems at the time to load.
I have see the file generate with an hexe editor and I saw that the data has been write, but I can't still load it, I get always 0.
Thank you for your support.
|
|
|
|
|
The problem might be with the << and >> overloads for the classes your are serializing. If as you say the data is being written correctly, have a look at the code in your >> operator.
Its also worth considering just writing a Serialize function for each class then you can call it from the main objects serialize (rather than having to use >> and << e.g.
CClass1::Serialize(CArchive& ar)
{
member1.Serialize(ar); // Serialise class members that are objects
member2.Serialize(ar);
if(ar.IsStoring()) // Seialise non-objects
{
ar << m_longvariable;
}
else
{
ar >> m_longvariable;
}
{
|
|
|
|
|
Hi.
I don't have written overload operators << and >> I just use these operators from CArchive when a I must serialize a non object members, (long), and every array of objects that I have, (in the main object), it call the Serialize method of the Object that, in some cases, it have others array of objects plus non objects members, and in other cases just non object members.
Anonymous wrote:
Its also worth considering just writing a Serialize function for each class then you can call it from the main objects serialize (rather than having to use >> and << e.g.
I'm doing that.
Maybe, sometimes, at the moment of store, there is some kind of "detail" that make a little shift of data, so when I try to load the data, part of it might load it well, but the part that have been shifted doesn´t.
I have verify the order of serialization and I think that it's correct, always the same order.
That's my problem.
Thank you very much
|
|
|
|
|
Hi.
I don't have written overload operators << and >> I just use these operators from CArchive when a I must serialize a non object members, (long), and every array of objects that I have, (in the main object), it call the Serialize method of the Object that, in some cases, it have others array of objects plus non objects members, and in other cases just non object members.
Anonymous wrote:
Its also worth considering just writing a Serialize function for each class then you can call it from the main objects serialize (rather than having to use >> and << e.g.
I'm doing that.
Maybe, sometimes, at the moment of store, there is some kind of "detail" that make a little shift of data, so when I try to load the data, part of it might load it well, but the part that have been shifted doesn´t.
I have verify the order of serialization and I think that it's correct, always the same order.
That's my problem.
Thank you very much
|
|
|
|
|
Hi everyone!
I am working with a connection to a MS-SQL server in C++ and use ADO. But I can not make it work like I want to!
I want to use SQL-statment in my code, and there are 2 statment I need, INSERT and UPDATE. I have tried my code with an ACCESS database it worked perfect. When I changed to MS-SQL it stopped when I try to INSERT. Update is not tryed yet.
Hope someone can help me with this, or have some examples...;)
My source is:
::CoInitialize(NULL);
// Use ODBC
_ConnectionPtr ptrConn("ADODB.Connection");
// Make the connection
ptrConn->Open(L"Provider=MSDASQL.1;Data Source=data", L"user", L"password", adConnectUnspecified);
// Pointer to the database
_CommandPtr ptrCmd("ADODB.Command");
// Activate the connection
ptrCmd->ActiveConnection = ptrConn;
// Create a recordset
_RecordsetPtr ptrRs("ADODB.Recordset");
ptrRs->PutRefSource(ptrCmd);
// Create a SQL-statment (nnavn, snavn, gruppe and navn is CString)
sql = "INSERT INTO opc (datamaskin, server, gruppe, tagnavn) VALUES ('" + nnavn + "', '" + snavn + "', '" + gruppe + "', '" + navn + "')";
// Create a char[] of CString (Maybe I dont need this..)
strncpy (buf, sql, 200);
// Execute SQL
ptrRs->Open(buf, ptrConn.GetInterfacePtr(), adOpenForwardOnly, adLockReadOnly, adCmdText);
// Close the database
ptrConn->Close();
CoUninitialize();
Andreas
|
|
|
|
|
I am not exactly sure what your problem is. I do use ADO and MS-SQL server all the time without problems. Here is a link to a very good class that makes ADO a lot easier to use:
http://www.codeproject.com/database/caaadoclass1.asp[^]
Wait a minute, I think I have found the problem.
ptrConn->Open(L"Provider=MSDASQL.1;Data Source=data", L"user", L"password", adConnectUnspecified);
I beleive there are two problems with this line as you do not specify the server or the database you want to use.
Here is the connection string that I use to connect to one of my databases:
CString strConnect("Provider=sqloledb;Data Source=(local);Initial Catalog=MageeMammoSQL;User Id=XX; Password=XX;");
hr = connection->Open(
_bstr_t(strConnect),
_bstr_t(L""),
_bstr_t(L""),NULL);
In my case the server is (local) meaning the current pc. And the database on the server is MageeMammoSQL
John
|
|
|
|
|
If your program works in the JET engine (MS Access), but not in SQL Server, then that suggest a difference in the SQL statement between the two systems.
andysmurfen wrote:
sql = "INSERT INTO opc (datamaskin, server, gruppe, tagnavn) VALUES ('" + nnavn + "', '" + snavn + "', '" + gruppe + "', '" + navn + "')";
for example:
By default the string qualifier for SQL Server is ', not a ", as it is in Access.
try using this for your SQL Server connection and see if it works
I Dream of Absolute Zero
|
|
|
|
|
Hello,
how can i draw an image that would be transparent? which means will get the background of where it is drawn....
this is the code i use to draw the image:
HBITMAP hBmp = pDlgInf->GetBmp();
CPoint pnt(rc.left + SPACE_WIDTH / 5,rcText.top);
CSize size(IMAGE_DIMENTIONS,IMAGE_DIMENTIONS);
pDC->DrawState(pnt,size,hBmp,DST_BITMAP);
i see the image fine, but it is not transparent...the transparent color (0,128,128) is shown there...
can any1 help?
thanks in advanced
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
DrawState can draw transparent icons only. To draw a transparent bitmap, use the ::TransparentBlt function.
|
|
|
|
|
Thanks for the reply,
i tried to use TransparentBlt, and i saw the image as transparent, but i got an other problem , if i moved the dialog outside the screen boundaries and then drag it back in, the image was fundged....it didn't appear well.
can u help?
thanks again
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
Well... all I think is that you should redraw your bitmap properly, that is, first clear the background and then blitting an image. Use clipping information in PAINTSTRUCT for proper paiting. And try to use double buffering.
|
|
|
|
|
I need to make CDateTimeCtrl not editable, without arrows ?
<br />
m_Planer.m_Current_Date .ModifyStyle(0, DTS_SHORTDATEFORMAT);<br />
m_Planer.m_Current_Time .ModifyStyle(0, DTS_TIMEFORMAT);<br />
not works:
<br />
m_Planer.m_Current_Date .ModifyStyle(DTS_UPDOWN | DTS_APPCANPARSE ,0 );<br />
How to do subject?
thanks
|
|
|
|
|
Hey! You can subclass this control and listen for WM_KEYDOWN message
codes of arrows
VK_LEFT (25)
LEFT ARROW key
VK_UP (26)
UP ARROW key
VK_RIGHT (27)
RIGHT ARROW key
VK_DOWN (28)
DOWN ARROW key
<br />
switch (uiMsg)<br />
{<br />
case WM_KEYDOWN:<br />
{<br />
if(wParam>= VK_LEFT && wParam<=VK_RIGHT)<br />
return 0;<br />
}<br />
<br />
}<br />
try to read something on subclusing on msdn
and probably in this article you will find usefull info
Pain is a weakness living the body
|
|
|
|
|
i need help with my timeouts. i can get my program to read/write single bytes, but the problem is a function related with the hardware i'm using.
you send the command and the hardware will enter a loop sending you each 3ms 7 bytes.
i can't set the timeouts properly in order to receive all those bytes (the most important thing is that i don't loose any bytes!)...
can anybody please help me??
thank you in advance...
Я люблю русский языкь!
|
|
|
|
|
Hello all
I'm pretty new on C++ and I have a problem. The thing is that I want to write a CString to a CStdioFile and be able to read the string from the file. All I have done so far is a little testprogram, just to se if it worked. It did not! Problem: I get a lot of junk text in my file and when I read from the file. Here is the code, I would be very greatful if anyone could help me a bit.
CStdioFile file;
CString filnamn = "Temp.txt";
CFileException fileException;
char buf1[] = "Hej hej\n";
char buf2[] = "Jag heter henrik\n";
CString rad = "";
CString rad1 = "Hej hej";
CString rad2 = "Jag heter henrik";
if (!file.Open(filnamn, CFile::modeCreate | CFile::modeReadWrite, &fileException))
{
TRACE("Can't open file %s, error = %u\n",
filnamn, fileException.m_cause);
}
file.WriteString(rad1 + '\n');
file.WriteString(rad2 + '\n');
file.ReadString(rad);
printf(rad, "%s");
file.Close();
|
|
|
|
|
You need to move the file pointer (where in the file you're reading/writing).
Try file.SeekToBegin() before trying to read...
Steve S
|
|
|
|
|
And your printf is erronous
try a printf((LPCTSTR)rad);
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Stojan78 wrote:
file.WriteString(rad1 + '\n');
file.WriteString(rad2 + '\n');
file.ReadString(rad);
Your problems lies with the above statement.
Try this:
<br />
file.WriteString(rad1 + '\n');<br />
file.WriteString(rad2 + '\n');<br />
file.SeekToBegin();
file.ReadString(rad);<br />
I Dream of Absolute Zero
|
|
|
|
|
Thanks a lot all. It now works just fine...
|
|
|
|
|
i am using visual studio to make some histogram graphs and pie graphs of standered divation but the programme does not recognize the graphics.h header file. how should i make the graphs and please tell what should i do to this heard file (graphics)
graphics in c/c++
|
|
|
|
|
|
How can I change the Style of an CSlideCtrl subsequent? I need this, because some settings cannot be set on the dialog editor...!
|
|
|
|
|
Thank you for reading this.
Now I want to keep the height and position of vertical scrollbar's thumb all
the time,so I used this m_ctrlTree' is a TreeListView control)
----------------------------
const int nBar = SB_VERT;
SCROLLINFO si = {0};
si.cbSize = sizeof(si);
si.fMask = SIF_ALL;
m_ctrlTree.GetScrollInfo(nBar, &si);
si.nMax = si.nPage * 2;
si.nPos = (int)si.nPage/2;
m_ctrlTree.SetScrollInfo(nBar, &si, TRUE);
-----------------------------
I placed that block in the 'OnPrePaint' event of the tree control and it really works,but
problem is that when resizing the TreeListView window or expanding a
node, it scrolls madly,perhaps always scrolls to the last record,this is not what I
want.
Is the calculate method right?And where should I place the
SetScrollInfo(nBar, &si, TRUE)to control the Thumb?
Best reguards.
de BG2SC
|
|
|
|
|
Hi,
in an application that i'm developping, i need to know if there are some user activities at any given time, such as the mouse being moved or the keyboard being used.
Is there any other smarter way to know how, that there are no user activity on the system and how long he was not active. Such a behaviour is used by application for IM, when they set the "away" message !
Thanks in advance for any hints and best regards
Richard
|
|
|
|
|
Check OnIdle( LONG lCount ); for MFC
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|