How to Add Wtl and Atl to Visual Studio C++ Express 2008

C++ #include atlbase.h is not found

Microsoft ATL (Active Template Library), which includes the header atlbase.h is included with the Windows 2003 SDK, but it is not included with any newer Windows SDK release. It is also included with Professional editions of Visual Studio.

How do I add a menubar to my WTL dialog window?

First argument of WinAPI function LoadMenu is HINSTANCE of the module from which the menu should be loaded. If your app resources are in the executable (as opposed to a separate resource DLL), you can get its instance by calling GetModuleHandle(NULL):

menu.Attach(LoadMenu(GetModuleHandle(NULL),MAKEINTRESOURCE(<Menubar ID>)));

In other cases, you will need to pass module name to the function.

By the way, an easier way to load a menu is:

CMenu menu;
menu.LoadMenu(MAKEINTRESOURCE(<ID>));

Here is how it is implemented in atluser.h:

BOOL LoadMenu(ATL::_U_STRINGorID menu)
{
ATLASSERT(m_hMenu == NULL);
m_hMenu = ::LoadMenu(ModuleHelper::GetResourceInstance(), menu.m_lpstr);
return (m_hMenu != NULL) ? TRUE : FALSE;
}

So you can use the ModuleHelper thing instead of _Module. It comes from atlapp.h:

inline HINSTANCE GetResourceInstance()
{
#if (_ATL_VER >= 0x0700)
return ATL::_AtlBaseModule.GetResourceInstance();
#else // !(_ATL_VER >= 0x0700)
return ATL::_pModule->GetResourceInstance();
#endif // !(_ATL_VER >= 0x0700)
}

ATL::_AtlBaseModule.GetResourceInstance function returns handle of the module in which ATL was compiled (if I remember correctly).

Compile ATL project with only Windows SDK 7.1

ATL is now freely available as a part of Windows Driver Kit: http://msdn.microsoft.com/en-us/windows/hardware/gg487438.aspx

Cannot open include file: 'atlbase.h': No such file or directory

For me these files are located here:

VS2010 - C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\atlbase.h
VS2008 - C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlbase.h

Please note ATL is part of Microsoft Visual Studio (but not the Express Edition).
If you need get ATL for Express please take a look at this topic How to add WTL and ATL to visual studio c++ express 2008

I don't think copying atlbase.h and atlcom.hwill help you.
You might try to get all atl*.h files and install required Microsoft Visual C++ Redistributable package.

How to make your own native-like (copyable) controls with ATL/WTL?

You have a few custom controls right there in WTL, in \Include\atlctrlx.h:

///////////////////////////////////////////////////////////////////////////////
// Classes in this file:
//
// CBitmapButtonImpl<T, TBase, TWinTraits>
// CBitmapButton
// CCheckListViewCtrlImpl<T, TBase, TWinTraits>
// CCheckListViewCtrl
// CHyperLinkImpl<T, TBase, TWinTraits>
// CHyperLink

Apart from this, you will find custom WTL controls made right way at http://viksoe.dk.

The "copiability" of the controls is based on the fact that standard controls are available to you via handle HWND, and you can easily copy, attach, detach etc. this handle, and while it is valid the whole control is good. Wrapper classes are thin and only have the HWND member variable in them.

Custom controls on the other hand as you noticed have additional information, and you cannot copy them as easily. You can still have this additional information allocated/released dynamically with the control, you will implement the additional control specific window messages and notifications, and then you can create a thin wrapper class that converts methods into messages, sends them to the real control, which in turn will handle them, esp. by converting messages with parameters back to real methods. This let you copy thin wrapper class, but the control itself is way more complicated and cumbersome (you don't normally need to have it that way).



Related Topics



Leave a reply



Submit