|
I already took a look at this article, but the example doesn't use BeforeNavigate2 and no variable "url" of type VARIANT.
btw I hate the type VARIANT
|
|
|
|
|
I have defined a class foo, and I have a CList of the class, defined as:
CList <foo, foo&=""> fooList;
After populating the list, I want to process items from that list in a function within another class. The ways I have tried keep giving me C2664 and C2440 errors.
This sounds pretty basic, but what is the proper way to declare my function parameters and make the call with the CList?
TIA.
|
|
|
|
|
Here's how you prototype a CList reference parameter:
void YourFunction ( CList<foo, foo&>& refList );
--Mike--
http://home.inreach.com/mdunn/
Trillian: What are you supposed to do with a manically depressed robot?
Marvin: You think you've got problems. What are you supposed to do if you are a manically depressed robot?
|
|
|
|
|
I would like to disable borders which appears with WebBrowser ActiveX. I saw that a solution would be to implement IDocHostUIHandler interface and to use GetHostInfo(), but how to implement that interface from a MFC Dialog Exe. AtlBrowser and WBCustomizer implement IDocHostUIHandler from COM interface.
Thanks in advance.
|
|
|
|
|
I was implementing a reference counting mechanism. How do I address the situation, where I store the pointers in a list or a map and does not have any other references to it. If I use the MFC map or list classes, will the addition to the list/map increment one count. As far as I understand, they either add it as a void* or a CObject*. Is it different in STL lists?
- Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
I was implementing a reference counting mechanism You mean something other than what is available anyway?
If you are adding the pointer to a list you do not need to AddRef. You would AddRef if you were copying the interface.
|
|
|
|
|
If I understood you well, it's some class you're designing (say CYourClass ) that has the ref counting methods (AddRef() and Relase or something similar). In this situation, no container, be it from MFC or STL, is going to call that methods automatically if all you store in them is plain pointers to CYourClass . What you should have to do is store instead some suitable smart pointer that does the job of incrementing/decrementing the objects count at construction, destruction and assignment time. Have a look here at CodeProject or any other major programming site to find a wealth of info about smart pointers.
Once you have your smart pointers up and running, both MFC and STL containers will work OK with them. IMHO, however, STL is preferrable because of portability and design issues.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thankyou for the reply. I have already made the pointer that does the job of inc/dec, assignment etc.
I have a smart pointer implemented, that is used like this:
CPtr<CMyClass> p1 = new CMyClass;
This will make an object of type CMyClass inside the smart pointer and increment the ref count.
if I did
p1 = NULL;
the object would be deleted, because the reference count = 0;
Consider the following case :
I have a class with a member variable m_ptrList of type CPtrList or CTypedPtrList.
CClass::MyFunc()
{
CPtr<CMyClass> p1 = new CMyClass;
m_ptrList.AddHead(p1);
}
The problem that I foresee is that the AddHead will not increment the reference count. So will the object get deleted when MyFunc returns.
Is there something wrong in my understanding of the situation?
-Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
Is there something wrong in my understanding of the situation?
No, your understanding of the situation is absolutely correct, and the object will get deleted when MyFunc returns. CPtrList is a beast every reasonable programmer should try to avoid, because it forces you to abandon type information when storing things in it and reinferring it later thru an explicit cast. Things are no better with CTypedPtrList , as the poor patch it proposes to bring type information back does not permit you to deal with smart pointers.
If you can make the switch, I recommend you enter the wondrous land of STL and substitute list<CPtr<CMyclass> > for your former MFC lists everywhere. Additionally, you might want to reconsider having defined operator CMyClass * () , as it paves the way to errors resulting from inadvertently casting your smart pointers away thus loosing track of the right ref count (as in your example). It'd be better to have an explicit method for casting like T * get() so the programmer is aware of entering a risk zone when she/he uses it.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Is there any simple way to change a item's
parent of a tree control?thank you.
|
|
|
|
|
Do you mean the "parent of a tree control" or the "parent of a node in a tree control"?
Derek Lakin.
Salamander Software Ltd.
|
|
|
|
|
(item's parent) of (a tree control),
|
|
|
|
|
In that case ... if you're using CTreeCtrl , you need to call GetParentItem and pass it the handle of the item (HITEM ) you want to know the parent of. It will return the item handle of the parent item, or NULL if it doesn't exist.
If you are using raw Win32, you need to use Treeview_GetParentItem and pass it the window handle (HWND ) of the tree control and the item handle of the item you want to know the parent of. It will also return the item handle of the parent item, or NULL if it doesn't exist.
Hope this helps
Derek Lakin.
Salamander Software Ltd.
|
|
|
|
|
I am wondering what class to use to have a toolbar appear when a child window is created in a MFC MDI application. I want it so that the main window contains a child frame and a floating toolbar. Thanks.
|
|
|
|
|
Hi
I just wanted to create a dll that works together with the Internet Explorer (the so called BHO-Browser Helper Object)
I created the file as described here: http://www.microsoft.com/mind/defaulttop.asp?page=/mind/0598/browhelp.htm&nav=/mind/0598/inthisissuecolumns0598.htm
In Debug mode, the dll compiles quite fine, but if I choose to compile in Release-mode (ReleaseMinSize or ReleaseMinDependency), I get one linker error:
unresolved external symbol _main (translated from german)
why the hell does my dll not compile, although it does in debug mode?
regards
|
|
|
|
|
remove the _ATL_MIN_CRT preprocessor macro from your release projct.
|
|
|
|
|
it works
thanks a lot
|
|
|
|
|
Look at Q165076 in the knowledge base. You may need to remove the _ATL_MIN_CRT preprocessor define if it is present in you release configuration. This is often the cause of unresolved external errors in ATL .dll's. You will find this in the Project Settings dialog, C/C++ tab, the preprocessor selection in the dropdown.
Hope that helps,
Aaron
|
|
|
|
|
When I add a menu on a Dialog Box....the hot keys of menu did not work although i set the caption of menu item right such as "&Edit...\tCtrl+E". When I do the same work in SDI Appliaction...In single document Application it works fine....but when i made Dialog based application and design menu manually...here it not works.....
I have checked the .rc file in SDI and here class wizard
added more lines for Hot Keys like
IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE
BEGIN
"N", ID_FILE_NEW, VIRTKEY, CONTROL
END
I added these lines in .rc of Dialog application but all in vain....any help
Have a nice wishes for Helper
|
|
|
|
|
You'll have to override PreTranslateMessage in CYourDlg. Inside the function, call ::TranslateAccelerator.
BOOL CYourDlg::PreTranslateMessage(MSG* pMsg)
{
if (::TranslateAccelerator(m_hWnd, m_hAccelTable, pMsg))
{
return TRUE;
}
return CDialog::PreTranslateMessage(pMsg);
}
Init m_hAccelTable in OnInitDialog - call LoadAccelerators.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
HACCEL LoadAccelerators(
HINSTANCE hInstance, // handle to module
LPCTSTR lpTableName // accelerator table name
);
the prototype of LoadAccelerators is like
how i can get lpTableName value....I dont know what to pass in 2nd parametre of function...Thanks foe early help.
|
|
|
|
|
HACCEL LoadAccelerators(
HINSTANCE hInstance, // handle to module
LPCTSTR lpTableName // accelerator table name
);
the prototype of LoadAccelerators is like
how i can get lpTableName value....I dont know what to pass in 2nd parametre of function...Thanks foe early help. if u have any chat contact...i want to chat with u ...thanks.
|
|
|
|
|
Chief ....the problem has been solved.....thanks for your
help.
"VC is an incubus and to tame this monster experience is a mandatory Field."
|
|
|
|
|
Hi,
i just want to know.
Whats your way to look into stl-container.
For example a stl::list that contains structs.
Thanx
Olivier
|
|
|
|
|
I am interested in understanding how to change the capture resolution of a webcam without using the property pages (i.e., dialog boxes). I want to be able to set this in my program independently of the dialog boxes. Does anyone know how to do this? I am using the DirectShow interface for capturing. Any help would be appreciated.
Thanks,
John
|
|
|
|