|
Hello all.
In all the time I have worked with C++ / MFC I have usually created data-centric applications, so I'm full with apps using ATL OleDB and the ODBC classes (CRecordset et. al.). So, I usually simply bypass the CDocument, or store small ammounts of info there (like the current user's ID and encrypted connection strings).
This time, however, I've been instructed to build a full doc-view application, with all the bells and whistles. It's kinda a internal product, so it will be a desktop app with no connectivity, and the files the app generates must be shared to other users. So, a doc-view app.
I've been wondering, however, how to create the data model. I mean, I created a base class that inherits from CObject, implements serialization and has a GUID as a property and such. Then my model classes inherit from this one. Some of this classes have collections of another one as their child, and so on. Say:
class CEntity : public CObject
{
CGuid GetId() const; };
class CContact : public CEntity
{
};
class CMeeting : public CEntity
{
CArray<CContact*> m_objParticipants;
};
Here the thing is that a CContact object can be used elsewhere, so it is not owned by the CMeeting. So, I'm guessing that the CContact collection should be created in the CDocument-derived class, and so the CMeeting one should have only references to a) the CDocument and b) the contact's CGuid, so that it can search for the actual pointer when needed. This would mean that CDocument should have to serialize the object rather than CMeeting, and I'm thinking CMeeting should only serialize the CGuid value... or something similar.
Yet... it doesn't feel quite right, and I'm rather confused as to which approach to use. So, I was wondering if you CPians could help me with advises, experiencies and how you solved similar problems. Any comment will be really appreciated.
Cheers and thanks in advance.
|
|
|
|
|
I know how to make IE not prompt this error.
How can I compile and distribute a program that wont
trigger this warning? Please let me know.
|
|
|
|
|
|
Hi all,
i get the details of any file using IShellFolder2::GetDetailsOf method,its working fine for other files.
but fails in case of MS Office files of 2007 and upper version of MS Office.
please help me to get these details of these files.
thanks in advance.
|
|
|
|
|
Hello,
I´m trying to output a byte to parallel printer port using dev-c++. I´ve included dos.h and conio.h, and I´ve put inpout32.dll in the system32 dll folder, but when I try to compile, the compiler stops at the "using system" instruction. I`m not very experienced with C programming and am feeling my way around, as yet.What I´m trying to do is to send a signal which can be read by a PLC which will in turn open an automatic barrier to let a registered vehicle in.
Can anybody help me out?
Many anticipated thanks
Andrew
|
|
|
|
|
After the #include <...> lines, insert the following:
short _stdcall Inp32(short PortAddress); */
void _stdcall Out32(short PortAddress, short data);
and link with inpout32.dll
Sample code:
#include <conio.h>
#include <windows.h>
#include<iostream>
short _stdcall Inp32(short PortAddress); */
void _stdcall Out32(short PortAddress, short data);
using namespace std;
int main()
{
cout<<"Parallel Port Interfacing"<<endl;
cout<<"Press 8 to forw, 2 to reverse,4 to left,6 to right,1 to forw&left and 3 to forw&right:"<<endl;
int inp;
do
{
inp=getch();
out32(0x378,0x00);
if(inp=='8')
{
cout<<"forward";
out32(0x378,0x01);
}
else if(inp=='2')
{
cout<<"reverse";
out32(0x378,0x02);
}
else if(inp=='4')
{
cout<<"left";
out32(0x378,0x04);
}
else if(inp=='6')
{
cout<<"right";
out32(0x378,0x08);
}
else if(inp=='1')
{
cout<<"forward and left";
out32(0x378,0x05);
}
else if(inp=='3')
{
cout<<"forward and right";
out32(0x378,0x09);
}
}
while(inp=='1'||inp=='2'||inp=='3'||inp=='4'||inp= ='6'||inp=='8');
system("pause");
return 0;
}
|
|
|
|
|
Thanks for kindly answering. Using your sugestion solved the problem. Thanks again,
Kindest regards
|
|
|
|
|
RealHigh wrote: but when I try to compile, the compiler stops at the "using system" instruction.
Care to share the exact error message as well as the offending statement?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Hi David,
Thanks a lot. Yes I threw out the code I was trying compile, and just started anew, using suggestion from just-in-time. I still don´t know if the code actually works, but at least it´s compiled ok.
Kindest regards
|
|
|
|
|
Hi,
I am using "DrawText(HDC hDC,LPCTSTR lpchText,int nCount,LPRECT lpRect,UINT uFormat)" in my project, it returns 0 means function fils. In which case this function will fail and whether there is error code for this function?
I have gone through MSDN but they didn't mentioned the reason for failing.
Thanks in Advance,
Ratheesh
|
|
|
|
|
Have you tried GetLastError() ?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
That usually works for most WinAPI calls that don't return an actual error message off the back... but its usually specified in the MSDN documentation... for whatever reason, they didn't specify this for this call[^]. That omission is a bit strange.
|
|
|
|
|
The problem isn't with the DrawText call itself. Apparently something is NULL in
DrawText(HDC hDC,LPCTSTR lpchText,int nCount,LPRECT lpRect,UINT uFormat)
An access violation occurs in unmanaged or unsafe code when it attempts to read or write to memory that has not been allocated, or to which it does not have access. Not all reads or writes through bad pointers lead to access violations, so an access violation usually indicates that several reads or writes have occurred through bad pointers, and that memory might be corrupted.
[This] might shed some light.
|
|
|
|
|
TopCoder23 wrote: An access violation occurs
Where exactly did they say they experienced an access violation? They could have simply passed in an invalid parameter option for format or the function could have simply checked for a NULL parameter and returned indicating failure based on that branch statement.
|
|
|
|
|
Try showing the actual code from your program, and make sure that all the parameters are valid.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Hi,
i search for an function to restore folder content to previous status/version?
I mean, if i add new files to folder, i need in some cases to restore a status before adding new files!?
Restore to previous version?
Is there an API to use for that or some sample code??
Simple single deletion of any each file is not the way, because there can be many files added(hundreds)!
Thanks for any help!
|
|
|
|
|
bosfan wrote: i search for an function to restore folder content to previous status/version? I mean, if i add new files to folder, i need in some cases to restore a status before adding new files!? Restore to previous version? Is there an API to use for that or some sample code??
No such API exists.
bosfan wrote: Simple single deletion of any each file is not the way, because there can be many files added(hundreds)!
You can use SHFileOperation() with wildcards.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Hi,
thanks for answer!
regards
bosfan
|
|
|
|
|
Windows has a feature called Backup.
Find it here , and a list of related actions here.
|
|
|
|
|
If functionality provided by the operating system is not sufficient, you might consider using software revision control for your files or differential backup with your prefered tool.
Philippe Mori
|
|
|
|
|
Hi all,
I have made a application in which i play video files Using MCI api's. Everything is working fine accept when the video ends playing and i move my dialog or any window comes over my dialog then the control in which i play my video becomes empty or it does not repaint itself.
I want that after video ends and some windows come up on it, the image should remain there.
How can i do this??
Thanks in advance
|
|
|
|
|
Do you set m_Play.EnableWindow to TRUE ?
m_Play.EnableWindow(TRUE);
m_Video = MCIWndCreate(this->GetSafeHwnd(),
AfxGetInstanceHandle(),
WS_CHILD | WS_VISIBLE|MCIWNDF_NOMENU,m_Path);
MCIWndPlay(m_Video);
Pause = FALSE;
m_Play.EnableWindow(TRUE);
[ here] is a fine example of MCIWndPlay usage that remains there.
|
|
|
|
|
Hi,
I'd like to make the button save as.. and load, but I think that maybe this button is made in visual as activeX or something like that.
Do you know if it is made already?
|
|
|
|
|
antonio343 wrote: I'd like to make the button save as.. and load, but I think that maybe this button is made in visual as activeX or something like that.
Where do you want to put a button save-as or load ? dialog ? menu ? toolbar ?
And, adding a button for the save-as and load will not actually do all the code ... just sayin'
M.
Watched code never compiles.
|
|
|
|
|
Just add them to your toolbar, and then add the code handlers for both items as required.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|