Solved

CAxWindow without linking to atl?

Posted on 2003-11-09
20
650 Views
Last Modified: 2013-12-03
Possible? If yes, how
0
Comment
Question by:Daij-Djan
  • 9
  • 7
  • 2
20 Comments
 
LVL 48

Expert Comment

by:AlexFM
Comment Utility
There is no such thing "Linking to ATL". As any template library, ATL is set of h-files. Adding the ATL include files doesn't require lib files and doesn't add external depencencies to the project.

0
 
LVL 5

Author Comment

by:Daij-Djan
Comment Utility
There is an atl box in vs.net called 'use of atl'
'not using atl'
'Static link to atl'
'Dynamic link to atl'

but.. whatever. im kinda new so........ what do I have to do to use atl classes?
0
 
LVL 48

Expert Comment

by:AlexFM
Comment Utility
Just include required h-files.

#include <atlwin.h>       // for CAxWindow

VC++ has menu item Insert - New ATL Object. It adds ATL support to existing project.
0
 
LVL 5

Author Comment

by:Daij-Djan
Comment Utility
nope... not enough...
0
 
LVL 19

Accepted Solution

by:
Dexstar earned 250 total points
Comment Utility
Daij-Djan:

> nope... not enough...

Try this:
     #include <atlbase.h>
     #include <atlwin.h>

To get it to compile, you'll sometimes have to change "Not Using ATL" to either of the other two (your choice, depending on whether you want your EXE being larger, or you want to distribute another DLL).  Some features of ATL are not templates, some are part of an actual library that needs to be linked in.  If you use these, then you'll have to link to ATL one way or another.  Try it and see.


Hope that helps,
Dex*
0
 
LVL 5

Author Comment

by:Daij-Djan
Comment Utility
I am not linking to it but I now have _Module in my main cpp file. That worked.
Thanks for trying though
0
 
LVL 19

Expert Comment

by:Dexstar
Comment Utility
Daij-Djan:

I researched your question, posted an answer, you tried it, and it worked.  Yes, to use some of the features of ATL, you will need to have to declare a _Module variable.  What is your issue with that?  It's just a small struct that holds things like a handle to the DLL/EXE module (which you need for loading resources, for example).  The effect of it being there is negligible, especially when weighed against the benefits you get from using CAxWindow.

Unless you can tell me why it is impossible for you to have a _Module variable in your program, I'm going to have to object to your refund request.  I almost feel like we're in this situation:

     Q:  My car used to go, but it suddenly stopped moving, and now it won't start.  What's wrong?
     A:  You're out of gas.  Go buy some more.
     Q:  Well, I don't to spend any money.  Sorry, I want my points back.

I'll work with you to help you get the best answer that works for you, but to get it working, and then request a refund because you didn't like some of the inevitable consequences of the answer makes me feel ripped off.

Dex*
0
 
LVL 5

Author Comment

by:Daij-Djan
Comment Utility
1 most (if not all) atl headers automaticly include "atlbase.h"
2 I simply didnt know about the module. It compiled fine and the docs didnt say this
-> You didnt help me enough but I will accept you comment and be done with it.
0
 
LVL 19

Expert Comment

by:Dexstar
Comment Utility
Look, I don't want you to accept my answer to "be done with it" anymore than I want you to request a refund.  I want(ed) to work with you until you got an answer that you were 100% happy with.  Especially if you're just going to give me a vindictive C grade...  I mean, read what http://www.experts-exchange.com/help.jsp#hi73 says about giving Experts a chance to clarify if you have problems with implementing their answer.

But, FYI, here are few things you should know:

1) In "AtlWin.h", you'll find this:
      #ifndef __ATLBASE_H__
            #error atlwin.h requires atlbase.h to be included first
      #endif
      So, no, it is not included automatically by AtlWin.h

2) When I created a sample project to re-create the problem, I didn't do anything that required _Module to be included, so mine compiled fine without it.  Without any extra information, I would have had no way of knowing that you would need it.  If you had posted the error you got regarding _Module, I would've helped you to work it out...   I mean, I'm glad you were able to figure it out, but I'm not sure why you hold that against me.

3) In the future, I think you'll find that you get more satisfactory answers to your questions if you provide more details.  The extent of the details for your question was "Possible? If yes, how".  When AlexFM tried to help you, the response he got was "nope... not enough... "  It is very difficult to help you if you don't meet us half-way.

I'm seriously considering protesting the grade, but I thought I'd give you a chance to explain your reasoning first.

Dex*
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 5

Author Comment

by:Daij-Djan
Comment Utility
>I'm seriously considering protesting the grade
Do so if you like
0
 
LVL 19

Expert Comment

by:Dexstar
Comment Utility
Daij-Djan:  I guess the real question is...  Did you get it working on your own before I posted anything?  Reading back over it, I can see that maybe you did get it and just forgot to close the question until after I posted.

Dex*
0
 
LVL 5

Author Comment

by:Daij-Djan
Comment Utility
I already had the includes in my file, tryed linking to atl before you posted.
The reason why didnt more info is because I didnt have it. I didnt know what was wrong.
No error msg, nothing

CAxWinddow::Create just silently failed.

Oh and. I became so barsh because AlexFM treated me like a retard. There is an option to link to atl and he just said 'no'
0
 
LVL 19

Expert Comment

by:Dexstar
Comment Utility
Okay, knowing that CAxWindow::Create failed is helpful.  All that time, I thought you were just trying to get it to compile...  :)

I know you got it working, but if you want to debug that issue in the future, you have to do this:
     1) Check the HWND return value of Create.
     2) If it is NULL, then call ::GetLastError() to get the error code.

Or step into the Create() function and see where the failure occurs...

BTW, In Visual Studio 6, there is no option to link to ATL, just like AlexFM said.  However, in Visual Studio .NET, there is most definitely an option, like you said.  Which compiler you are using might be useful information to include in a future question.
0
 
LVL 5

Author Comment

by:Daij-Djan
Comment Utility
vs.net ships with an ms compiler - nothing changed.
You are right and your grade _WAS_ incorrect and I acted purely emiotionally. Sorry
0
 
LVL 19

Expert Comment

by:Dexstar
Comment Utility
Apology accepted.  I'm not going to protest the grade, but if you wanted to change it, I'd appreciate it.

Have a good weekend.

Dex*
0
 
LVL 5

Author Comment

by:Daij-Djan
Comment Utility
I would change it. can I? .... is it really worth the trouble? Is a Grade important?
0
 
LVL 5

Author Comment

by:Daij-Djan
Comment Utility
B
0
 
LVL 19

Expert Comment

by:Dexstar
Comment Utility
Thank you...  Is a grade important?  To some it doesn't really matter, to others, it's a reflection of the quality of their work ...  Which some people take very personally.  But, in the grand scheme of things, all that really matters is that your question got answered, and your problem is solved.  :)

Dex*
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now