ERROR : FAILED TO REGISTER WINDOW CLASS. Topic is solved

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
Harsh
Experienced Solver
Experienced Solver
Posts: 70
Joined: Tue Apr 13, 2021 5:03 am

ERROR : FAILED TO REGISTER WINDOW CLASS.

Post by Harsh »

I have created DLL for MyFrame.cpp and MyPanel.cpp
I have just added one more string variable in MyFrame and it is giving this error on execution.
I have checked for variable naming in both files but no match was found.
How can I solve this error?

Code: Select all

#ifndef MYFRAME_H
#define MYFRAME_H
#include<wx/frame.h>
#include<sqlite3.h>

#ifdef MAKEDLL//Use it while creating object file like -c DLLClass.cpp -DMAKEDLL 
	#define EXPORT __declspec(dllexport)
#else
	#define EXPORT __declspec(dllimport)
#endif

class EXPORT MyFrame:public wxFrame{
    public:
        MyFrame();

	wxString Name="Student1", Address="India";
        wxDateTime dt=wxDateTime::Today();
};
#endif
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: ERROR : FAILED TO REGISTER WINDOW CLASS.

Post by ONEEYEMAN »

Hi,
I presume you are working with MSVC.
What version of wx do you use?

And what is the full build log?

And can you post the source code for your DLL?

Thank you.
User avatar
doublemax
Moderator
Moderator
Posts: 19158
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: ERROR : FAILED TO REGISTER WINDOW CLASS.

Post by doublemax »

That's an error that appears at runtime, not compile time?

viewtopic.php?p=165281&sid=7874805c74cc ... 11#p165281
Use the source, Luke!
Harsh
Experienced Solver
Experienced Solver
Posts: 70
Joined: Tue Apr 13, 2021 5:03 am

Re: ERROR : FAILED TO REGISTER WINDOW CLASS.

Post by Harsh »

ONEEYEMAN wrote: Sat Aug 14, 2021 11:41 pm Hi,
I presume you are working with MSVC.
What version of wx do you use?

And what is the full build log?

And can you post the source code for your DLL?

Thank you.
1. Compiler : MinGW 8.1
2. Do not know what is 'Full Build Log'.
But here the commands I used to create DLL and EXE.
I. Create Object file with -c :
g++ ".\Source\*.cpp" -c -DMAKEDLL -DWXUSINGDLL -I ".\Include" -I "C:\WxAPI\include" -I "C:\WxAPI\lib\gcc810_x64_dll\mswu" -L "C:\WxAPI\lib\gcc810_x64_dll" -l wxbase31u -l wxmsw31u_core

II. Create DLL :
g++ -shared -o UI.dll *.o -Wl,--out-implib,libUI.a -I ".\Include" -I "C:\WxAPI\include" -I "C:\WxAPI\lib\gcc810_x64_dll\mswu" -L "C:\WxAPI\lib\gcc810_x64_dll" -l wxbase31u -l wxmsw31u_core sqlite3.dll

III. Crete EXE :
g++ MyApp.cpp -o MyApp.exe -I ".\Include" -I "C:\WxAPI\include" -I "C:\WxAPI\lib\gcc810_x64_dll\mswu" -L "C:\WxAPI\lib\gcc810_x64_dll" -l wxbase31u -l wxmsw31u_core UI.dll

3. wxWidgets Version : 3.1.5

4. Here is header file of MyPanel. Cannot give source code I want to commercialize the app.

Code: Select all

#ifndef MYPANEL_H
#define MYPANEL_H

#ifdef MAKEDLL//Use it while creating object file like -c DLLClass.cpp -DMAKEDLL 
	#define EXPORT __declspec(dllexport)
#else
	#define EXPORT __declspec(dllimport)
#endif

#include<wx/frame.h>
#include<wx/panel.h>
#include<wx/stattext.h>
#include<wx/textctrl.h>
#include<wx/button.h>
#include<wx/scrolwin.h>
#include<wx/sizer.h>
#include<wx/regex.h>
#include<wx/arrstr.h>
#include<wx/popupwin.h>
#include<sqlite3.h>
#include<wx/Dialog.h>
#include<wx/bmpbuttn.h>
#include<wx/file.h>
#include"MyFrame.h"

class EXPORT MyPanel:public wxPanel{
    public:
        MyPanel(MyFrame*);
        char ITEM=1;
        wxArrayString listData;

    private:
        MyFrame* frame;
        wxWindow *win;
        
        wxPanel *p,*panel;
        wxScrolledWindow *sw;
        wxStaticText *st;
        wxTextCtrl *txt,*txt1;
        wxRect rect;
        wxRegEx *regX;
        sqlite3 *db;
        wxButton *btn;
        wxBitmapButton *bmb;
        double i=0,j=0,k=0,m=0;
        wxBoxSizer *vbox,*vbox1,*hbox;
        wxPopupWindow *pop;
        wxDialog *dlg;
        int f1=0,f2=0;
        bool SAVED=0,NonEditable=0;
        wxColour col1,col2;
        wxFile *file;
        wxDateTime now;
        wxString str,value;
};
5. I am using MyFrame class public variables to share data between two wxPanels, which are children of MyFrame.
6. I am using MyFrame inside MyPanel and MyPanel Inside MyFrame. Is it causing the problem?
Harsh
Experienced Solver
Experienced Solver
Posts: 70
Joined: Tue Apr 13, 2021 5:03 am

Re: ERROR : FAILED TO REGISTER WINDOW CLASS.

Post by Harsh »

doublemax wrote: Sun Aug 15, 2021 12:05 am That's an error that appears at runtime, not compile time?

viewtopic.php?p=165281&sid=7874805c74cc ... 11#p165281
Yes, you are right. It is giving Error MessageBox after execution.
But I am using command line to use DLL and not windows.h to import DLLs.
As I mentioned in the reply above. Please consider them.
stahta01
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 550
Joined: Fri Nov 03, 2006 2:00 pm

Re: ERROR : FAILED TO REGISTER WINDOW CLASS.

Post by stahta01 »

Code: Select all

III. Crete EXE :
g++ MyApp.cpp -o MyApp.exe -I ".\Include" -I "C:\WxAPI\include" -I "C:\WxAPI\lib\gcc810_x64_dll\mswu" -L "C:\WxAPI\lib\gcc810_x64_dll" -l wxbase31u -l wxmsw31u_core UI.dll
You failed to define WXUSINGDLL.

Code: Select all

-DWXUSINGDLL
This may have resulted in static libs being used in step III
Me, I would have guessed an linker error would have happen; but, I do *not* mix compiling and linking; so, I have no experience with the types of errors that can happen.

Tim S.
Harsh
Experienced Solver
Experienced Solver
Posts: 70
Joined: Tue Apr 13, 2021 5:03 am

Re: ERROR : FAILED TO REGISTER WINDOW CLASS.

Post by Harsh »

You are right. I forgot to run that last command.

1. I made changes to MyFrame.h
2. Compiled and exported it to DLL.
3. But I was also using MyFrame.h in MyApp.h which is in executable which was not compiled again after changes made in MyFrame.h
4. There was the mismatch between MyFrame.h in DLL and MyFrame.h in EXE, which was causing 'Error : Class Was Not Registered.'
Post Reply