Hello,
I am working on a Win32 project with VS2008 Express, where I am attempting to write a C++ program that places two dialog boxes inside a DLL. The two dialog boxes will be accessed with a C program and displayed on the terminal. I've gotten to the point where the only remaining errors are:
Code:
------ Build started: Project: TS104, Configuration: Release Win32 ------
Compiling...
TS104.cpp
.\TS104.cpp(12) : error C2065: 'hDlg' : undeclared identifier
.\TS104.cpp(12) : error C2065: 'hWndParent' : undeclared identifier
.\TS104.cpp(12) : error C2065: 'GoTo1Proc' : undeclared identifier
.\TS104.cpp(40) : error C2065: 'hDlg' : undeclared identifier
.\TS104.cpp(40) : error C2065: 'hWndParent' : undeclared identifier
.\TS104.cpp(40) : error C2065: 'GoTo2Proc' : undeclared identifier
.\TS104.cpp(64) : error C2065: 'nResult' : undeclared identifier
stdafx.cpp
dllmain.cpp
Build log was saved at "file://f:\VS2008\TS104\TS104\Release\BuildLog.htm"
TS104 - 7 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
The documentation for compiler error code C2065 talks about defining namespaces. I created the following namespace:
Code:
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
//
#pragma once
#include "targetver.h"
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <Windows.h>
#include <Winuser.h>
#include <WinDef.h>
#include <BaseTsd.h>
#include <WinNT.h>
#include "resource.h"
#include "TS104.h"
#include "Header.h"
// namespace
namespace std
{
HWND hDlg;
HWND hWndParent;
DLGPROC GoTo1Proc();
DLGPROC GoTo2Proc();
INT_PTR nResult;
}
using namespace std;
// TODO: reference additional headers your program requires here
Now the only error message that I get says the compiler cannot convert a 'INT_PTR' to an 'HWND':
Code:
------ Build started: Project: TS104, Configuration: Release Win32 ------
Compiling...
TS104.cpp
.\TS104.cpp(40) : error C2440: '=' : cannot convert from 'INT_PTR' to 'HWND'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
stdafx.cpp
dllmain.cpp
Build log was saved at "file://f:\VS2008\TS104\TS104\Release\BuildLog.htm"
TS104 - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
The statement that the compiler cannot make an implicit conversion on is:
Code:
hDlg = DialogBox( hInstance, MAKEINTRESOURCE(IDD_DIALOG1), hWndParent, (DLGPROC) GoTo2Proc );
The two issues are: 1. Is the namespace defined correctly and 2. What is the proper way to perform a cast on the statement shown.
Can anybody provide a suggestion about how to resolve these issues? I'm not sure if the namespace creation was handled incorrectly, and that caused the conversion error, or whether the namespace creation was satisfactory, but that had uncovered the conversion error? Any help would be greatly appreciated!!
Regards,
-Frank