The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

sabeeshcs (6) [Avatar] Offline
#1
Hi,
I try to use HWND directly in a Win32 API call, but When i try to build my program, then vc2008 display an error message like this

1>simple.obj : error LNK2028: unresolved token (0A000032) "extern "C" int __stdcall SetWindowTextA(struct HWND__ *,char const *)" (?SetWindowTextA@@$$J18YGHPAUHWND__@@PBD@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)

1>Linking...

1>simple.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall SetWindowTextA(struct HWND__ *,char const *)" (?SetWindowTextA@@$$J18YGHPAUHWND__@@PBD@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)

1>E:MFC_WITH_WINFORMSCLRProject1DebugCLRProject1.exe : fatal error LNK1120: 2 unresolved externals

My code is like this,

1. Create a CLR project using VC2008
2. Change the SUBSYSTEM linker setting to /SUBSYSTEM:WINDOWS.
3. Set the Entry point as main.
4. Add referances to System ans System.Windows.Forms
5. Add a .cpp file with this code


#include <windows.h>
#include<tchar.h>

using namespace System;
using namespace System::Windows::Forms;

[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
Application::EnableVisualStyles();
Form^ form = gcnew Form();

SetWindowText((HWND) form->Handle.ToPointer(),
("Hello World"));

Application::Run(form);
Application::Run(gcnew Form());
return 0;
}
and build.

Please help me to solve this problem. I am using WindowsXP.