|
How are you serializing document members? Using m_foo.Serialize(ar) or ar << m_pFoo?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Everything is done using ar << m_pFoo (no objects other than CString are serilaized - most of what is saved is structures, and I do the members of each by hand).
You sound as if you're hinting that each object (class) has its own schema... which I can understand... but should there not be an overall schema for the document / doc-derived object? It does, after all, have IMPLEMENT_SERIAL()...
Basically, I'm not interested in the individual schemas of each thing I serialize - all serializing is done from one class (the doc-derived) (since there are no child objects being serialized, not even CXXXArrays). I want one overall schema that is used in all serializing operations so that I can check it on loading to avoid loading new data from old-schema files...
|
|
|
|
|
Everything is done using ar << m_pFoo (no objects other than CString are serilaized - most of what is saved is structures, and I do the members of each by hand).
You sound as if you're hinting that each object (class) has its own schema... which I can understand... but should there not be an overall schema for the document / doc-derived object? It does, after all, have IMPLEMENT_SERIAL()...
Basically, I'm not interested in the individual schemas of each thing I serialize - all serializing is done from one class (the doc-derived) (since there are no child objects being serialized, not even CXXXArrays). I want one overall schema that is used in all serializing operations so that I can check it on loading to avoid loading new data from old-schema files...
|
|
|
|
|
Schema number is written to file only if you use CArchive::WriteObject (operator << for CObject pointers calls this method). WriteObject uses CArchive::WriteClass for sort of 'metadata' (class name, schema version).
Default serialization implemented in CDocument::OnSaveDocument uses plain Serialize. This means that you can't call GetObjectSchema to get document schema number in CYourDoc::Serialize - it's not in the file.
You've mentioned that you're creating CArchive yourself - if you're replacing OnSaveDocument you can also try to replace CYourDoc::Serialize() with ar << pDoc.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
An excellent suggestion - I will try that trick tomorrow and let you know. Thanks for the help.
|
|
|
|
|
I've got a problem with the post SP4 NT4+ API "CreateIpForwardEntry". I'm trying to add a routing rule in the piece of code hereunder. It works just fine. However, if i use the IP address assigned to my ethernetcard as het "next hop" (thereby making it the default gateway for the particular network segment) it fails me. Can anyone help me out?
<br />
PMIB_IPFORWARDROW pRow = NULL;<br />
ULONG dwSize = 0;<br />
DWORD dwStatus = 0;<br />
<br />
pRow = (PMIB_IPFORWARDROW)malloc(sizeof(MIB_IPFORWARDROW));<br />
<br />
if (!pRow) {<br />
MessageBox("Malloc failed, Out of Memory!\r\n");<br />
exit(1);<br />
}<br />
<br />
pRow->dwForwardDest = inet_addr("172.0.0.0");<br />
pRow->dwForwardNextHop = inet_addr("172.31.64.9");
pRow->dwForwardMask = inet_addr("255.0.0.0");<br />
pRow->dwForwardIfIndex = 2;<br />
pRow->dwForwardType = 4;<br />
pRow->dwForwardProto = MIB_IPPROTO_NETMGMT;<br />
pRow->dwForwardAge = 0;<br />
pRow->dwForwardMetric1 = 30; <br />
<br />
dwStatus = CreateIpForwardEntry(pRow);<br />
<br />
if (dwStatus == NO_ERROR)<br />
MessageBox("Route Added Successfully\n");<br />
else if (dwStatus == ERROR_INVALID_PARAMETER)<br />
MessageBox("Invalid Parameter\n");<br />
else <br />
DisplayErrorMessage(dwStatus);<br />
<br />
if (pRow)<br />
free(pRow); <br />
|
|
|
|
|
Hi,
I am trying to implement an edit host (IHTMLEditHost).
I looked at the ATL example, and tried to implement the IServiceProvider interface in the CHtmlView class. But this doesn't work.
The interface function QueryService is not called after activating the editor (spDoc->put_designmode(L"On").
Does anyone have any idea how to do this?
Thanks,
Jurgen Wolke
|
|
|
|
|
I'm using a CAsyncSocket object to communicate with a unix socket server. The performance of the client data reception is too low. It takes about 400 miliseconds between the net ACK and the data catches the OnReceive() callback function. There's no traffic in the net. How can I improve this performance ? In a windows socket server, the problem doesn't occur.
Thanks !
Visual C++ 6.0, Windows98/NT.
sato
|
|
|
|
|
I'm using a CAsyncSocket object to communicate with a unix socket server. The performance of the client data reception is too low. It takes about 400 miliseconds between the net ACK and the data catches the OnReceive() callback function. There's no traffic in the net. How can I improve this performance ? In a windows socket server, the problem doesn't occurs.
Thanks !
Visual C++ 6.0, Windows98/NT.
sato
|
|
|
|
|
I need my application to be like "Quick Launch" so I could dock it to any screen border or nest in a tray. The GUI consists of a toolbar with a few buttons.
Any ideas?
Thanks!
|
|
|
|
|
There are two ways of approaching this:
The more common way is provide your application with an icon in the system notification area. When the user clicks on the icon, you can pop-up a menu or a toolbar with the choices you would like the user to have.
The potentially "more correct" way would be to make a deskband for your product. This is actually an extension provided by Internet Explorer and the Active Desktop. If you are running Windows 2000 or ME, or an older version of Windows with the Active Desktop installed, you will notice that you not only have a taskbar, but you can have toolbars, and address bar, and several other bars displayed. Each of these is a deskband which provides some interactive functionality.
The major difference between the two methods is that creating a deskband requires some COM programming. If you are familiar with COM, this should not be an issue. However, there are still many programs out there, such as the ones installed by many video card manufacturers, that add an icon to the system notification area with a pop-up menu.
I hope this helps!
--
Paul
"I drank... WHAT?"
|
|
|
|
|
Hi
I need to binary combine two files from C++ code.
I need to add binary file1 and file2 into file3, which is possible by the following command line:
copy /b a:\test1.txt + a:\test2.txt a:\test3.txt
How can I add those file in C++ code or perform a call to the command line which will perform the copy itself?
thanks,
lina
|
|
|
|
|
there are dozens of fun ways to do this.
the first, like you say, is to just issue a command line command to do it. see the "spawn" function.
the second, C, way to do it is like this:
(off the top of my head, so you'll have to fix any bugs by yourself)
FILE *fp1 = fopen("a:\\test1.txt", "rb");
FILE *fp2 = fopen("a:\\test2.txt", "rb");
FILE *fp3 = fopen("a:\\test3.txt", "wb");
while (!feof(fp1))
{
BYTE c;
c = fgetc(fp1);
fputc(fp3, c);
}
while (!feof(fp2))
{
BYTE c;
c = fgetc(fp2);
fputc(fp3, c);
}
fclose(fp1);
fclose(fp2);
fclose(fp3);
of course this is horribly inefficient. you'd be much better reading and writing large chunks (4K chunks, for example) instead of single bytes (see fread and fwrite).
then there are the C++ ways to do it, with CFile, or the io stream stuff.
all of it is 100% fun.
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
In CMainFrame I want to access m_Grid that I have declared global in a CFormView derived class called CTableView. In CTableView I have the declaration:
CMSFlexGrid m_Grid;
But when I for example call m_Grid.GetRows() in CMainFrame I get an error:
'm_Grid' : undeclared identifier..........
What am I doing wrong?, it is another way to access m_Grid from CTableView without making it global?
OyS
|
|
|
|
|
1) First, you have to have a pointer to the view that contains the m_Grid variable. To get one, enumerate through the document templates, and then through the opened documents in each template, and then through the opened views of each document until you get a pointer to the desired view.
2) If the m_Grid variable is not declared public (and it shouldn't be), you either need to make it public, or (better choice) make a public function in your view class that returns the number of rows in the grid.
|
|
|
|
|
Thanks for your interest. Could you please give me an code example of how I get the pointer to the view. That would be very helpful.
OyS
|
|
|
|
|
Have you checked the articles on this web site yet?
|
|
|
|
|
If you want a quick and dirty way to get a pointer to your view you can do this:
MainFrm.h:
CMyView* m_pMyView;
MyView.cpp (in OnInitialUpdate):
((CMainFrame*)(AfxGetMainWnd()))->m_pMyView = this;
Make sure to put class CMyView; above your MainFrame class declaration in MainFrm.h
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
Create an instance of your Class CTableView in CMainFrame
..
CTableView tv;
..
access it by typing tv.*
CaKe
|
|
|
|
|
Hi,
I am adding an automatically resizable dialogbar into my MFC program. But it can not automatically resize when the window size is changed. Can you tell me the reason and how to implement this? Thanks in advance.
Kidd
|
|
|
|
|
|
No difference, do you have any idea? Thanx.
Kidd
|
|
|
|
|
How do I change the cursor to the mouse when i drag it over a bitmap/icon. And How do I get an onclick event to the bitmap/icon?
ALB
|
|
|
|
|
To change the cursor take a look at the API LoadCursor(..) and SetCursor(..) i think i done it with them few times ago,
And to the other yust use the WM_RBUTTONDOWN Message...
|
|
|
|
|
To change the cursor take a look at the API LoadCursor(..) and SetCursor(..) i think i done it with them few times ago,
And to the other yust use the WM_RBUTTONDOWN Message...
|
|
|
|