|
Jörgen Sigvardsson wrote:
I suppose a const pointer ref would do...?
Yes, but since he wants to pass the pointer by reference, I suppose it's because he wants to change the pointer, so a const pointer would not really serve his requirement.
Nish
|
|
|
|
|
Hi Folks,
I am using Microsoft Visual Studio .NET 2003 (Visual C++ 7.1) to access a webservice.
Scenario is:
I make a call to one of the methods of webservice. The call goes succesfully through the webservice. However, it fails while reading the response back from the webservice.
This happens for a specific case if the chunk size is 07ff or 0800 bytes. Here, chunk size is the size of the SOAP response (it does not include HTTP header & footer size). Technically it is the value calculated as nChunkSize on line 1818 in atlhttp.inl.
The code line is:
cresult = get_chunked_size(chunk_buffer, chunk_buffer_end, &nChunkSize);
The call fails because a value of LEX_ERROR is set by the "consume_chunk_footer" function of atlhttp.inl. It seems to me that in this particular case, the socket reads 1 byte less than the actual no. of bytes to be read, and so, it does not find the character '\n' which makes this function to return LEX_ERROR instead of LEX_OK.
I have tested this taking various data. But it fails only for the above scenario.
This seems to be a definite BUG. However, I am not sure if the patch already exists for it. If someone has any workarounds, do let me know.
Regards,
Arun Gupta.
|
|
|
|
|
Hello Folks!
I'm trying to build a DCOM server that interfaces a foreign API (National Instruments IMAQ Vision, for precision).
I implemented my ATL object, created interface, and added methods.... some of them use, in parameters, native types defined in the API library (I got a LIB + 1 .H files), so I wrote, at the beginning of my IDL file:
import "nivision.h";
and continued adding methods.
When I compiled, I got MIDL errors indicating redefinitions on 80% of typedefs in .H file.
What's wrong? Me, probably?
I can post or send code, if needed.
Thanks in advance,
Morenz
|
|
|
|
|
Yep, it was me, in part
The other part goes to National Instruments, which header file I had to modify by 80%, commenting out redefinitions (they referred 'em as "forward delarations"... in fact in an MFC app worked well, but MIDL compiler was not so happy...
Now I'm trying to obtain from NI a "simpler" way to make an ATL server with their types without destroying their headers....
Bye
Morenz
|
|
|
|
|
please help me..
I've developed something.
First I made a txt file that contains just some word "Hello, Bye, etc.." and then load it on the IE.
Second check the text on the IE, and then compare the text with some pattern like "Hello".
Third I add some html cord. The function of cord would change background color of the text "Hello" and hand cursor shape, if the pattern is same.
OK. Now I want to add some more function.
1. If I click the text that was already changed background color, and some more things,
('couse same with some pattern like "Hello")
then I want to make pop up my Dialog box(modal) on the IE. The box name is IDD_POPUP.
2. Next, the IDD_POPUP has a static text. I want to show the "Hello" on the static box of IDD_POPUP.
That's all.. plz help me~
------------------------------------------------------------------------------------------------
void CABC::RegexHighlight(CComPtr spHTML)
///reference - http://www.codeproject.com/miscctrl/chtmlview_search.asp
{
static IRegExpPtr regExp( __uuidof(RegExp) );
static IRegExpPtr regExp_1( __uuidof(RegExp) );
LPCTSTR lpszPattern = " Hello /*some pattern*/ ";
regExp->Pattern = lpszPattern;
regExp->put_Global(VARIANT_TRUE);
IMatchCollectionPtr matches;
IMatchPtr match, tempMatch;
long m_cnt;
int i;
long startPoint, strLength;
IHTMLElement *lpBodyElm;
IHTMLBodyElement *lpBody;
IHTMLTxtRange *lpTxtRange;
bool bFound;
spHTML->get_body(&lpBodyElm);
lpBodyElm->QueryInterface(IID_IHTMLBodyElement,(void**)&lpBody);
lpBody->createTextRange(&lpTxtRange);
CString cstr;
BSTR bstr, tmpbstr;
BSTR bmark;
VARIANT_BOOL ret;
lpTxtRange->get_text(&bstr);
lpTxtRange->getBookmark(&bmark);
cstr = bstr;
matches = regExp->Execute(bstr);
m_cnt = matches->Count;
CString chkStr[1000];
long c_cnt = 0;
bool isChk = false;
for (i = 0; i < m_cnt; i++) {
match = matches->Item[i];
startPoint = match->FirstIndex;
strLength = match->Length;
match->get_Value(&tmpbstr);
CString searchText = tmpbstr;
CComBSTR html;
CComBSTR newhtml;
CComBSTR search(searchText.GetLength()+1,(LPCTSTR)searchText);
while(lpTxtRange->findText(search,0,2,(VARIANT_BOOL*)&bFound),bFound) //lFlags = 2 or 0
{
newhtml.Empty();
lpTxtRange->get_htmlText(&html);
//change the background color, etc..
newhtml.Append(" <span id='regexnum' style='color: Black; background-color: yellow'><font style='cursor:hand'>");
newhtml.AppendBSTR(html);
newhtml.Append("dssd");
lpTxtRange->pasteHTML(newhtml);
}
lpTxtRange->moveToBookmark(bmark, &ret);
}
}
|
|
|
|
|
Sorry I couldn't reply sooner ... since you've indicated you've been reading the Programming IE 5 book, that will save a bunch of your time and my typing.
Check out the section called Sinking Events for DHTML Objects in Visual C++. There's an entire code block provided that shows how you can catch click events and handle them (in this case, a double click). Not exactly certain how you can determine what text was clicked ... I didn't sit and read the entire chp. on the subject; but their ATL Browser example has a good bit of C++ good for you to look over.
You could always make that text item an HTML anchor with a bogus URL and then in the OnBeforeNavigate method, check in the incoming URL to see if they match (then you know what item was clicked upon) ...
Obviously if you don't want the text to look like a standard Hyperlink, you'll have to change that through a style sheet or whatnot ...
:..::. Douglas H. Troy ::..
Fold with us|Development Blogging|viksoe.dk's site
|
|
|
|
|
Thank you~
Your answer help me definitly.
Actually I didn't know whick section is fit for me.
So I've just trying to read the entire book.
Today I'll try to understand the section "Sinking Events for DHTML Objects in Visual C++" and more section.
Thanx
|
|
|
|
|
Hi Guys,
Where can I get "shobjidl.h" & "atlstr.h" files. Actually I downloaded one of the demo project from this forum. But when I compile it says 'Cannot open shobjidl.h, & atlstr.h'
I have searched net but nowhere I found them. Some where I read that atlstr.h can be found in VS .NET . But still didnt get any success.
I downloaded WTL 7.0 & 7.1 from microsoft site. But it does not contain these files.
Can any body out there to help me.
Please give me some downlodable site/ dump
Thanks in advance.
-Tom
|
|
|
|
|
shobjidl.h - part of the Microsoft SDK. You can find that here:
Microsoft Platform SDK Web update site[^]
The other file atlstr.h is a standard ATL includes file that is a part of VS .NET 2003 (not sure about older studio releases). This file is typically found in the folder C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include
You should just be able to #include <atlstr.h> in your application ...
If it's not there, you might want to reinstall studio ...
:..::. Douglas H. Troy ::..
Fold with us|Development Blogging|viksoe.dk's site
|
|
|
|
|
Ya,
Thanks, I re-installed VS .NET 2003 fully & I found all of them.
-Tom
|
|
|
|
|
Hello. I am new to ATL and had a serious problem, see I want to use interface A and interface B, both from MS. The bad thing is they all have method named "GetWindowHandle", what should I do ???!!!
I tried to modify one of them's header to just make it compile, but it just sucks, I think there must be a decent solution.
Thanks a lot ahead.
|
|
|
|
|
Assuming that you want to return different things for each GetWindowHandle, you can do this:
template <typename T>
class InterfaceAShim : public InterfaceA {
STDMETHOD(GetWindowHandle)(HWND* phwnd) { return static_cast<T*>(this)->InterfaceA_GetWindowHandle(phwnd); }
};
class YourClass : public InterfaceAShim<YourClass>, public InterfaceB
{
...
HRESULT InterfaceA_GetWindowHandle(HWND* phwnd) {
}
STDMETHOD(GetWindowHandle)(HWND* phwnd) {
}
}; If you are going to return the same handle in both methods, you don't have to do anything.
Good music: In my rosary[^]
|
|
|
|
|
Hi, Jörgen:
Thank you so much, just 3 small questions:
1. Then the best bet in my code is Not use a method name same as common interface method, like GetWindowHandle, IsDirty, and so on. Right? Otherwise, it is tedious to write this kind of wrapper. (Is it the only solution? I think so)
2. why do you use static_cast, since static_cast do not do run time check, there is no difference with reinterpret_cast here.
3. Here:
template <typename t="">
class InterfaceAShim : public InterfaceA {
STDMETHOD(GetWindowHandle)(HWND* phwnd) { return static_cast<t*>(this)->InterfaceA_GetWindowHandle(phwnd); }
};
I think inside InterfaceAShim, I need only declare one duplicate method name OR I have to declare all methods from InterfaceA, just want to confirm.
Thanks again, you are ATL guru.
|
|
|
|
|
LongIsland wrote:
1. Then the best bet in my code is Not use a method name same as common interface method, like GetWindowHandle, IsDirty, and so on. Right? Otherwise, it is tedious to write this kind of wrapper. (Is it the only solution? I think so)
AFAIK, there is no automated process for this. But I wouldn't say it's the best approach either. I mean, if your method names become odd looking and non descriptive, it's not good.
LongIsland wrote:
why do you use static_cast, since static_cast do not do run time check, there is no difference with reinterpret_cast here.
Because I'm doing an "upcast". T is a subclass of the template. Draw a picture! Thus I don't have to do any casts, because the pointer types are related.
LongIsland wrote:
I think inside InterfaceAShim, I need only declare one duplicate method name OR I have to declare all methods from InterfaceA, just want to confirm.
You only need to declare the duplicate names. Unbound names are deferred to the next subclass, which is your COM class.
Good music: In my rosary[^]
|
|
|
|
|
Hello Jörgen,
If the COM class is written using ATL, how would you write the shim class ?
Many thanks, Jörgen.
Bio.
|
|
|
|
|
Hello Jörgen,
I did me experimentation just a while ago and found that the two (or more) interfaces that has common method names must have a shim class to represent them. For example :
[in ATL]
template <typename T>
class InterfaceAShim : public IDispatchImpl<IInterfaceA, &__uuidof(IInterfaceA), &LIBID_ObjectInterfacesLib, 1, 0>
{
public :
STDMETHOD(Method01)(BSTR stringParam)
{
return static_cast<T*>(this)->InterfaceA_Method01(stringParam);
}
};
template <typename T>
class InterfaceBShim : public IDispatchImpl<IInterfaceB, &__uuidof(IInterfaceB), &LIBID_ObjectInterfacesLib, 1, 0>
{
public :
STDMETHOD(Method01)(BSTR stringParam)
{
return static_cast<T*>(this)->InterfaceB_Method01(stringParam);
}
};
And the implementation class :
class ATL_NO_VTABLE CObjImpl01 :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CObjImpl01, &CLSID_ObjImpl01>,
public ISupportErrorInfo,
public IConnectionPointContainerImpl<CObjImpl01>,
public CProxy_IObjImpl01Events<CObjImpl01>,
public IDispatchImpl<IObjImpl01, &IID_IObjImpl01, &LIBID_ObjectImplementation01Lib, /*wMajor =*/ 1, /*wMinor =*/ 0>,
public InterfaceAShim<CObjImpl01>,
public InterfaceBShim<CObjImpl01>
{
...
...
...
public:
STDMETHOD(InterfaceA_Method01)(BSTR stringParam)
{
return S_OK;
}
STDMETHOD(InterfaceB_Method01)(BSTR stringParam)
{
return S_OK;
}
// Must comment out.
/*
STDMETHOD(Method01)(BSTR stringParam)
{
return S_OK;
}
*/
};
I also found that if I ever define Method01() in the implementation class CObjImpl01 (i.e. by uncommenting it), the Method01()s of the shims never get called. I'm not sure if they are still part of the final compiled code of CObjImpl01.
Any comments, Jörgen ?
Best Regards,
Bio.
|
|
|
|
|
Sorry for the late reply, I was out of town until now.
Lim Bio Liong wrote:
I also found that if I ever define Method01() in the implementation class CObjImpl01 (i.e. by uncommenting it), the Method01()s of the shims never get called.
That's because you rebind the entries in the vtable again in your implementation class. Remember, COM methods are virtual!
The both shims bind Method01 to its corresponding entry in their vtables. If you redeclare the method Method01 in the COM class (which inherits both), it'll rebind the method vtable entry for Method01, in all inherited vtables. Please note that C++ only does this for methods whose names and parameter signature match (i.e. standard C++ overloading rules).
Good music: In my rosary[^]
|
|
|
|
|
Hello Jörgen,
Thanks very much. I got it now. It's a brilliant solution. This series of discussions seem like a good subject for an article.
Thanks, again, Jörgen.
Best Regards,
Bio.
|
|
|
|
|
I am currently designing a program that needs the ca2wex but i can not locate it anywhere, i have the atl library and atlconv but i do not have and cannot find this class if anyone knows where i can get it or at least a way i can implement it myself i would appreciate it thank you.
|
|
|
|
|
|
(ATL/COM/MFC/C++)
HI, I'm beginner about Window programming
I'd like to develop a small dll that has a function.
There is one text(txt file) loaded on IE.
The txt contains just a words like "Hello!!".
I've made that the "Hello!!" has focus of cursor.
I mean If I move cursor on "Hello!!"
then arrow-shaped cursor would be changed to hand-shape on a web page.
Now, If I click the "Hello!!",
the programe opens new dialog that has a static text.
The static text shows me "Hello!!".
That's all. How can I make this?
any reply, any URL contains some reference about this, offer me please.
|
|
|
|
|
As easy as this is to say, it's more complex than just what you're wanting (I believe). Although from your description, you could do all this in straight DHTML ...
Regardless: if you're wanting to program IE, then you'll want the book called Programming Internet Explorer by Microsoft Press.
FYI - if you are beginning windows programming, as you've stated, ATL and COM are far too advanced to start with ... you need to start with learning C++ first. Not programming IE ... (just my personal opinion on this).
Good-luck.
:..::. Douglas H. Troy ::..
Fold with us|Development Blogging|viksoe.dk's site
|
|
|
|
|
Thank you for your answer
Sorry for my question that was not announced my statu minutely.
I've just graduated from my University. So I'd already learn c++ and more stuff.
And, I've been reading the book Programming IE5(MS),
and I'm beginner of ATL/COM.
So I need your answer about my question. Please~;)
|
|
|
|
|
<br />
class CDialogPage1 : public CDialogImpl <CDialogPage1><br />
{<br />
enum { IDD = IDD_DLG1 };<br />
...<br />
}<br />
<br />
class CDialogPage2 : public CDialogImpl <CDialogPage2><br />
{<br />
enum { IDD = IDD_DLG2 };<br />
...<br />
}<br />
<br />
class CSettingDlg : public CDialogImpl <CSettingDlg><br />
{<br />
public:<br />
enum { IDD = IDD_SEETINGDLG };<br />
....<br />
??? GetDialog(UINT DIALOG_IDD) <br />
{<br />
}<br />
private:<br />
CDialogPage1 m_page1;<br />
CDialogPage2 m_page2;<br />
}<br />
how to write this GetDialog function?
or maybe i should change CDialogPage1 & CDialogPage2 , make them inherit from the same class? could anyone give me some hints?
|
|
|
|
|
Are you trying to build a wizard or use a tab ctrl? In which case you could use CPropertySheetWindow to implement this functionality ...
Maybe more details on what exactly it is you're trying to do/implement might better help us (or at least myself) understand how to answer ...
:..::. Douglas H. Troy ::..
Fold with us|Development Blogging|viksoe.dk's site
|
|
|
|
|