How to get window main handle?

My code is as follows:

#include <Mstn\MdlApi\MdlApi.h>
#include <Mstn\cmdlist.r.h>
#include <Mstn\MdlApi\msnativewindow.h>
#include <windows.h>
#include <DgnPlatform\DgnFile.h>
#include <DgnPlatform\DgnFileIO\DgnFileIOApi.h>

extern "C" DLLEXPORT void MdlMain(int argc, WCharCP argv[])
             HWND hWnd = NULL;
             hWnd = (HWND)mdlNativeWindow_getMainHandle(0);



I can't able to resolve these build errors.

Parents Reply Children
  • The project still fails to compile

    Incorrect!  His project compiles OK.

    Building a C++ project takes several steps...

    1. Compile MicroStation resources (command tables, dialogs, message lists etc)
    2. Compile Windows resources (message lists, version info etc)
    3. C++ pre-processor
    4. Compile C++ code
    5. Link

    Examine his build log to see this...

         Creating library C:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\objects\hc_microstation.lib and object C:\Users\RVARAT~1\AppData\Local\Temp\Bentley\MicroStationSDK\objects\hc_microstation.exp
    hc_microstation.obj : error LNK2019: unresolved external symbol mdlNativeWindow_getMainHandle referenced in function MdlMain
    C:\PROGRA~1\Bentley\MICROS~1\MICROS~1\mdlapps\hc_microstation.dll : fatal error LNK1120: 1 unresolved externals

    The log is telling you that function mdlNativeWindow_getMainHandle() is used, but the linker can't find its implementation.  The implementation is in a library (*.lib) file, but that's not specified in his bmake file.

    Regards, Jon Summers
    LA Solutions

  • The project still fails to compile.

    It is not clear what you mean by "the project", because the discussion is nearly year old.

    But if you mean the discussed project, discussed by Rajesh, I agree with Jon: The compilation was ok, because the error message was not reported by compiler, but by linker.

    Do you understand the whole application build process (well described by Jon)?

    Unfortunately, this old discussion stopped in a middle, and no requested information was shared, so I guess no final conclusion was done at this time.

    "Unable to find/link library" and "Unable to find external symbol" are one from the most often reported C/C++ code build errors in my opinion, when to know and analyze complete environment is usually required.

    With regards,