|
In a tabbed property page I found out MS uses a gradiant to fill the the client area when using the XP visual styles & new common control library. On one of my property pages I have a child dialog derived from CAxDialogImpl<myclass>. Since this child control is at the bottom of property page I get a big white rectangle where my child dialog is.... it just looks bad.
The only solution i can come up with is move the controls on the child dialog into the property page. Anybody have any ideas, thanks in advance.
|
|
|
|
|
Where do all the WTL programmers hang out, is it just the Yahoo WTL mailing list. I'm trying to improve my WTL skills and I'm looking for good code examples and components besides the ones here at CP.
A Google search tends just to point me at the mailing list or at CodeProject and a few foreign language pages. Any suggestions on where I need to be hanging out.
Michael
Fat bottomed girls
You make the rockin' world go round -- Queen
|
|
|
|
|
I do not think you need special codes besides the ones here. All the MFC codes (at least most) translate into WTL easily, so just pick the basis and you will be fine.
Start some project yourself and you will have enough to learn. I just started my WTL project and is it a good learning process.
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
You may know this one, but just in case
Bjarke Viksoe Home Page, see the URL:
viksoe.dk
ATL/WTL section.
Bjarke has been very nice publishing his work. Although there is not a lot of documentation, I've learnt a lot from his sources.
Best Regards,
Ramon
|
|
|
|
|
What is it we are not good enough for you?
|
|
|
|
|
Hello,
INTRODUCTION
Using VC++6 sp5
MS W2k sp3
I'm using CHtmlView in order to show web pages (that are modified from my dialog based VC++ program) to the user.
In order to be able to do that I'm using Paul Di Lascia's HTMLCtrl and since today this code:
pIDispatchPtr.QueryInterface(pHTMLDocPtr);
if (lpDispatch)
{
hr = lpDispatch->QueryInterface(IID_IHTMLDocument2, (LPVOID*)&pHTMLDocument2);
lpDispatch->Release();
hr = pHTMLDocument2->get_body(&pBody);
pHTMLDocument2->Release();
bstr = csCodiHTML.AllocSysString();
if (pBody)
{
pBody->put_innerHTML(bstr);
pBody->Release();
}
SysFreeString(bstr);
}
The main problem is that for some reason the memory "allocated" is not being freed.
After posting "ho can I free this" in the VC++6 forum, somebody has told me to do it using ATL and COM smart pointers...
I've added this line to the "stdafx.h":
#include <atlbase.h>
QUESTION
I have no idea how to do this, since is my first time in ATL...
I've used this...
CComPtr<IHTMLDocument2Ptr> spHTMLDocPtr;
CComPtr<IDispatchPtr> spIDispatchPtr;
spIDispatchPtr = this->m_HTMLCtrl.GetHtmlDocument();
and I'm getting this error message (when I compile):
error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'struct IDispatch *' (or there is no acceptab
le conversion)
could you tell me how to use those smart pointers in order to link them to the HTML document and to free them when finished?
SUMMARY
I need to know:
- How to link com pointers to the HTML document.
- The HTML document is intended to be taken from a CHtmlView derived class.
- How to free those pointers.
Thanks in advance.
|
|
|
|
|
First, click the "Display this message as-is (no HTML)" in order to make sure that all of your < and > tags appear in your code.
Next it looks like you are declaring your smart pointers like this:
CComPtr<IHTMLDocument2Ptr> spHTMLDocPtr;
CComPtr<IDispatchPtr> spIDispatchPtr;
When you declare a smart pointer with CComPtr you only need to define the type, you don't need to define it as a pointer. So change your code to this:
CComPtr<IHTMLDocument2> spHTMLDocPtr;
CComPtr<IDispatch> spIDispatchPtr;
I believe this will fix your problem.
When ever these items are assigned, Addref is automatically called on your interfaces, and when the smart pointer goes out of scope, the reference is Released. If you would like to get a hold of a pointer without AddRef or Release being called, use Attach adn Detach respectively.
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Thank you very much for your reply!
I'd solved the problem doing what you've suggested...
But I'm still having one problem:
CComQIPtr<IHTMLDocument2> spHTMLDocument = this->m_HTMLCtrl.GetHtmlDocument();
if(spHTMLDocument)
{
CComQIPtr<IHTMLElement> spHTML;
spHTMLDocument->get_body(&spHTML);
if (spHTML)
{
bstr = csCodiHTML.AllocSysString();
spHTML->put_innerHTML(bstr);
spHTML.Release();
}
else
{
}
OK, as you can see In the else clause I'm trying to write the HTML directly to the document. This is interesting for me because for some reason the first time that I try to get access to the document it's a null pointer... (all the other times it works fine).
Moreover if I can do it I'll avoid the usage of the second pointer making the code easier...
The only problem (I expect) is that I need to use a SAFEARRAY type in order to write directly to the document pointer and I don't know how to do it...
I've searched into the MSDN but there are not examples...
Thank you for your help!
|
|
|
|
|
Here is a sample; error handling is omitted (but required):
HRESULT hr = S_OK;
SAFEARRAY * pArray = ::SafeArrayCreateVector(VT_VARIANT, 0, 1);
if (pArray)
{
VARIANT* pElement = 0;
hr = ::SafeArrayAccessData(pArray,(LPVOID*) &pElement);
pElement->vt = VT_BSTR;
pElement->bstrVal = _bstr_t(L"Hello world.").copy();
hr = ::SafeArrayUnaccessData(pArray);
hr = spHTMLDocument->write(pArray);
::SafeArrayDestroy(pArray);
}
|
|
|
|
|
THANK YOU! (infinite times!)
Now I'm able to load memory contents into my HTML Control directly from memory giving a great look to my app without more effort than the one required to design a web page!
Thank you again!
|
|
|
|
|
I want do built a list of VARIANT
#include <list> typedef std::list<variant> VARIANTLIST;
VARIANTLIST varList;
and I add a VARIANT into list varList;
VARIANT pp;
pp.vt=VT_I2;
pp.iVal=1;
varList.push_back(pp);
then length of vatList is increased 1, but the comment is not right.
What is the matter? Can you help me, Thanks.
|
|
|
|
|
What do you mean with "then length of vatList is increased 1, but the comment is not right"?
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
Sorry, I spell a word wrong.
I means then sizes of varList si increased 1, and now varList.size() return 1.
but the element VARIANT whose vt is not VT_I2.
|
|
|
|
|
Sorry, but I think I don't understand !!!
I have tested your code:
#include "stdafx.h"
#include <atlbase.h>
#include <list>
typedef std::list<VARIANT> VARIANTLIST;
VARIANTLIST varList;
int main(int argc, char* argv[])
{
for (int n = 0; n < 100; n++)
{
VARIANT var;
var.vt = VT_I2;
var.iVal = 1;
varList.push_back(var);
}
printf("size = %d \n", (int) varList.size());
return 0;
}
There is all right with the code! I have a std::list of VARIANT and add 100 members of VARIANT to the list!
The varList.size() function returns the count of elements in the list and so it returns 100 and that's right!
The VT_I2 says that the VARIANT holds short members. I2 says that the member is an integer who need 2 byte of space in the memory (sizeof(short) = 2 ).
Take a look in the MSDN:
typedef struct tagVARIANT {
VARTYPE vt;
unsigned short wReserved1;
unsigned short wReserved2;
unsigned short wReserved3;
union {
Byte bVal;
Short iVal;
long lVal;
float fltVal;
double dblVal;
...
...
...
};
};
Hope this helps you!
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
Thanks Daniel S.
I have remove the problem. All the code really run in the right way, the fault was my wrong checking. I check by the watch window of Visual Stdio.
The results of the list element showed there are upset.
Thanks again.
|
|
|
|
|
Sorry, I spell a word wrong.
I means then sizes of varList si increased 1, and now varList.size() return 1.
but the element VARIANT whose vt is not VT_I2.
|
|
|
|
|
Does the STL support a tree as it does with other data structures like the linked-list and vector, or do I need to write my own implementation?
Nick Parker
Not everything that can be counted counts, and not everything that counts can be counted. - Albert Einstein
|
|
|
|
|
|
Neville Franks wrote:
Hope that's of some help.
Thanks for the feedback Neville, I am looking for something that will compile under Unix with GCC. I was hoping (thinking it doesn't exist now) that I could do something like:
tree<int> m_tree;
m_tree.AddNode(1);
m_tree.AddNode(2);
m_tree.AddNode(3);
or at least something like it. Guess I was hoping I wasn't going to have to write a whole bunch of code here as it is due on Friday (last project for my data structures class). I have already started the implementation last night and I can get it done, I was just looking for a quicker method. Thanks again for the extra info.
Nick Parker
Not everything that can be counted counts, and not everything that counts can be counted. - Albert Einstein
|
|
|
|
|
boost.org has a tree class I beleive.
Todd Smith
|
|
|
|
|
Look up Red-Black tree on Google, that is what STL uses for its internal tree mechanism.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Do you need a specialized tree such a binary search tree or a general n-tree?
A general n-tree can be hacked up as:
template <typename T>
struct Node {
T data;
Node* parent;
std::list<Node*> children;
};
template <typename T>
Tree_AppendChild(Node<T>* node, const T& value) {
...
}
template <typename T>
Tree_InsertChild(Node<T>* node, const T& value, int pos) {
...
}
And then you could of course wrap all this into a single class if you want a more object-oriented approach.
N.B. you need to interpret (Node*)NULL as the base case - an empty tree.
--
Only in a world this sh*tty could you even try to say these were innocent people and keep a straight face.
|
|
|
|
|
I'm completely new to ATL . I use VB. I know C++ && API. I have next
questions:
1.How do I define and raise an event from a class defined inside atl.
2.How do I raise errors to the clients that use my DLL.
I'd appreciate if you give me some MSDN refferences or even articles inside CodeProject.
- Any suggestions how to make subclassing for a window through the pass of hWnd parameter inside an ATL DLL? (I have some ideas that worked well under vb using API functions but I really appreciate the experience of the coders that visit this site, so I expect your opinion.)
- I want to use ATL to build an DLL that takes as parameter the hWnd and subclass certain messages secified through an AttachMessage method. When the message is received I want to raise an event WndProc(...) into the caller.
Thanx to all of you. I have a lot to learn from you.
Cosmin Amza
|
|
|
|
|
Answer
Q1.http://msdn.microsoft.com/library/en-ccore/html/vcconATLEventHandling.asp
Q2.AtlReportError() or CComCoClass::Error()
|
|
|
|
|
When i select the object as internetexplorerobject,i would like to call the setsite function onstartup.
How should i call that function.
|
|
|
|