Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Skin Framework
  New Posts New Posts RSS Feed - [solved] Runtime check Failure and Load Failed
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

[solved] Runtime check Failure and Load Failed

 Post Reply Post Reply
Author
Message
Cedric_ar View Drop Down
Groupie
Groupie


Joined: 04 September 2012
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote Cedric_ar Quote  Post ReplyReply Direct Link To This Post Topic: [solved] Runtime check Failure and Load Failed
    Posted: 07 March 2017 at 1:29pm
hi,

I'm currently using 16.1 and I try to upgrade to 17.3. but I have 2 problem.

1st problem : Run-Time Check Failure #2 - Stack around the variable 'szHashName' was corrupted.

here my callstack

> ToolkitPro1730v140x64D.dll!CXTPSkinManagerSchemaCodeManager::MapKey(const TMS_SCHEMA_ENTRY * pArray, const char * key, const char * prefix) Line 1138 C++
  ToolkitPro1730v140x64D.dll!CXTPSkinManagerSchema::GetClassCode(const char * lpszClass) Line 328 C++
  ToolkitPro1730v140x64D.dll!CXTPSkinManagerSchema::GetClass(const ATL::CStringT<char,StrTraitMFC_DLL<char,ATL::ChTraitsCRT<char> > > & strClassList) Line 1990 C++
  ToolkitPro1730v140x64D.dll!CXTPSkinManager::GetSkinClass(const CXTPSkinObject * pObject, ATL::CStringT<char,StrTraitMFC_DLL<char,ATL::ChTraitsCRT<char> > > strClassList) Line 751 C++
  ToolkitPro1730v140x64D.dll!CXTPSkinManagerApiHook::OnHookOpenThemeData(HWND__ * hWnd, const wchar_t * pszClassList) Line 2371 C++
  ToolkitPro1730v140x64D.dll!CXTPWinThemeWrapper::OpenThemeData(HWND__ * hWnd, const wchar_t * pszClassList) Line 553 C++
  KS_GUI.dll!KS_MFCEditorApp::InitApp() Line 237 C++

This problem appear when i writing This

m_themeWrapper.OpenThemeData( *m_pMainWnd, L"BUTTON;CLOCK;COMBOBOX;"
	L"COMMUNICATIONS;CONTROLPANEL;DATEPICKER;DRAGDROP;"
	L"EDIT;EXPLORERBAR;FLYOUT;GLOBALS;HEADER;LISTBOX;LISTVIEW;MENU;MENUBAND;"
	L"NAVIGATION;PAGE;PROGRESS;REBAR;SCROLLBAR;SEARCHEDITBOX;SPIN;STARTPANEL;"
	L"STATUS;TAB;TASKBAND;TASKBAR;TASKDIALOG;TEXTSTYLE;TOOLBAR;TOOLTIP;"
	L"TRACKBAR;TRAYNOTIFY;TREEVIEW;WINDOW" );

2nd problem : 

i've a assert on 
Program: \ToolkitPro1730v140x64D.dll
File: ..\..\Source\Common\XTPDrawHelpers.cpp
Line: 3900

the callstack
> ToolkitPro1730v140x64D.dll!CXTPPrimitiveDrawer::InitFont() Line 3900 C++
  ToolkitPro1730v140x64D.dll!CXTPPrimitiveDrawer::DrawSymbol(CDC * pDC, XTPPrimitiveSymbol nSymbol, const CRect & rc, unsigned long crForeColor, unsigned long crBackColor, int bOutline, HPEN__ * hOutlinePen) Line 3951 C++
  ToolkitPro1730v140x64D.dll!CXTPPaintManager::DrawDropDownGlyph(CDC * pDC, CXTPControl * __formal, CPoint pt, int bSelected, int bPopuped, int bEnabled, int bVert) Line 890 C++
  ToolkitPro1730v140x64D.dll!CXTPPaintManager::DrawControlToolBarParent(CDC * pDC, CXTPControl * pButton, int bDraw) Line 2227 C++
  ToolkitPro1730v140x64D.dll!CXTPPaintManager::DrawControl(CDC * pDC, CXTPControl * pButton, int bDraw) Line 1417 C++
  ToolkitPro1730v140x64D.dll!CXTPControl::GetSize(CDC * pDC) Line 158 C++
  ToolkitPro1730v140x64D.dll!CXTPControls::XTPBUTTONINFO::Attach(CDC * pDC, CXTPControl * p) Line 710 C++
  ToolkitPro1730v140x64D.dll!CXTPControls::CalcDynamicSize(CDC * pDC, int nLength, unsigned long dwMode, const CRect & rcBorder, int nWidth) Line 1451 C++
  ToolkitPro1730v140x64D.dll!CXTPToolBar::CalcDockingLayout(int nLength, unsigned long dwMode, int nWidth) Line 764 C++
  ToolkitPro1730v140x64D.dll!CXTPTabToolBar::CalcDockingLayout(int nLength, unsigned long dwMode, int nWidth) Line 647 C++
  ToolkitPro1730v140x64D.dll!CXTPDockBar::_AdjustRow(CArray<CXTPToolBar *,CXTPToolBar *> & arrRow, CPoint pt, int nLength, int bHorz, AFX_SIZEPARENTPARAMS * lpLayout, int & nRemove) Line 194 C++
  ToolkitPro1730v140x64D.dll!CXTPDockBar::AdjustRow(CArray<CXTPToolBar *,CXTPToolBar *> & arrRow, CPoint pt, int nLength, int bHorz, AFX_SIZEPARENTPARAMS * lpLayout) Line 355 C++
  ToolkitPro1730v140x64D.dll!CXTPDockBar::CalcDynamicLayout(int nLength, unsigned long nMode, AFX_SIZEPARENTPARAMS * lpLayout) Line 415 C++
  ToolkitPro1730v140x64D.dll!CXTPDockBar::OnSizeParent(unsigned __int64 __formal, __int64 lParam) Line 483 C++


with 16.1 i haven't those issue.  I'm using DLL without unicode.


Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post Posted: 08 March 2017 at 3:21am
Hello,

First problem needs more time to investigation.
About second problem I can advice to review settings of project.

Regards,
 Oleksandr Lebed

Back to Top
Cedric_ar View Drop Down
Groupie
Groupie


Joined: 04 September 2012
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote Cedric_ar Quote  Post ReplyReply Direct Link To This Post Posted: 08 March 2017 at 7:00am
thanks for the reply

for the 1st pb:
I forget to mention. I'm on Window 10 ( anniversary update ) with Visual Studio 2015 update 3

For the font problem i read this post. it's refer to a static utilisation of XTP. i'm using DLL version. My project setting ( dll project ) are correct :

'Configuration Properties' > General > 'Use of MFC' > 'Use MFC in a Shared DLL'
'Configuration Properties' > 'C/C++' > 'Code generation' > 'Runtime Library' > 'Multi-threaded DLL (/MD)'


regards

Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post Posted: 09 March 2017 at 6:48am
Originally posted by Cedric_ar Cedric_ar wrote:

i'm using DLL version

in that post described settings of ToolkitPro library. Please check its settings and rebuild it.
Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post Posted: 09 March 2017 at 10:13am
Originally posted by Cedric_ar Cedric_ar wrote:

...Stack around the variable 'szHashName' was corrupted.
m_themeWrapper.OpenThemeData( *m_pMainWnd, L"BUTTON;CLOCK;COMBOBOX;"
	L"COMMUNICATIONS;CONTROLPANEL;DATEPICKER;DRAGDROP;"
	L"EDIT;EXPLORERBAR;FLYOUT;GLOBALS;HEADER;LISTBOX;LISTVIEW;MENU;MENUBAND;"
	L"NAVIGATION;PAGE;PROGRESS;REBAR;SCROLLBAR;SEARCHEDITBOX;SPIN;STARTPANEL;"
	L"STATUS;TAB;TASKBAND;TASKBAR;TASKDIALOG;TEXTSTYLE;TOOLBAR;TOOLTIP;"
	L"TRACKBAR;TRAYNOTIFY;TREEVIEW;WINDOW" );


Documentation for CXTPWinThemeWrapper::OpenThemeData():

Open the theme data for the specified HWND and semi-colon separated list of class names. OpenThemeData() will try each class name, one at a time, and use the first matching theme info found.

void OpenThemeData(
    HWND hWnd, 
    LPCWSTR pszClassList
);

hWnd
Window handle of the control/window to be themed.
pszClassList
Class name (or list of names) to match to theme data section. if the list contains more than one name, the names are tested one at a time for a match. If a match is found, OpenThemeData() returns a theme handle associated with the matching class. This param is a list (instead of just a single class name) to provide the class an opportunity to get the "best" match between the class and the current theme. For example, a button might pass L"OkButton;Button" if its ID=ID_OK. If the current theme has an entry for OkButton, that will be used. Otherwise, we fall back on the normal Button entry.

See examples on this forum (link, link)

I have explored callstack for CXTPSkinManagerSchemaCodeManager::MapKey and can see that SkinFramework doesn't support splitting of ClassList. To compare strings there is used _tcsicmp() which compare whole strings. That is why method MapKey even doesn't have checking of length of string on copying. It expects that class name will be one from global array with class names and parts (gSchemaClassAndPartsCodes).

Also if you want to use single CXTPWinThemeWrapper for all controls you should to know, that CXTPSkinManagerSchemaCodeManager::MapKey method caches key (pszClassList, second parameter of OpenThemeData()).  So for all further calls it will return the same value for this class list. Buffer szHashName size is 255. But even I make dynamic buffer size and splitting of ClassList, then your algorithm will not work because OpenThemeData() always handle first BUTTON and skip all other controls. Except cases when you set theme which doesn't have buttons.
Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post Posted: 10 March 2017 at 7:33am
I have fixed noticed defects. Changes will be available in next beta or final release.

Regards,
 Oleksandr Lebed
Back to Top
SvenC View Drop Down
Groupie
Groupie


Joined: 02 February 2007
Status: Offline
Points: 79
Post Options Post Options   Thanks (0) Thanks(0)   Quote SvenC Quote  Post ReplyReply Direct Link To This Post Posted: 10 March 2017 at 7:59am
Originally posted by olebed olebed wrote:

Changes will be available in next beta or final release

As you hinted several times about that: can you already announce an expected time frame for 18.0 beta and/or release? Really looking forward to that Smile
--
SvenC

Toolkit Pro 15.3.1, 16.2.4, 16.3.1, 16.4.0, 17.2.0, 17.3.0, 18.0.1, 18.2 with VC++ 2010, 2012, 2013, 2015, 2017
Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post Posted: 10 March 2017 at 10:37am
Back to Top
Cedric_ar View Drop Down
Groupie
Groupie


Joined: 04 September 2012
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote Cedric_ar Quote  Post ReplyReply Direct Link To This Post Posted: 10 March 2017 at 11:57am
For runtime check failure. 
i'll change my code according to your reply.


For the Font loading

the Codejock dll project checked and it's ok

On codejock.Toolkitpro.shared project this options ar correctly setup

'Configuration Properties' > General > 'Use of MFC' > 'Use MFC in a Shared DLL'
'Configuration Properties' > 'C/C++' > 'Code generation' > 'Runtime Library' > 'Multi-threaded DLL (/MD)'

but i think it's my project setup that cause the problem. I've a small exe with plenty of dll. I have a dll use for the GUI, these dll is linked to XTP in dll too.

 When i debug void CXTPPrimitiveDrawer::InitFont() this line

HMODULE hResModule = AfxFindResourceHandle( MAKEINTRESOURCE(XTP_IDC_FONT_CODEJOCK), RT_FONT); 

always return my GUI dll not XTP dll ( i've checkef in my dll if a have a same resource type with the same id but no ). then if step in AfxFindResourceHandle, only my gui dll and mfc40s.dll are parsed.

then i try to add this at the begin of function and it's works now 

void CXTPPrimitiveDrawer::InitFont()
{
if (NULL == m_hCodejockMemFont)
{
// custom modification
#ifdef _AFXDLL
#ifdef _DEBUG
HMODULE hResDll = LoadLibrary( _T( "ToolkitPro1730v140x64D.dll") );
else
HMODULE hResDll = LoadLibrary( _T( "ToolkitPro1730v140x64.dll" ) );
#endif
AfxSetResourceHandle( hResDll );
#endif
        // 

I think it's not the best solution, but it's works for me.


Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post Posted: 01 October 2017 at 9:13am
Hello,

Thank you for information.
Problem was solved like in this post.


Regards,
 Oleksandr Lebed
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.188 seconds.