|
How to add control on the CProperty Page .
|
|
|
|
|
Add a new resource. (Insert->Resource->Dialog->Property Page)
Create the property page as you would any standard dialog.
When you create a class for the new resource, make sure you derive from CPropertyPage. That's it.
|
|
|
|
|
Not for the faint hearted. I recently changed the way my project was designed and parts of it stopped working, I tracked this down to a media com object being created in my worker thread and not the thread where my *mainframe* window resides.
Question?
If I'm in a worker thread is there anyway to create a com object under the context of another thread i.e the thread where my mainframe resides, I'm sure I've done this before, but have'nt touched COM for 6months.
Thanks In Advance
Norm Almond
Chief Technical Architect
FS Walker Hughes Limited
|
|
|
|
|
Does the com object work in a worker thread (does it have a window or need a message pump)? You may need to create it in your main thread or a user-interface thread instead.
If you create a com object from the worker thread, then it cannot be called from other threads directly because the com implemenation uses windows messages to call objects in other threads.
|
|
|
|
|
Here goes, hope this is clean
[CMainframe]
|
+-W A S----> OnTimer
| new ATLMediaPlayerWrapperWnd *This Worked*
|
+ N O W----> ActionThread (Responsible for creating objects etc)
| new ATLMediaPlayerWrapperWnd *This Doesn't play but screen a single frame*
if I put DoEvents( PeekMessage etc) in the while (1) loop is works fine.
Ideally I *dont* the DoEvents code, the the object needs to be create in the ActionThread code.
Norm Almond
Chief Technical Architect
FS Walker Hughes Limited
|
|
|
|
|
if I put DoEvents( PeekMessage etc) in the while (1) loop is works fine.
That means you DO need to have a message pump for the object to work. Why not change the ActionThread to a user interface thread derived from CWinThread so that you don't need to DoEvents explicitly.
|
|
|
|
|
Owwww noooo, can't do that. Need especially CWinThread (horrid) need to keep the object in a worker thread. I think I have a solution see other postings on this thread.
Norm Almond
Chief Technical Architect
FS Walker Hughes Limited
|
|
|
|
|
"Owwww noooo, can't do that. Need especially CWinThread (horrid) need to keep the object in a worker thread. I think I have a solution see other postings on this thread."
Good for you. Comeback when it doesn't work.
|
|
|
|
|
Got it working, do you won't a copy for reference
Norm Almond
Chief Technical Architect
FS Walker Hughes Limited
|
|
|
|
|
No, thanks. But you did move the creation of your com object to the main thread which has a message pump, right?
Otherwise, you need to write an article to explain how it is working.
|
|
|
|
|
You can create the object and then marshal it to the other thread via CoMarshalInterThreadInterfaceInStream.
|
|
|
|
|
I know where your coming I reckon this should do the trick?
CMyActionThread::CreateObject()
{
SendMessage(m_hWnd, WM_CREATE_OBJECT, 0, 0);
//
Now get the marshedPointer!
}
LRESULT CMainFrame::OnMyCreateObjectMessage(WPARAM wParam, LPARAM lParam)
{
// Create the object
// Marshal the object
return 0;
}
and it's coming back now, in essential com, there's helper functions, WritePtrToGlobalVariable and ReadPtrFromGlobalVariable
Norm Almond
Chief Technical Architect
FS Walker Hughes Limited
|
|
|
|
|
I have create DBGrid controls at run time and want to catch event corresponding each instance but find no way.
so if someone know about it plz tell me
|
|
|
|
|
I tried to create a cobject derived class:
CObject*t=(CObject*)RUNTIME_CLASS(CHScrollTitle)->CreateObject();
and then i tried to free it with:
delete t; or CHScrollTitle::operator delete(t);
but the delete operator failes in debug-mode with an assert-notice. (something with pHead->nBlockUse==nblockuse)
does anybody know how to free a with CreateObject(or CArchive::ReadObject()) created object?
\
TIA B.Bruggeman
|
|
|
|
|
This problem isn't probably related to CRuntimeClass::CreateObject - seems that you've corrupted the heap somehow.
BTW: calling CRuntimeClass::CreateObject makes absolutely no sense when you know the exact type of object - in your case, it's CHScrollTitle. You can just write
t = new CHScrollTitle;
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I also thought it was a memoryleak/overwrite but i wrote a simple test program and than already it assert's about the debug-memory-tracing-variable m_nBockUse,
but when i use new/delete it doesn't assert..
i have different kind of classes in a list and i want to serialize them using Write/ReadObject, so i can't use an ordinary new/delete operator. but when i tested this it asserts in the (debug) operator delete, so i tested it with the lines i posted before, but it still asserted..
so do you have other suggestions?
btw in the file afxmem.cpp are many operator delete which (in debugmode) either call _free_dbg(p, _CLIENT_BLOCK); or _free_dbg(p, _NORMAL_BLOCK);, so probably the wrong deconstructor is called.. but how do I fix this?
TIA. B.Bruggeman
|
|
|
|
|
1) memory overwrites: the fastest way to detect/remove them is by using automatic diagnostic tools, like BoundsChecker (www.numega.com) or Purify (www.rational.com)
2) serializing different CObject-derived classes from list: just use operator << with pointers to objects. MFC is smart enough to write metadata containing type information to archive. You don't need to write type information yourself.
CBaseClass *p = list.GetHead();
ar << p;
CBaseClass *p;
ar >> p;
delete p;
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
hi there,
I'm writing a client to manage a remote ms-access database, how can i do that is it with SQLConfigDataSource
or something else ??
my problem is that my db is on my website ie:
www.mywebpage.com/database/mydb.mdb
a sample code will help me lot
thanks in advance ...
|
|
|
|
|
how can i add a version number to the CDocument class?
ZHANGYIFEI
|
|
|
|
|
1. Don't double post.
2. You really DON'T want to add _anything_ to the CDocument class.
The whole idea of MFC is that it encapsulates base functionality. To extend it for specific requirements, you inherit an MFC class and extend and customise to your hearts content.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Is my dll will be matched for another language (delphi, vb ect) if I created it in ATL COM APP Wizard and I use in class CDialog into this project ?
|
|
|
|
|
Delphi and VB will be able to call a COM dll generated by ATL/WTL Wizard. I don't tend to use MFC but rather ATL for my dialog classes. As long as you don't export any MFC/C++/C Datatypes then a COM dll should be able to be called from any lanugage that supports COM.
Michael
|
|
|
|
|
MSDN contains an article titled How to add MFC code to an ATL project. It explains all.
Thanks for the help,
Bill
|
|
|
|
|
You must have no problem with that, while in the pc you have the MFC runtimes.
I build ATL Com Objects from a lot of languajes, like delphi, VB, VBScript, VFP, etc....
Cheers
Carlos Antollini.
|
|
|
|
|
The question is why would you need to ? ATL is designed to be lean, why fatten it up with MFC ?
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|