Need to know how to properly create a new object in another cpp file
Posted
by karikari
on Stack Overflow
See other posts from Stack Overflow
or by karikari
Published on 2010-05-31T10:53:28Z
Indexed on
2010/05/31
11:23 UTC
Read the original article
Hit count: 252
visual-c++
I have a class. The problem now is, after a few attempt, I'm still in huge error. My problem is I don't know how to properly declare a new object for this class, inside another cpp file. I wanted to call/trigger the functions from this RebarHandler class from my other cpp file. I keep on getting problems like, 'used without being initialized', 'debug assertion failed' and so on.
In the other cpp file, I include the RebarHandler.h and did like this:
CRebarHandler *test=NULL;
test->setButtonMenu2();
When compile, I does not give any error. But, when run time, it gives error and my IE crash. I need help.
Below is the class I meant:
#pragma once
class CIEWindow;
class CRebarHandler : public CWindowImpl<CRebarHandler>{
public:
CRebarHandler(HWND hWndToolbar, CIEWindow *ieWindow);
CRebarHandler(){};
~CRebarHandler();
BEGIN_MSG_MAP(CRebarHandler)
NOTIFY_CODE_HANDLER(TBN_DROPDOWN, onNotifyDropDown)
NOTIFY_CODE_HANDLER(TBN_TOOLBARCHANGE, onNotifyToolbarChange)
NOTIFY_CODE_HANDLER(NM_CUSTOMDRAW, onNotifyCustomDraw)
NOTIFY_CODE_HANDLER(TBN_ENDADJUST, onNotifyEndAdjust)
MESSAGE_HANDLER(WM_SETREDRAW, onSetRedraw)
END_MSG_MAP()
// message handlers
LRESULT onNotifyDropDown(WPARAM wParam, LPNMHDR pNMHDR, BOOL& bHandled);
LRESULT onNotifyToolbarChange(WPARAM wParam, LPNMHDR pNMHDR, BOOL& bHandled);
LRESULT onNotifyCustomDraw(WPARAM wParam, LPNMHDR pNMHDR, BOOL& bHandled);
LRESULT onNotifyEndAdjust(WPARAM wParam, LPNMHDR pNMHDR, BOOL& bHandled);
LRESULT onSetRedraw(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
// manage the subclassing of the IE rebar
void subclass();
void unsubclass();
void handleSettings();
void setButtonMenu2();
bool findButton(HWND hWndToolbar);
private:
// handles to the various things
HWND m_hWnd;
HWND m_hWndToolbar, m_hWndRebar, m_hWndTooltip;
HMENU m_hMenu;
int m_buttonID;
int m_ieVer;
CIEWindow *m_ieWindow;
// toolbar finding functions
void scanForToolbarSlow();
void getRebarHWND();
void setButtonMenu();
};
© Stack Overflow or respective owner