J'ai une classe. Le problème est maintenant, après quelques tentatives, je suis toujours dans une énorme erreur. Mon problème est que je ne sais pas comment déclarer correctement un nouvel objet pour cette classe, dans un autre fichier cpp. Je voulais appeler/déclencher les fonctions de cette classe RebarHandler à partir de mon autre fichier cpp. Je continue d'avoir des problèmes comme "utilisé sans être initialisé", "échec de l'assertion de débogage" et ainsi de suite.Besoin de savoir comment créer correctement un nouvel objet dans un autre fichier cpp
Dans l'autre fichier cpp, j'inclure le RebarHandler.h et a fait comme ceci:
CRebarHandler *test=NULL;
test->setButtonMenu2();
Lorsque la compilation, je ne donne aucune erreur. Mais, lors de l'exécution, il donne une erreur et mon crash IE. J'ai besoin d'aide.
Ci-dessous est la classe que je voulais dire:
#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();
};