|
Hello,
I've heard the easiest way of doing COM development with C++ is by leveraging the ATL. Can anybody recommend a good book introducing a medium skilled C++ developer to using ATL?
Any help is appreceated.
Thanks,
Matthias
|
|
|
|
|
The Beginning ATL book from Richard Grimes et al is full of detail but very dry. I found it made more sense AFTER I read 'teach yourself ATL in 21 days' ( OK, I usually run from books that have a time frame attached to the title, but this is from one of the C++ unleashed guys and very good ). Between the two I feel I have a grasp on HOW to use ATL, and I've bought ATL Internals to help learn WHY it does what it does. I came close to buying Richard Grimes 'Professional ATL' book, but online reviews caused me to buy 'Creating Lightweight ATL components' instead. When they arrive I guess I'll find out if I chose poorly, but I have no doubt ATL Internals will rock.
Christian
#include "std_disclaimer.h"
The careful application of terror is also a form of communication.
Eagles may soar, but weasels don't get sucked into jet engines.
|
|
|
|
|
Must be on the same reading list.
I have read all of these titles plus some others. While I have yet to find any one book covering the topic adequately, all of those mentioned here taken together form an excellent base of knowledge.
If I were to rank them I would get ATL in 21 days first to give a you start then move to ATL Internals and Professional ATL Programming.
|
|
|
|
|
Have you read Inside ATL from Microsoft Press?
I really like that book, and think it cover the topic adequately
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Softcopy of the MS Press book'Inside ATL' is available with that book.
|
|
|
|
|
Thanks for the reply. I think I'm getting it now.
QuickSilver
|
|
|
|
|
It's a complex topic so experiment and feel free to ask questions. You should absolutely learn and use STL over CArray et al. If you use ATL/WTL is up to you.
Christian
#include "std_disclaimer.h"
The careful application of terror is also a form of communication.
Eagles may soar, but weasels don't get sucked into jet engines.
|
|
|
|
|
Hi, I'm just a beginner and I was just wondering what templates are? Are templates related to STL and ATL?
I heard that they are really cool.
QuickSilver.
|
|
|
|
|
The T in both ATL and STL stands for templates. You know how you can pass parameters into a function, like
RotateCube(x,y,z);
?? Well, imagine if instead of a function knowing it's getting, for example, 3 int's, you could actually pass in the type as a parameter ? That is what templates do. The classic example is a swap() function. If you wrote a function like this:
void swap(int & x, int & y)
{
int temp = x;
x = y;
y = temp;
}
That's great, but you'd need to rewrite it for floats, for CString, for any other parameter. Instead you can use templates:
template<class T> void swap(T& x, T& y)
{
T temp = x;
x = y;
y = temp;
}
You would use this as follows:
swap<int>(myint1,myint2);
The type passed in <> is accessable as a type in the function by using the name given at the top, typically this is T, but can be any legal variable name.
STL is a rockin' collection of container classes and algorithms that use templaes like this:
vector<int> myVector;
map<bool, CString> myMap;
so that the parameters passed in become the type held by the container ( map is a b-tree and holds two types per iteration ).
ATL is a template library that helps with the creation of COM objects. WTL is a template library that provides an alternative to MFC ( albeit unsupported and incomplete in comparison ).
Templates are a major reason the .Net CLR languages are incomplete - the CLR does not support them, neither does Java, to my knowledge. Templates make it easier to write broadly applicable functions, but they have one drawback. If you use, for example, vector and use it for three different types, then three copies of vector will be compiled in your code. It's not as bad as macros are for code bloat, but it's something to be aware of.
Christian
#include "std_disclaimer.h"
The careful application of terror is also a form of communication.
Eagles may soar, but weasels don't get sucked into jet engines.
|
|
|
|
|
How do I programmatically get my IP
Thanks
|
|
|
|
|
Q160215 - it's written in VB but gives you enough to look it up on the the API site.
or there's at least one articles about it on here eg. (http://www.codeproject.com/useritems/ipaddress.asp)
C++/C# Student.
Wither Thee VB.Net.
|
|
|
|
|
When I use:
"[MyField] ='"+sMyString+"'"
everything works fine unless there is a a single quote in sMyString. Then I get a JET error that a parameter is missing.
Any ideas?
Richard
|
|
|
|
|
I have an icon I am displaying, its a simple check. I need to display it in a few different spots simultaneously. Is there a way to do this without creating a spereate variable for each check, and using ShowWidow()?
|
|
|
|
|
Where are you using the icon? You mentioned ShowWindow() so I'm guessing your using it in a window... do you need to diplay it more than once in a window, or are you wanting to diplay it in multiple windows?
-Ben
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
I could have created a bitmap file as well, either would have worked. I need to show it multiple times from a single dialog window. Anywhere from 1 to 7 times. Right now I have...
enum { IDD = IDD_PROGRESS_DLG };
CStatic m_ctrlCheck1;
CStatic m_ctrlCheck2;
CStatic m_ctrlCheck3;
CStatic m_ctrlCheck4;
CStatic m_ctrlCheck5;
CStatic m_ctrlCheck6;
CStatic m_ctrlCheck7;
I would think this is a waste, since 90% of the time i will only show 3 or 4. My guess is that there is a way to create/show them without creating a variable for each possibility.
|
|
|
|
|
Its sounds like you to me like your making one of those nifty progress dialogs that puts checkmarks beside the tasks that have been completed. Have you considered making an owner-drawn static control that can display the checkmark and the task's text? You could then just create the number of them you need dynamically -- and just store their pointers a list.
-Ben
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
Hello!
Is there any way to use a std::string with the Windows API method LoadString() without having to use a char* as an intermediate step? For example, something like this:
std::string junk;
LoadString(AfxGetInstanceHandle(),IDS_JUNK_STRING,junk.c_str(),250);
This doesn't compile, but maybe there's a way around it. I'm just not used to mixing STL and C-API's.
Thanks,
Derek
|
|
|
|
|
Yes you can.
const int MAX = 250;
std::string junk;
junk.resize(MAX);
LoadString(AfxGetInstanceHandle(), IDS_JUNK_STRING, &junk[0], MAX);
Jam on.
|
|
|
|
|
Thanks! It works using a std::vector<char>, but I wasn't sure if it was correct to use the same &junk[0] method for std::string.
|
|
|
|
|
Yep, vector and string are the two STL containers with guaranteed contiguous memory.
|
|
|
|
|
Actually, Neither string or vector guarantee contiguous memory today. There is a proposal in front of the committee to alter the standard to require contiguous memory for vector, but not for string.
Having said that, it's highly unlikely that anyone will create a string implementation that doesn't use contiguous memory, at least on Win32.
|
|
|
|
|
I'm writing a MDI application with a toolbar in a child window. I want to chnge the toolbar from flat to non-flat buttons (and back) programatically.
I've already got a function in the CChildFrame class that responds to an message, but everything I try results in failure (in one form or another).
Does anyone know what the secret is?
|
|
|
|
|
Hi John,
I just tried with ModifyStyle(TBSTYLE_FLAT, 0) (and vice-versa) and Invalidate() and it seems to work. It's a very simple project though ...
From where are you trying to change the toolbar? (I did it in the MDI child frame)
Well, I think we all need more details to help
Paolo.
|
|
|
|
|
That was exactly what I needed. Thanks buddy.
I was over-engineering my own attempt at a solution, and was so far into the forest, I couldn't see the trees.
|
|
|
|
|
I can't figure out how to control the color of text drawn with CDC::TextOut. CFont or LOGFONT don't seem to have a color attribute, and none of the other crazy things I tried worked. Ideas?
thanks,
Jake
|
|
|
|