Solved

ATL and Casting Controls

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

856 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