Hi,
I am currently migrating a mdl/C++ App from V8i to Connect.
Unfortunately, the app uses mfc-Classes.
The code uses a derived class from CBFramedModelessDialog.
For me, it looks like the CBFramedModelessDialog implementation from Bentley is broken.
Anybody in this forum did any migration to CONNECT that incorporates the MFC-Framework?
Did anybody face the same issue?
Best, Stefan
Stefan Bernsdorf said:it looks like the CBFramedModelessDialog implementation from Bentley is broken
That really doesn't tell us much!
Stefan Bernsdorf said:The code uses a derived class from CBFramedModelessDialog
Show us your code. Have you switched your project from 32-bit to 64-bit? In my experience Viz Studio has a tendency to revert to 32-bit when you're not watching.
Regards, Jon Summers LA Solutions
Hi Stefan Bernsdorf,
As Jon mentions providing more specifics (product versions, problem descriptions/errors and/or code snips) or a sample code project (test case) can ensure the most prompt review, exact problem identification and reproduction, and recommendations towards resolving developer issues.
Prior to providing more (necessary) details, do you mind reviewing the MicroStationAPI.chm help topic: "MFC and Native Window"; that provides specific notes on CBFramedModelessDialog?
Thank you in advance,Bob
Robert Hook said:MicroStationAPI.chm help topic: "MFC and Native Window"
Thanks for that reference!
The formatting has gone AWOL for the MainForm.cpp example code...
MainForm.cpp
MainFrm.cpp ~~~~~~~~~~~~~~~{.c} int CMainFrame::OnCreate( LPCREATESTRUCT lpCreateStruct ) { CWnd::OnCreate (lpCreateStruct); Initialize Native Window support // mdlNativeWindow_initialize("windowTest"); Create a MSWindow instance based on the frame's hWnd // mdlNativeWindow_createMSWindow(&m_pWindow, m_hWnd, FALSE, TRUE, 1); set up default position and size // BSIRect prevRect; UINT nFlags; int screen; prevRect.origin.x = 0; prevRect.origin.y = 0; prevRect.corner.x = prevRect.origin.x + 400 - 1; prevRect.corner.y = prevRect.origin.y + 200 - 1; get previous position, size and screen // mdlNativeWindow_getPreviousPosition(&prevRect, &screen, m_pWindow); Make MicroStation my parent // mdlNativeWindow_setAsChild(m_pWindow, screen, FALSE); Move the window to the previous position, if any // nFlags = SWP_NOZORDER | SWP_NOACTIVATE; if (prevRect.origin.x == 0 && prevRect.origin.y == 0) prevRect.origin.x = prevRect.origin.y == 50; SetWindowPos(NULL, prevRect.origin.x, prevRect.origin.y, prevRect.corner.x - prevRect.origin.x + 1, prevRect.corner.y - prevRect.origin.y + 1, nFlags); Add this MSWindow to MicroStation's Window List // mdlNativeWindow_addToWindowList(m_pWindow); return 0; } void CMainFrame::OnDestroy() {
Hi Jon,
I am using SDK 10.13.00.48.
The app is starting and running, so it seems that compiling and linking works fine.
Only the mfc dialogs are not running. My further inspections showed that the OnInit()-Event of the CDialog is not propagated.
As I see, the example you posted is not based on the CBFramedModelessDialog but maybe I can find a workaround based on that.
To you mind posting the complete MainFrm.cpp or at least advice me where to find it?
Stefan Bernsdorf said:the example you posted is not based on the CBFramedModelessDialog
What example have I posted? The messy code I cited above is taken from the MicroStationAPI help doc.
Hi Jon Summers,
Thank you for pointing out the need to update/clean the documentation formatting. I will see what can be done between now and U15.
BTW. Although I am having trouble identifying a whole MainFrm.cpp (Actual vs. Proper: MainForm.cpp) I did find a cleaner version of this help topic posted from about 6 years ago, here: MFC Dialog And Native Window Support. Please note this post is from a snapshot in time and may need some modifications to work correctly. I will see if I can validate the documentation and source code from which it was derived, otherwise GUI/UI/UX blog posts have been queued up for future posting.
HTH,Bob
I will ask permission from my client to post the code...
Anyway, any derived class from CBFramedModelessDialog will do.
The header file Bentley provides in the SDK differs from the actual compiled stuff
I had to patch
// Construction public: CBFramedModelessDialog ( UINT nID, TCHAR *pTitle = _T(""), bool bResizeable = true, int iDefaultWidth = 400, int iDefaultHeight = 200 );
with
// Construction public: CBFramedModelessDialog ( UINT nID, wchar_t *pTitle = L"", bool bResizeable = true, int iDefaultWidth = 400, int iDefaultHeight = 200 );
to get the code compiled.
Stefan Bernsdorf said:I had to patch// SDK TCHAR *pTitle = _T(""), // Modified wchar_t *pTitle = L"",
// SDK TCHAR *pTitle = _T(""),
// Modified wchar_t *pTitle = L"",
You don't need to hack the SDK header file. TCHAR is a Microsoft typedef. If _UNICODE is defined it is wchar_t. _T() is a Microsoft macro. If _UNICODE is defined it becomes L"".
TCHAR
_UNICODE
wchar_t
_T()
L""
#include <WinNT.h> // Also, define macros _UNICODE and UNICODE in your C++ project
Since the CONNECT SDK is almost entirely Unicode, Bentley Systems don't need to use those macros any longer.
Hello,
In case our project is not unicode, we are forced to hack their .h
Indeed, the constructor with "char pTitle = " does not exist in their lib nativewinmfc.lib
they only have the wchar_t version.
Rgds,
Goubier Sébastien
Sebastien GOUBIER said:In case our project is not unicode, we are forced to hack their .h Indeed, the constructor with "char pTitle = " does not exist in their lib nativewinmfc.lib they only have the wchar_t version.
That's inadvisable. Your code will compile to an object file that wants a library implementation using char* but that implementation does not exist in nativewinmfc.lib. The linker will fail to find the non-Unicode function.
char*
nativewinmfc.lib