ambiguous call to overloaded function in WinApi calls

Code:

namespace OoMetaPanel2 {

using namespace System::Runtime::InteropServices;

[DllImport("user32.dll")]

extern "C" HWND FindWindow( LPCTSTR lpClassName,

LPCTSTR lpWindowName

);

extern "C" BOOL SetWindowText( HWND hWnd,

LPCTSTR lpString

);

extern "C" BOOL ShowWindow( HWND hWnd,

int nCmdShow

);

//......

};

Process Button Click

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)

{

HWND Wnd = FindWindow(_T("SALFRAME"),NULL); //This works OK

bool result = ShowWindow(Wnd, SW_MAXIMIZE); //This cause

ambiguous call to overloaded function

}

};

I tried different variations of Wdn casts into HWND type, and nothing works. I also tried to use another WinAPI window funcions like SetWindowText or OpenWindow, and this error causes anyway.

Please help solve this problem.




Answer this question

ambiguous call to overloaded function in WinApi calls

  • Ravindra Patil

    Ooops, sorry -- I responded before reading your post properly.

    You don't have to trouble yourself by declaring the winapi functions as dllimports like that. Just add the following to your stdafx.h (or similar) header:

    #pragma comment(lib, "user32.lib")
    #define WIN32_LEAN_AND_MEAN
    #include <windows.h>

    That will include the function definitions, and link the library in which they are defined.



  • Depick

    I triet replace

    extern "C" BOOL ShowWindow

    with

    extern BOOL ShowWindow,

    but it didn`t help.



  • Adam1987

    C doesn't support function overloading. Remove the "C" part of your function declaration.

  • Fabio Pintos

    Big thank`s! It`s works!

  • soul creator

    You're very welcome

  • ambiguous call to overloaded function in WinApi calls