Solved

ATL and Casting Controls

Posted on 2008-06-26
5
438 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 250 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

751 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