|
Hi Michael,
The problem I'm having is my Active(ocx) control does not have any interface pointers. All I have is dispinterface for the ocx. Do you know how I call the methods of this control.
Thanks
|
|
|
|
|
You'll be calling it through IDispatch. Use IDispatch::GetIDsOfNames to map method names to IDs, then use those in IDispatch::Invoke. To discover what methods are avaialable, use IDispatch::GetTypeInfo.
Have a look at the source for CComDispatchDriver::Invoken in the ATL that comes with VC++ 6 for some guidance.
|
|
|
|
|
I am a beginner.My first program is show a picture on one static control which based on dialog!And I use WTL to do it,is there some example code ?
Or which book shoud I read!
Pre_thank you for give me a direct!My english is very poor,sorry!Just can read some comment!
I will online wait for you today!
heboy, the name is same as my real name!its meaning is "river "
|
|
|
|
|
I have a series on WTL starting here[^], however it probably won't be too helpful if you have no Windows or GUI programming experience already.
I always advise newbies to start at the API level, and not to move on to libraries until you have a very good understanding of how the APIs work.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
thank you !I think I know some about API !your help is very useful! And your
advice is good for me!
heboy
|
|
|
|
|
Hi all,
I am using ATL COM application, in which i am having a list control, i want that by clicking the particular column the elements of that column sorted out how can i do it ...Plz help me out
I write one callback function for sorting and i called that function in the OnColumnClickListname handler i share my code
LRESULT OnColumnclickList1(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
{
// My code started here
m_ctrllist.Attach(GetDlgItem(IDC_LIST1));
HD_NOTIFY *phdn = (HD_NOTIFY *) pnmh;
m_ctrllist.SortItems(SortFunc, phdn->iItem);
m_ctrllist.Detach();
//My code ends here
return 0;
}
static int CALLBACK SortFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
int nRetVal;
PITEMDATA pData1 = (PITEMDATA)lParam1;
PITEMDATA pData2 = (PITEMDATA)lParam2;
switch(lParamSort)
{
case 0:
nRetVal = strcmp(pData1->empcode,
pData2->empcode);
break;
case 1:
nRetVal = strcmp(pData1->empname,
pData2->empname);
break;
case 2:
nRetVal = strcmp(pData1->designation, pData2->designation);
break;
default:
break;
}
return nRetVal;
}
|
|
|
|
|
Use CSortListViewCtrlImpl, it does sorting for you.
|
|
|
|
|
Hi
I'm using ATL just for one function.
Base64Encode.
I don't make server or network i want juste Encode a string.
I try to make it with an example
from CodeProject:
CString sSource = "ToEncode";<br />
<br />
int nDestLen = Base64EncodeGetRequiredLength(sSource.GetLength());<br />
CString str64;<br />
Base64Encode((const BYTE*)(LPCSTR)sSource, sSource.GetLength(), <br />
str64.GetBuffer(nDestLen), &nDestLen);<br />
str64.ReleaseBuffer(nDestLen);<br />
cout<<(LPCSTR)str64;
It said me Cannot convert CString to LPCSTR one first argument of Base64Encode.
I'm working under VS2005.
It's the right way to do what i want?
Is there a better way, maybe something else than ATL?
How to correct this error?
Thanks for your answer.
Sorry for my poor english i'm not an english-speaking
|
|
|
|
|
|
Hi all,
I am using ATL wizard to make my ATL application and i have ClistCtrl and i want to sort the list,How can i do this if any one having any idea please share it,it will be very thankfull to me
Thanks in advance
|
|
|
|
|
By default CListCtrl will sort items in ascending order.
You can control sort order programatically by setting the style LVS_SORTASCENDING or LVS_SORTDESCENDING
cheers..mil10.
|
|
|
|
|
Just use CSortListViewCtrlImpl, that's all.
|
|
|
|
|
i am new with ATL , i want to declare a method which have a out parameter, i am decalaring this like
[id(1), helpstring("method calcution")] HRESULT calcution([in] int ival1 ,[in] int ival2,[out] int& iret);
but i compiled this is giving errors like
syntax error : expecting a declarator or * near "&"
syntax error : expecting ) near "&"
please give me answer as soon as possible.
Bankey Khandelwal
Software Engineer
|
|
|
|
|
IDL doesn't have references. Try this:
[id(1), helpstring("method calcution")] HRESULT calcution([in] int ival1, [in] int ival2, [out, retval] int *pRet);
Steve
|
|
|
|
|
thanx this is done.
Bankey Khandelwal
Software Engineer
|
|
|
|
|
Hi,
How Do I implement late binding on a COM Addin which I created using ATL?
Thanks..
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
Implement the IDispatch interface. Here's the IDL file for an AddIn I implemented for VC6
import "oaidl.idl";
import "ocidl.idl";
[
uuid(0c8dd9f0-2391-447a-b6dd-72aea4db9dc4),
version(1.0),
helpstring("Visual C++ Build Environment Loader Add-In 1.0 Type Library")
]
library DSWENVLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
importlib("devshl.dll");
importlib("ide\devdbg.pkg");
[
uuid(01b836c6-51c8-4476-bf15-ae91b0fe74f6),
oleautomation,
dual
]
interface ICommands : IDispatch
{
[id(1), helpstring("method RereadEnvironment")]
HRESULT RereadEnvironment();
};
[ hidden, uuid(0309A24D-B3E7-4C6A-8ACD-B3F0F8FAA483) ]
coclass ApplicationEvents
{
[default] dispinterface IDispApplicationEvents;
}
[
uuid(6c5658bc-946b-4bc7-94bf-5530cad3d654)
]
coclass Commands
{
[default] interface ICommands;
};
[
uuid(3d3eb2a1-8ce9-4555-89cd-d989a6b3009e)
]
coclass DswEnv
{
[default] interface IUnknown;
}
};
If you pick the correct options when creating the class, all the hard work gets done for you
|
|
|
|
|
Thanks a lot for your answer.
But if my Idl is smething like this then...
import "oaidl.idl";<br />
import "ocidl.idl";<br />
[<br />
object,<br />
uuid(23BB6C3D-AF30-4622-AE80-F19B29A964A7),<br />
dual,<br />
helpstring("IOutlookAddin Interface"),<br />
pointer_default(unique)<br />
]<br />
interface IOutlookAddin : IDispatch<br />
{<br />
<br />
};<br />
[<br />
uuid(B6AE2F8A-DA59-4371-8664-D4DEFCBE60C9),<br />
version(1.0),<br />
helpstring("EOutlookAddin 1.0 Type Library")<br />
]<br />
library EOUTLOOKADDINLib<br />
{<br />
importlib("stdole32.tlb");<br />
importlib("stdole2.tlb");<br />
<br />
[<br />
uuid(6228A6E9-3C8C-4E6C-8869-77631F65164A),<br />
helpstring("OutlookAddin Class")<br />
]<br />
coclass OutlookAddin<br />
{<br />
[default] interface IOutlookAddin;<br />
};<br />
};
Plus I also have
#import "C:\Program Files\Microsoft Office\Office\mso9.dll" rename_namespace("Office") named_guids <br />
using namespace Office;<br />
#import "C:\Program Files\Microsoft Office\Office\MSOUTL9.olb" rename_namespace("Outlook"), raw_interfaces_only, named_guids <br />
using namespace Outlook;
in my StdAfx.h file. I think the moment we use #import the dlls get early binded, isn't it?
I am creating an Outlook addin. So can you show me the way to create a late binded Outlook addin using ATL.
Thanks once again...
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
Ah - you mean you want to late-bind to Outlook?
In that case, you're correct - the #imports early-bind. You need to access the relevant object through it's IDispatch interface. Not very much fun...You might find using a wrapper around an IDispatch pointer (like this[^]) makes things easier.
|
|
|
|
|
Why do you want to bind late? I tought the office components were dual, and can thus be called through the vtable.
|
|
|
|
|
Well, technically, it is said that to support multiple versions of any office application, late or dynamic binding must be used.
Can anyone help?
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
Can you be more specific? I would just QueryInterface for the interface I need; If it succeeds the component supports it and I can call its methods; If it fails I can't so I try another approach. I can't see the need to "late bind" at the function level using IDispatch when you can negotiate at the interface level using QueryInterface (as is its function).
Steve
|
|
|
|
|
That's what I was thinking.
|
|
|
|
|
using VC++ 2005 Pro, I created an ATL/COM dll, added a simple object, then created a dialog control with a combo box and some other controls. Now I want to populate that combo box with some strings -- how do I do that? I use MFC a lot, so I know in MFC how to use ClassWizard to create a class name to the control, then call its AddString() method. But I don't see anything equilivant -- in VC++ 2005 I hold Ctrl key down and double click the control -- it brings up a window where I can assign class name, but only an integer. So I tried to call GetDlgItem(), but the compiler will not let me typecast its return value to CCombBox* as I can do in MFC.
Do I have to resort to sending normal win32 api messages to populate the combo box list?
Thanks
|
|
|
|
|
Stober wrote: Do I have to resort to sending normal win32 api messages to populate the combo box list?
Yes, if you stick with plain ATL. You can also use WTL, which has the control wrappers that you're looking for.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|