|
You could try to empty the WM_POWERBROADCAST reaction of your frame (1, rudely)
or to debug the CMFCVisualManagerOffice2007::OnUpdateSystemColors() after the logon...
...to find the responsible for the crash line
and then - to derive your own class from Off2007VManager
with some overwritten virtualities (2)
virtual void BeHappy() = 0;
|
|
|
|
|
So, now the problem is how to use my derived class in MainFrame.
I can't use :
CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCMyVisualManagerOffice2007));
My application still crash.
|
|
|
|
|
// I can't use
Why ?
virtual void BeHappy() = 0;
|
|
|
|
|
Here is my derived class:
class CMFCMyVisualManagerOffice2007 : public CMFCVisualManagerOffice2007
{
DECLARE_DYNCREATE(CMFCMyVisualManagerOffice2007)
public:
CMFCMyVisualManagerOffice2007();
virtual ~CMFCMyVisualManagerOffice2007();
virtual void OnUpdateSystemColors()
{
m_bAutoFreeRes = bAutoFree;
}
};
IMPLEMENT_DYNAMIC(CMFCMyVisualManagerOffice2007, CMFCVisualManagerOffice2007)
So, in OnCreate of CMainframe:
CMFCMyVisualManagerOffice2007::SetStyle (CMFCMyVisualManagerOffice2007::Office2007_LunaBlue);
CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCMyVisualManagerOffice2007));// this line crash application
|
|
|
|
|
Does it crash at the initial starting or after the standby mode ?
Try to comment your implementation for virtual void OnUpdateSystemColors() firstly,
then, when it will not crash, try to modify it slowly, for example :
void COurVisualManagerOffice2007::OnUpdateSystemColors()
{
CYourApp* pcApp = (CYourApp*) AfxGetApp();
ASSERT(pcApp);
if (pcApp) {
switch (pcApp->m_nAppLook) {
case ID_VIEW_APPLOOK_OFF_2007_BLUE:
CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_LunaBlue);
break;
case ID_VIEW_APPLOOK_OFF_2007_BLACK:
CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_ObsidianBlack);
break;
case ID_VIEW_APPLOOK_OFF_2007_SILVER:
CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Silver);
break;
case ID_VIEW_APPLOOK_OFF_2007_AQUA:
CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Aqua);
break;
}
}
CMFCVisualManagerOffice2007::OnUpdateSystemColors();
}
virtual void BeHappy() = 0;
|
|
|
|
|
Ok, this works in first time that I go in sleep/stand by mode.
In second time my application crash in the same way.
Im using Windbg to see stack.
Here is my stack, the problem happens in release/debug version.
02dcf92c 78bbdb80 mfc90u!AfxFindResourceHandle+0x15 [f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dllinit.cpp @ 237]
02dcf94c 78bb8b74 mfc90u!CPngImage::Load+0x2e [f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxtoolbarimages.cpp @ 3141]
02dcf9f8 78b38b3d mfc90u!CMFCToolBarImages::LoadStr+0xca [f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxtoolbarimages.cpp @ 199]
02dcfb20 78bd2e4e mfc90u!CMenuImages::SetColor+0x7e [f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxmenuimages.cpp @ 111]
02dcfb50 78bd2d33 mfc90u!CMFCVisualManagerOffice2007::~CMFCVisualManagerOffice2007+0x27 [f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxvisualmanageroffice2007.cpp @ 305]
02dcfb5c 78bc4772 mfc90u!CMFCVisualManagerOffice2007::`scalar deleting destructor'+0xd
02dcfb6c 78b23736 mfc90u!CMFCVisualManager::SetDefaultManager+0x34 [f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxvisualmanager.cpp @ 159]
02dcfb80 78b20b95 mfc90u!AFX_GLOBAL_DATA::Resume+0x138 [f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxglobals.cpp @ 1254]
02dcfb8c 78a3f97c mfc90u!CFrameWndEx::OnPowerBroadcast+0x1d [f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxframewndex.cpp @ 1164]
02dcfc3c 78a3f6ce mfc90u!CWnd::OnWndMsg+0x287 [f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp @ 1897]
02dcfc5c 78a3e2f4 mfc90u!CWnd::WindowProc+0x24 [f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp @ 1755]
02dcfcc4 78a3e580 mfc90u!AfxCallWndProc+0xa3 [f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp @ 240]
02dcfd2c 7e418734 mfc90u!AfxWndProc+0x37 [f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp @ 402]
02dcfd58 7e418816 USER32!InternalCallWinProc+0x28
02dcfdc0 7e428ea0 USER32!UserCallWinProcCheckWow+0x150
02dcfe14 7e428eec USER32!DispatchClientMessage+0xa3
02dcfe3c 7c90e473 USER32!__fnDWORD+0x24
02dcfe60 7e4193e9 ntdll!KiUserCallbackDispatcher+0x13
02dcfe8c 7e419402 USER32!NtUserPeekMessage+0xc
02dcfeb8 78a7ea72 USER32!PeekMessageW+0xbc
02dcfeec 78a7e337 mfc90u!CWinThread::Run+0x86 [f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\thrdcore.cpp @ 640]
02dcff70 78543433 mfc90u!_AfxThreadEntry+0x10c [f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\thrdcore.cpp @ 126]
02dcffa8 785434c7 MSVCR90!_callthreadstartex+0x1b [f:\dd\vctools\crt_bld\self_x86\crt\src\threadex.c @ 348]
02dcffb4 7c80b729 MSVCR90!_threadstartex+0x69 [f:\dd\vctools\crt_bld\self_x86\crt\src\threadex.c @ 326]
02dcffec 00000000 kernel32!BaseThreadStart+0x37
|
|
|
|
|
Hmm...
...may be, it is not correctly to process AFX_GLOBAL_DATA::Resume()
since it was initialized by the main thread (that is not my case).
So you can empty/redirect CYourMainFrame::OnPowerBroadcast(..)
without the call of CFrameWndEx::OnPowerBroadcast(..) ...
virtual void BeHappy() = 0;
|
|
|
|
|
Hi all.
Can we create DSN Name and set a datadase path through Install shield 2010.
i.e I dont want to create DSN name going through Control Panel->ODBC
and then select .mdb file and create DSN Name and selecta database path
Any ideas will be helpful
I dont know,is this the right forum for this question.
Thanks
Raj
|
|
|
|
|
How is this a C/C++/MFC question?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hi, I am getting below compiler error on Visual Studio 2005:
isodirbrowserlistctrl.cpp(46) : error C2906: 'const AFX_MSGMAP *CListDataCtrl<B,T>::GetThisMessageMap(void)' : explicit specialization requires 'template <>' with [B=CListCtrl,T=CBrowserListCtrlData
Here is the code with .h and .cpp files. This code used to compile and run fine on Visual Studio 6.0. I guess I need to use BEGIN_TEMPLATE_MESSAGE_MAP. But BEGIN_TEMPLATE_MESSAGE_MAP can not handle more than one template arguments. In my case, there are 2 template arguments.
class CListDataBase
{
public:
CListDataBase() : m_iItem(-1), m_pCtl(0) {};
void SetControl(CListCtrl* pCtl) { m_pCtl = pCtl; }
CListCtrl* GetControl() { return m_pCtl; }
void SetItemNumber(int iItem) { m_iItem = iItem; }
int GetItemNumber() { return m_iItem; }
protected:
int m_iItem;
CListCtrl *m_pCtl;
};
template <class B, class T>
class CListDataCtrl : public B
{
public:
CListDataCtrl() {};
public:
public:
T* GetListData(int iItem)
{
T *pResult = (T*) GetItemData(iItem);
return pResult;
}
void DeleteListDataPrim(int iItem)
{
T* pData = (T*) GetItemData(iItem);
delete pData; pData = 0;
SetItemData(iItem, 0);
}
void DeleteListData(int iItem)
{
DeleteListDataPrim(iItem);
}
BOOL DeleteListNode(int iItem)
{
DeleteListData(iItem);
return DeleteItem(iItem);
}
void SetListData(int iItem, T* pData)
{
pData->SetItemNumber(iItem);
pData->SetControl(this);
DeleteListData(iItem);
SetItemData(iItem, (DWORD) pData);
}
void DeleteAllListData()
{
int cMax = GetItemCount();
for (int i=0; i<cMax; i++)
{
delete (T*) GetItemData(i);
SetItemData(i, 0);
}
}
void DeleteEntireList()
{
DeleteAllListData();
DeleteAllItems();
}
T* InsertItemData(LPCTSTR ptszText, int iItem, T* pData = 0)
{
if (!pData)
{
pData = new T;
}
int iNewItem = InsertItem(iItem, ptszText);
SetListData(iNewItem, pData);
return pData;
}
public:
virtual ~CListDataCtrl() {};
protected:
DECLARE_MESSAGE_MAP()
#endif // !defined(AFX_LISTDATACTRL_H__D2FAE7C7_4E4E_11D2_BA1B_00A02489AC7A__INCLUDED_)
#include "ListDataCtrl.h"
#include "DirectoryInfo.h"
#include "DirDn.h"
class CBrowserListCtrlData : CListDataBase
{
public:
CDirDn m_rdnEntry;
CDirectoryInfo* m_pDirInfo;
HTREEITEM hTreeParent;
CString m_csFullDn;
};
typedef CListDataCtrl<CListCtrl,CBrowserListCtrlData> CIsoDirBrowserListCtrlBase;
class CIsoDirBrowserListCtrl : public CIsoDirBrowserListCtrlBase
{
public:
CIsoDirBrowserListCtrl();
public:
public:
public:
virtual ~CIsoDirBrowserListCtrl();
protected:
DECLARE_MESSAGE_MAP()
};
<pre lang="x-cpp">
#include "stdafx.h"
#include "isodirbrowser.h"
#include "IsoDirBrowserListCtrl.h"
CIsoDirBrowserListCtrl::CIsoDirBrowserListCtrl()
{
}
CIsoDirBrowserListCtrl::~CIsoDirBrowserListCtrl()
{
}
BEGIN_MESSAGE_MAP(CIsoDirBrowserListCtrlBase, CListCtrl)
END_MESSAGE_MAP()
BEGIN_MESSAGE_MAP(CIsoDirBrowserListCtrl, CIsoDirBrowserListCtrlBase)
END_MESSAGE_MAP()
Here is the code with .h and .cpp files. This code used to compile and run fine on Visual Studio 6.0. I guess I need to use BEGIN_TEMPLATE_MESSAGE_MAP.But I can't use BEGIN_TEMPLATE_MESSAGE_MAP because it works only when there is single template argument. In my case, I have 2 template arguments.
#define BEGIN_TEMPLATE_MESSAGE_MAP(theClass, type_name, baseClass) \
PTM_WARNING_DISABLE \
template < typename type_name > \
const AFX_MSGMAP* theClass< type_name >::GetMessageMap() const \
{ return GetThisMessageMap(); } \
template < typename type_name > \
const AFX_MSGMAP* PASCAL theClass< type_name >::GetThisMessageMap() \
{ \
typedef theClass< type_name > ThisClass; \
typedef baseClass TheBaseClass; \
static const AFX_MSGMAP_ENTRY _messageEntries[] = \
{
Can above BEGIN_TEMPLATE_MESSAGE_MAP be changed to cater for 2 template arguments. I mean can I have BEGIN_TEMPLATE_MESSAGE_MAP_2 for 2 template arguments? Can someone tell me what will have to be written in BEGIN_TEMPLATE_MESSAGE_MAP_2 macro to handle 2 template arguments for VS2005?
PLEASE NOTE that I need to have BEGIN_TEMPLATE_MESSAGE_MAP_2 for Visual Studio 2005. Please help.
|
|
|
|
|
See if this[^] can help.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
I looked at it. But it has Customized BEGIN_TEMPLATE_MESSAGE_MAP only for VC7. It doesn't have mention of Customized BEGIN_TEMPLATE_MESSAGE_MAP for VS2005/VC8.
|
|
|
|
|
Well, other than "extracting" the macros yourself and adding the template parameters where needed i have no better idea yet if those don't work for VS2005/8 as you said...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
Is there a standard vectorized way to copy a list of doubles to a list of int8 values? I would like to code the following:
typedef __uint8 unsigned __int8;
double *const srcList = new double [ARRAY_SIZE];
__uint8 *const dstList = new __uint8[ARRAY_SIZE];
for (size_t i = 0; i < ARRAY_SIZE; ++i)
dstList[i] = static_cast<__uint8>(max<double>(0, min<double>(255, srcList[i]))); I would like to code this more like the following:
__uint8 ToUint8(double const inVal) {
return static_cast<__uint8>(max<double>(0, min<double>(255, srcList[i])));
}
std::???(srcList, srcList + ARRAY_SIZE, dstList, &ToUint8); Is there some existing function that will make the above work, or do I need to just make the iterator myself? Thanks,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
you or the build in functions have to parse the entire list.
try stl's
for_each
|
|
|
|
|
std::transform(src.begin(), src.end(),
dst.begin(),
[] (double v)->(__uint8) {
return (__uint8)v;
});
... if you're on vc++10, define trivial std::unary_function converter otherwise. You could also try one of the selectors or projectors from <algorithm> , with the other overload of transform then.
Cheers,
Paul
|
|
|
|
|
I've got a DLL hook in place, it's all working fine, the hook is for a game, and it works in windowed mode, but not in fullscreen mode.
I'm using FindWindow to look for the window title, but I'm thinking it changes during fullscreen.
What I really need is the hooked .exe's ProcessId, for use with OpenProcess, so I can get the handle to use with WriteProcessMemory, etc,.
Can someone help me out here.
|
|
|
|
|
If the DLL is injected into the EXE you can use GetCurrentProcess to get the handle of the EXE.
|
|
|
|
|
Thank you, that did the trick.
(I feel dumb for not trying that earlier, I was thinking it would probably return the dll, since that's where I called it from, but upon further thought, I realize that the dll is actually part of the process once injected.)
|
|
|
|
|
Which is better writing my own custom Linked List class or using STL?
Which is better not just from the point of speed, but also memory usage?
|
|
|
|
|
I don't know the answer, however I'm rather pragmatic on such issues: what makes you think your implementation would be better in some way (speed, memory, whatever)?
|
|
|
|
|
|
That does not even start to look like the answer to my question.
If you think you can design and build a better linked list, and can afford to spend the time to do it right, then do it, debug it, test it, document it, and compare it to existing implementations.
|
|
|
|
|
I have done this where each node is an element but the forward and back 'pointers' are offsets from the base address to a block of memory, rather than individual 'nodes' allocated from the current process heap. If you put this into a custom Win32 Heap, then the entire list deletes almost instantly! I am not sure that is the case even if you feed the STL a custom allocator - it still asks for a node one at a time? Anyways, that was done years before STL existed.
|
|
|
|
|
I agree there can be circumstances where a specialized implementation (or even an entirely different data structure, e.g. some kind of tree) is (much) better; however the OP did not give any hint in that sense.
|
|
|
|