Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ATL and Casting Controls

Posted on 2008-06-26
5
Medium Priority
?
452 Views
Last Modified: 2013-12-14
I need some help on working with controls in an visual c ATL project.

I have some basic examples that show how to Interact with controls using:
SetDlgItemText
CheckDlgButton
SendDlgItemMessage

However, now i have a more advanced control type, spin control and I need more control.

I want to be able to map a message for this control to a function and then cast it this:

CSpinButtonCtrl* hWnd = (CSpinButtonCtrl*)lParam;

So i can follow the many examples provided about SpingButtonCtrl.

Howerver, I get the following error:

error C2065: 'CSpinButtonCtrl' : undeclared identifier


Any Suggestions?

Thanks,

Jason
0
Comment
Question by:cristo1701
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 19

Accepted Solution

by:
LordOfPorts earned 1000 total points
ID: 21879530
CSpinButtonCtrl http://msdn.microsoft.com/en-us/library/sfac27cz(VS.80).aspx is declared in the header file afxcmn.h I am not certain if this will work in an ATL project but try including it:

#include <afxcmn.h>
0
 

Author Comment

by:cristo1701
ID: 21879793
LordOfPorts:

I already tracked it down and tried to include that file.

However, I got the following error:

C1189: #error :  Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]

So then I #define _AFXDLL
And Got this error:
WINDOWS.H already included.  MFC apps must not #include <windows.h>

Did some research and found that i need to add these lines before #include <atlbase.h> in StdAfx.h
only to get stuck again with the following error:
fatal error LNK1169: one or more multiply defined symbols found

Thanks,

Jason
0
 

Author Comment

by:cristo1701
ID: 21879968
Alright,

I figured it out finally, I found out this project is actually a MFC dll created by Windows Media Player Wizard.

They use there own version of DllMain, which came into conflict when I included #include <afxcmn.h>

I did all the above and had to replace
extern "C"
with
extern "C" { int _afxForceUSRDLL; }

to force use of my DllMain not the one in the MFC library

this useful tip is expalined here:
http://www.codediscuss.com/mfc/dllmain-in-mfc-dll/

I'm totally new to windows programming and DLLs, does this look right? It seems to work.
0
 
LVL 19

Expert Comment

by:LordOfPorts
ID: 21880238
I am not certain if it will have any impact on any other functionality however if you have tested it successfully and it is working properly give it a try. Alternatively you can also try to access Project -> Properties and under "Use of MFC" select "Use MFC in a Shared DLL" to see if it makes a difference.
MFCSharedDLL.png
0
 

Author Comment

by:cristo1701
ID: 21881173
I tried that before and it didn't seem to have any affect on my issue.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand column That will then direct you to their download page. From that p…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses

670 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