Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ATL and Casting Controls

Posted on 2008-06-26
5
Medium Priority
?
458 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
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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
Course of the Month13 days, 10 hours left to enroll

963 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