atl

Pre-registering an ATL window class

╄→尐↘猪︶ㄣ 提交于 2019-12-05 19:08:38
I am using a combination of the ATL and WTL for a project and have derived my own class from CWindowImpl , which looks something like this: class CMyControl : public CWindowImpl<CMyControl> { public: DECLARE_WND_CLASS(_T("MyClassName")) ... BEGIN_MSG_MAP(CMyControl) ... END_MSG_MAP() }; This is all good, and if I use CMyControl::Create to create an instance of the control, then it works fine as under the hood, the CWindowImpl::Create function will register the Win32 class (in this case called MyClassName ). However, it is this behaviour - the Win32 class being registered when an instance is

Load image from memory buffer using ATL CImage

孤街醉人 提交于 2019-12-05 18:27:05
How can I load an image from BYTE* array using CImage ? My workaround until now is to simply create a temporary file, but this operation is very expensive sometimes ... There are probably libraries for that, but I do not want to link to other libraries, all I need is to get image size and effectively display to screen, and CImage is all I need for that ... p->pbData is a BYTE* array and p->dwDataLen is a DWORD that hold the array size My code : ATL::CAtlTemporaryFile TempFile; TempFile.Create(NULL, GENERIC_WRITE | GENERIC_READ); TempFile.Write(p->pbData, p->dwDataLen); TempFile.HandsOff(); ATL

convert BSTR to LPCWSTR

允我心安 提交于 2019-12-05 18:21:31
Here is my need BSTR l_strArgs; LPCWSTR sth; //---- //--- OutputDebugStringW(sth); How to convert BSTR to LPCWSTR ? Is there any header only library that coverts any string type(microsoft) to LPCWSTR type ? Just cover NULL scenario and you're good to go BSTR l_strArgs; LPCWSTR sth = strArgs ? strArgs : L""; As you mentioned ATL in the tag, here is ATL-style one-liner: OutputDebugString(CString(l_strArgs)); or, to make sure you are staying in Unicode domain: OutputDebugStringW(CStringW(l_strArgs)); I just found this one BSTR l_strArgs; LPCWSTR sth; CString cs(_com_util::ConvertBSTRToString(l

Does ATL/WTL still require the use of a global _Module variable?

北城以北 提交于 2019-12-05 17:01:52
I'm just starting up a new ATL/WTL project and I was wondering if the global _Module variable is still required? Back a few years when I started working with WTL it was required (at least for ATL 3.0) that you define a global variable such as: CAppModule _Module; To get ATL to work correctly. But recently I've read somewhere that this may not be required anymore (yet the wizard generated code still uses it). Also I did a search through the Visual C++ include directories and it only picked up _Module in a few places - most notably the ATL COM registry stuff. So do I still need to define a

How does one return a local CComSafeArray to a LPSAFEARRAY output parameter?

本秂侑毒 提交于 2019-12-05 16:07:55
问题 I have a COM function that should return a SafeArray via a LPSAFEARRAY* out parameter. The function creates the SafeArray using ATL's CComSafeArray template class. My naive implementation uses CComSafeArray<T>::Detach() in order to move ownership from the local variable to the output parameter: void foo(LPSAFEARRAY* psa) { CComSafeArray<VARIANT> ret; ret.Add(CComVariant(42)); *psa = ret.Detach(); } int main() { CComSafeArray<VARIANT> sa; foo(sa.GetSafeArrayPtr()); std::cout << sa[0].lVal <<

SQL Server CE 3.5 update row error DB_E_ERRORSOCCURRED column error is DBSTATUS_E_SCHEMAVIOLATION

若如初见. 提交于 2019-12-05 15:52:21
I am investigating moving a small and simple SQL Server database to SQL Server CE and am currently using a small prototype to investigate basic operations with SQL Server CE with the following operations in mind: (1) programmatically create a table, (2) insert new records, (3) read existing records, and (4) update existing records. The prototype is having a problem with updating existing records when using the Accessor and the bound members of the Accessor struct. The select statement works correctly returning the row along with the data. I can update the Accessor bound members however when I

ATL Based Linker Errors

帅比萌擦擦* 提交于 2019-12-05 11:01:49
I got a linking problem with atls.lib lately. I updated my linker's additional dependencies lines with: comctl32.lib C:\WinDDK\7600.16385.1\lib\ATL\i386\atls.lib C:\WinDDK\7600.16385.1\lib\ATL\i386\atl.lib C:\WinDDK\7600.16385.1\lib\ATL\i386\atlsd.lib However, now, I started getting these errors. What can cause these problems? Thank you very much. ------ Build started: Project: hede, Configuration: Debug Win32 ------ Linking... atlsd.lib(externs.obj) : error LNK2005: "char const * const g_pszUpdateEventName" (?g_pszUpdateEventName@@3PBDB) already defined in atls.lib(externs.obj) atlsd.lib

Shall we treat BSTR type in COM as value or reference?

泄露秘密 提交于 2019-12-05 10:04:49
From book ATL Internals , I knew BSTR is different from OLECHAR*, and there are CComBSTR and CString for BSTR. According MSDN Allocating and Releasing Memory for a BSTR , I knew memory management responsibility for caller/callee. Take this line from MSDN, HRESULT CMyWebBrowser::put_StatusText(BSTR bstr) I still do not know how to handle bstr properly in my implementation. Since I still have a basic question for BSTR -- should we treat bstr as a value (like int) or as a reference (like int*), at least on COM interface boundary. I want to convert BSTR as soon as possible to CString/CComBSTR in

Cannot Open File atls.lib

ぃ、小莉子 提交于 2019-12-05 09:11:52
I have atls.lib in my hard drive, but I can't link it into my Visual Studio project. I know that atls.lib is an ATL specific library file, and I have all the ATL files/headers/libraries. However, I still can't link them. LINK : fatal error LNK1104: cannot open file 'atls.lib' Can anyone help a helpless programmer? Thank you very much. It seems that the library directory has not been added. In Project Properties, Linker, General options, add the directory where atls.lib resides to the Additional Library Directories field. In my case the problem was missing ATL/MFC libraries for x64, I had to

ATL COM class registration .rgs file defaults

主宰稳场 提交于 2019-12-05 05:29:11
I'm creating a COM server executable, and have run into a problem with class registration. When I created my class object, the automatically generated .rgs file looked like this: HKCR { NoRemove CLSID { ForceRemove {4C6DAD45-64B4-4C55-81C6-4CE125226421} = s 'Test Class' { ForceRemove Programmable LocalServer32 = s '%MODULE%' { val ServerExecutable = s '%MODULE_RAW%' } TypeLib = s '{EAA173CA-BDBC-463A-8B7A-B010EFA467BC}' Version = s '1.0' } } } This created the registry entries correctly for the CLSID. However, when attempting to call CoCreateInstance externally, I was experiencing a hang. hr =