Help: A wxDialog Dll Error

Questions about wxWidgets running on MS.NET, mono or Portable.NET ? Ask it here !
james.chengguangwang
Knows some wx things
Knows some wx things
Posts: 38
Joined: Wed Aug 02, 2006 4:59 am

Help: A wxDialog Dll Error

Postby james.chengguangwang » Tue Aug 08, 2006 5:25 am

Hi All,

I have written a demo program about the dll which encapsulates a subclass of wxDialog, and it is ok, but who I invoke the dll in a win32 application, it has a problem who I close the dialog, the functions is all right, can you help me to see what happens and how to fix it ? thanks for your correcting.

Platform: windows XP, wxwidgets 2.6.0, vs 2005

This is my Dll files:

Code: Select all

// wxDLL is a simple DLL which demonstrates how to use
// wxWindows in a DLL which is called from another
// application (not using wxWindows)
//
//
// Tony Edgecombe
// (C) 2004 Frogmore Computer Services
// www.frogmorecs.com
// Edited by upCASE

#pragma once

#include "wx/wx.h"

#include "windows.h"

#ifdef DLLFUNCTIONS_EXPORTS
#define DLLFUNCTIONS_API __declspec(dllexport)
#else
#define DLLFUNCTIONS_API __declspec(dllimport)
#endif

extern "C" DLLFUNCTIONS_API void DLLFunction(HWND);
extern "C" DLLFUNCTIONS_API void TestReport(HWND handle);
//extern "C" DLLFUNCTIONS_API void TestDialog(HWND handle);

class wxDLLApp : public wxApp
{
        bool OnInit();
        void OnButton(wxCommandEvent& evt);
        DECLARE_EVENT_TABLE()
};

/////////////// User Define Dialog ///////////////////////////////

class MLC3Dlg : public wxDialog
{
   public:
      MLC3Dlg(wxWindow *parent, wxWindowID id = 1,
         const wxString &title = wxT("MLC3"),
         const wxPoint& pos = wxDefaultPosition,
         const wxSize& size = wxDefaultSize,
         long style = wxDEFAULT_DIALOG_STYLE );
      virtual ~MLC3Dlg();
   
   public:
      //Do not add custom control declarations
      //wxDev-C++ will remove them. Add custom code after the block.
      ////GUI Control Declaration Start
      wxButton *WxButtonDllDialog;
      wxButton *wxBtSubmit;
      wxTextCtrl *wxEdMail;
      wxRadioButton *wxRbAcceptWithMail;
      wxRadioButton *wxRbAccept;
      wxRadioButton *wxRbDeny;
      ////GUI Control Declaration End
      
   public:
      //Note: if you receive any error with these enum IDs, then you need to
      //change your old form code that are based on the #define control IDs.
      //#defines may replace a numeric value for the enum names.
      //Try copy and pasting the below block in your old form header files.
      enum
      {
         ////GUI Enum Control ID Start
         ID_WXBUTTONDLLDIALOG = 1007,
         ID_WXBTSUBMIT = 1005,
         ID_WXEDIT_MAIL = 1004,
         ID_WXRBACCEPTWITHMAIL = 1003,
         ID_WXRBACCEPT = 1002,
         ID_WXRBDENY = 1001,
         ////GUI Enum Control ID End
         ID_DUMMY_VALUE_ //don't remove this value unless you have other enum values
      }; //End of Enum
   
   public:
      void MLC3DlgClose(wxCloseEvent& event);
      void CreateGUIControls(void);
      void wxBtSubmitClick(wxCommandEvent& event);
      void wxBtDllDialogClick(wxCommandEvent& event);
};



// wxDLL is a simple DLL which demonstrates how to use
// wxWindows in a DLL which is called from another
// application (not using wxWindows)

// Edited by upCASE

#include "wx/wx.h"

#include "wxDLL.h"
#include "wx/wxhtml.h"

// We use IMPLEMENT_APP_NO_MAIN so we can start the app from DllMain
// as we don't have a WinMain or main entry point
//
BEGIN_EVENT_TABLE(wxDLLApp, wxApp)
        EVT_BUTTON(123,wxDLLApp::OnButton)
      EVT_CLOSE(MLC3Dlg::MLC3DlgClose)
      EVT_BUTTON(MLC3Dlg::ID_WXBTSUBMIT,MLC3Dlg::wxBtSubmitClick)
      EVT_BUTTON(MLC3Dlg::ID_WXBTSUBMIT,MLC3Dlg::wxBtSubmitClick)
      EVT_BUTTON(MLC3Dlg::ID_WXBUTTONDLLDIALOG,MLC3Dlg::wxBtDllDialogClick)
END_EVENT_TABLE()

IMPLEMENT_APP_NO_MAIN(wxDLLApp)

BOOL APIENTRY DllMain( HANDLE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                                         )
{
        switch (ul_reason_for_call)
        {
                case DLL_PROCESS_ATTACH:
                {       //use wxInitialize() if you don't want GUI instead of the following 12 lines
                        wxSetInstance((HINSTANCE)hModule);
                        int argc = 0;
                        char **argv = NULL;
                        wxEntryStart(argc, argv);
                        if ( !wxTheApp || !wxTheApp->CallOnInit() )
                                return FALSE;
                }
                break;

                case DLL_THREAD_ATTACH:
                break;

                case DLL_THREAD_DETACH:
                break;

                case DLL_PROCESS_DETACH:
                 wxEntryCleanup(); //use wxUninitialize() if you don't want GUI
                break;
        }
    return TRUE;
}

// extern "C" so we don't need a DEF file

// This is the function to be called from the host app
extern "C" DLLFUNCTIONS_API void DLLFunction(HWND handle)
{
// Create a dummy wxWindow so we can use the HWND passed from the
// host application

        wxWindow win;
        win.SetHWND((WXHWND)handle);
        win.Enable(false);

        wxDialog dlg(&win, -1, wxT("wxDialog in DLL"), wxDefaultPosition, wxSize(150,150));
        wxButton b(&dlg, 123,wxT("Press me please"));
        dlg.ShowModal();

// Clean up else the caller can't use its window
        win.Enable(true);
        win.SetHWND(0);
}

extern "C" DLLFUNCTIONS_API void TestReport(HWND handle)
{
        wxWindow win;

        win.SetHWND((WXHWND)handle);
        win.Enable(false);

/*        wxDialog dlg(&win, wxID_ANY, wxString(_("About")), wxDefaultPosition, wxSize(400,180));
       
        wxHtmlWindow html1(&dlg,wxID_ANY, wxDefaultPosition, wxSize(380, 160), wxHW_SCROLLBAR_NEVER);
        html1.SetPage(wxT("<html><body><h1>Error</h1>Some error occurred )</body></hmtl>"));

        dlg.ShowModal();
*/
      MLC3Dlg dlg(&win, wxID_ANY, wxString(_("About")), wxDefaultPosition, wxSize(400,180));
      dlg.ShowModal();

        // Clean up else the caller can't use its window
        win.Enable(true);
        win.SetHWND(0);
}

bool wxDLLApp::OnInit()
{
        return true;
}
void wxDLLApp::OnButton(wxCommandEvent& evt)
{
        wxMessageBox(wxT("You really did it.... I don't believe it!"));
}

MLC3Dlg::MLC3Dlg(wxWindow *parent, wxWindowID id,
   const wxString &title, const wxPoint &position,
   const wxSize& size, long style)
   : wxDialog(parent, id, title, position, size, style)
{
    CreateGUIControls();
}

MLC3Dlg::~MLC3Dlg() {}

void MLC3Dlg::CreateGUIControls(void)
{
    //Do not add custom code here
   //wxDev-C++ designer will remove them.
   //Add the custom code before or after the blocks
   ////GUI Items Creation Start

   this->SetSize(8,8,299,222);
   this->SetTitle(wxT("MLC3"));
   this->Center();
   this->SetIcon(wxNullIcon);
   

   WxButtonDllDialog = new wxButton(this, ID_WXBUTTONDLLDIALOG, wxT("Load Dll Dialog"),
      wxPoint(70,140), wxSize(90,27), 0, wxDefaultValidator, wxT("WxButtonDllDialog"));

   wxBtSubmit = new wxButton(this, ID_WXBTSUBMIT, wxT("Submit"), wxPoint(168,139),
      wxSize(90,27), 0, wxDefaultValidator, wxT("wxBtSubmit"));

   wxEdMail = new wxTextCtrl(this, ID_WXEDIT_MAIL, wxT(""), wxPoint(62,108),
      wxSize(194,21), 0, wxDefaultValidator, wxT("wxEdMail"));

   wxRbAcceptWithMail = new wxRadioButton(this, ID_WXRBACCEPTWITHMAIL,
      wxT("Yes, I would like to participate & Autodesk may contact me"),
      wxPoint(62,62), wxSize(193,33), 0, wxDefaultValidator, wxT("wxRbAcceptWithMail"));

   wxRbAccept = new wxRadioButton(this, ID_WXRBACCEPT, wxT("Yes, I would like to participate"),
      wxPoint(61,39), wxSize(190,17), 0, wxDefaultValidator, wxT("wxRbAccept"));

   wxRbDeny = new wxRadioButton(this, ID_WXRBDENY, wxT("No, Thank You"),
      wxPoint(60,12), wxSize(113,17), 0, wxDefaultValidator, wxT("wxRbDeny"));
   ////GUI Items Creation End
}

void MLC3Dlg::MLC3DlgClose(wxCloseEvent& event)
{
    Destroy();
}
 

/*
 * wxBtSubmitClick
 */
void MLC3Dlg::wxBtSubmitClick(wxCommandEvent& event)
{
   // insert your code here
   wxMessageBox( wxT("You have pressed The Submit Button!") );
}

/*
 * wxBtDllDialogClick
 */
void MLC3Dlg::wxBtDllDialogClick(wxCommandEvent& event)
{
   // insert your code here
   wxMessageBox( wxT("You have pressed The DllDialog Button!") );
}


And the following is the EXE program using the dll:

Code: Select all

// EXE.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
#include "EXE.h"
#include <assert.h>


#define MAX_LOADSTRING 100

// Global Variables:
HINSTANCE hInst;                        // current instance
TCHAR szTitle[MAX_LOADSTRING];               // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING];         // the main window class name

// Forward declarations of functions included in this code module:
ATOM            MyRegisterClass(HINSTANCE hInstance);
BOOL            InitInstance(HINSTANCE, int);
LRESULT CALLBACK   WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK   About(HWND, UINT, WPARAM, LPARAM);
typedef void (*DLLFunctionPtr) (HWND);

int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
   UNREFERENCED_PARAMETER(hPrevInstance);
   UNREFERENCED_PARAMETER(lpCmdLine);

    // TODO: Place code here.
   MSG msg;
   HACCEL hAccelTable;

   // Initialize global strings
   LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
   LoadString(hInstance, IDC_EXE, szWindowClass, MAX_LOADSTRING);
   MyRegisterClass(hInstance);

   // Perform application initialization:
   if (!InitInstance (hInstance, nCmdShow))
   {
      return FALSE;
   }

   hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_EXE));

   // Main message loop:
   while (GetMessage(&msg, NULL, 0, 0))
   {
      if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
      {
         TranslateMessage(&msg);
         DispatchMessage(&msg);
      }
   }

   return (int) msg.wParam;
}



//
//  FUNCTION: MyRegisterClass()
//
//  PURPOSE: Registers the window class.
//
//  COMMENTS:
//
//    This function and its usage are only necessary if you want this code
//    to be compatible with Win32 systems prior to the 'RegisterClassEx'
//    function that was added to Windows 95. It is important to call this function
//    so that the application will get 'well formed' small icons associated
//    with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
   WNDCLASSEX wcex;

   wcex.cbSize = sizeof(WNDCLASSEX);

   wcex.style         = CS_HREDRAW | CS_VREDRAW;
   wcex.lpfnWndProc   = WndProc;
   wcex.cbClsExtra      = 0;
   wcex.cbWndExtra      = 0;
   wcex.hInstance      = hInstance;
   wcex.hIcon         = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_EXE));
   wcex.hCursor      = LoadCursor(NULL, IDC_ARROW);
   wcex.hbrBackground   = (HBRUSH)(COLOR_WINDOW+1);
   wcex.lpszMenuName   = MAKEINTRESOURCE(IDC_EXE);
   wcex.lpszClassName   = szWindowClass;
   wcex.hIconSm      = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));

   return RegisterClassEx(&wcex);
}

//
//   FUNCTION: InitInstance(HINSTANCE, int)
//
//   PURPOSE: Saves instance handle and creates main window
//
//   COMMENTS:
//
//        In this function, we save the instance handle in a global variable and
//        create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
   HWND hWnd;

   hInst = hInstance; // Store instance handle in our global variable

   hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
      CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

   if (!hWnd)
   {
      return FALSE;
   }

   ShowWindow(hWnd, nCmdShow);
   UpdateWindow(hWnd);

   return TRUE;
}

//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND   - process the application menu
//  WM_PAINT   - Paint the main window
//  WM_DESTROY   - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
   int wmId, wmEvent;
   PAINTSTRUCT ps;
   HDC hdc;

   switch (message)
   {
   case WM_COMMAND:
      wmId    = LOWORD(wParam);
      wmEvent = HIWORD(wParam);
      // Parse the menu selections:
      switch (wmId)
      {
      case IDM_ABOUT:
         DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
         break;
      case IDM_EXIT:
         DestroyWindow(hWnd);
         break;
      default:
         return DefWindowProc(hWnd, message, wParam, lParam);
      }
      break;
   case WM_PAINT:
      hdc = BeginPaint(hWnd, &ps);
      // TODO: Add any drawing code here...
      EndPaint(hWnd, &ps);
      break;
   case WM_DESTROY:
      PostQuitMessage(0);
      break;

   case WM_LBUTTONUP:
          {
                // Load up the DLL and call DLLFunction(
            HMODULE hModule = LoadLibrary(_TEXT("TestDll.dll"));
            //assert(hModule);
            DLLFunctionPtr pProc = (DLLFunctionPtr)GetProcAddress(hModule, "DLLFunction");
            assert(pProc);
            (pProc)(hWnd);
            FreeLibrary(hModule);
          }
          break;

   case WM_RBUTTONUP:
          {
                // Load up the DLL and call DLLFunction(
                HMODULE hModule = LoadLibrary(_TEXT("TestDll.dll"));
                assert(hModule);
                DLLFunctionPtr pProc = (DLLFunctionPtr)GetProcAddress(hModule, "TestReport");
                assert(pProc);
                (pProc)(hWnd);
                FreeLibrary(hModule);
          }
          break;


   default:
      return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}

// Message handler for about box.
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
   UNREFERENCED_PARAMETER(lParam);
   switch (message)
   {
   case WM_INITDIALOG:
      return (INT_PTR)TRUE;

   case WM_COMMAND:
      if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
      {
         EndDialog(hDlg, LOWORD(wParam));
         return (INT_PTR)TRUE;
      }
      break;
   }
   return (INT_PTR)FALSE;
}

How can I do to solve that question? thanks.

james.chengguangwang
Knows some wx things
Knows some wx things
Posts: 38
Joined: Wed Aug 02, 2006 4:59 am

Postby james.chengguangwang » Tue Aug 08, 2006 9:19 am

And when I close the dialog, it has some problems at the line:

Code: Select all

FreeLibrary(hModule); 


And the messagebox display the following text:

Windows has triggered a breakpoint in EXE.exe.

This may be due to a corruption of the heap, and indicates a bug in EXE.exe or any of the DLLs it has loaded.

The output window may have more diagnostic information


I don't know why, could you help me of it ?

upCASE
Site Admin
Site Admin
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Postby upCASE » Tue Aug 08, 2006 9:31 am

Hi!
I just tried your DLL code with my loader app. It works just fine for me and there's no bug in it.

Could you:
1. Post the header file for your caller app.
2. Specify what version of wxWidgets you use. Please tell us if it is a static/DLL build, linked with the DLL version of the C-runtime or statically linked with the C-runtime.
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda

james.chengguangwang
Knows some wx things
Knows some wx things
Posts: 38
Joined: Wed Aug 02, 2006 4:59 am

Topic review

Postby james.chengguangwang » Tue Aug 08, 2006 9:52 am

Hi upCASE,

And this is the EXE.H file:

Code: Select all

#pragma once

#include "resource.h"


And this is the Resource.H file:

Code: Select all

//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by EXE.rc
//

#define IDS_APP_TITLE         103

#define IDR_MAINFRAME         128
#define IDD_EXE_DIALOG   102
#define IDD_ABOUTBOX         103
#define IDM_ABOUT            104
#define IDM_EXIT            105
#define IDI_EXE         107
#define IDI_SMALL            108
#define IDC_EXE         109
#define IDC_MYICON            2
#ifndef IDC_STATIC
#define IDC_STATIC            -1
#endif
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS

#define _APS_NO_MFC               130
#define _APS_NEXT_RESOURCE_VALUE   129
#define _APS_NEXT_COMMAND_VALUE      32771
#define _APS_NEXT_CONTROL_VALUE      1000
#define _APS_NEXT_SYMED_VALUE      110
#endif
#endif


And this is the stdafx.H file:

Code: Select all

// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#pragma once

// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER            // Allow use of features specific to Windows XP or later.
#define WINVER 0x0501      // Change this to the appropriate value to target other versions of Windows.
#endif

#ifndef _WIN32_WINNT      // Allow use of features specific to Windows XP or later.                   
#define _WIN32_WINNT 0x0501   // Change this to the appropriate value to target other versions of Windows.
#endif                  

#ifndef _WIN32_WINDOWS      // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif

#ifndef _WIN32_IE         // Allow use of features specific to IE 6.0 or later.
#define _WIN32_IE 0x0600   // Change this to the appropriate value to target other versions of IE.
#endif

#define WIN32_LEAN_AND_MEAN      // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>

// C RunTime Header Files
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>


// TODO: reference additional headers your program requires here


And this is the stdafx.cpp file:

Code: Select all

// stdafx.cpp : source file that includes just the standard includes
// EXE.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information

#include "stdafx.h"

// TODO: reference any additional headers you need in STDAFX.H
// and not in this file


That's all, thank you for your helping! :) [/code]

james.chengguangwang
Knows some wx things
Knows some wx things
Posts: 38
Joined: Wed Aug 02, 2006 4:59 am

Topic review

Postby james.chengguangwang » Tue Aug 08, 2006 10:39 am

Hi upCASE,

it is a static build, and the msvcrt version is
7.0.2600.2180 (xpsp_sp2_rtm.040803-2158)

thanks
james

upCASE
Site Admin
Site Admin
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Re: Topic review

Postby upCASE » Tue Aug 08, 2006 10:44 am

james.chengguangwang wrote: it is a static build, and the msvcrt version is
7.0.2600.2180 (xpsp_sp2_rtm.040803-2158)

Did you link with the DLL or static version of the runtime?
Should be (in VC) under project options, c/c++, codegeneration. Does it say "Multithreaded /MT" or "Multithreaded-DLL /MD"?
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda

james.chengguangwang
Knows some wx things
Knows some wx things
Posts: 38
Joined: Wed Aug 02, 2006 4:59 am

Postby james.chengguangwang » Tue Aug 08, 2006 10:48 am

Hi upCASE,

Both the EXE and the Dll program are Multithreaded /MT, by the way, do you have a msn account? if you can tell me, I will really appreciate you!

thanks
James

User avatar
T-Rex
Moderator
Moderator
Posts: 1168
Joined: Sat Oct 23, 2004 9:58 am
Location: Zaporizhzhya, Ukraine
Contact:

Postby T-Rex » Tue Aug 15, 2006 12:12 am

Hello.

upCASE, I have the same problem.
I attached the full source code of a project (wxWidgets-2.7.0) which creates some GUI from plugins. See SampleDockPlugin project and wxID_OPEN event handler. The application crashes on Debug build (and does not respond to any user actions) after wxFileDialog::ShowModal is finished.

Also a small notice for using GUI created from plugins. It seems that GUI, controls created from plugins, work correctly only if wxWidgets is built as DLLs (I tested the source code with all possible configurations but managed how to make it work only with DLL build). However I still get some memory leaks in Debug mode (I can assume that they appear in Release build but debugger does not show them).

So, please, upCASE, see the source code below and tell me if you have any ideas. I think that the any information you have will be helpful for all developers here.

The archive contains VC++ 8.0 solution
Build configurations Debug DLL and Release DLL are for wxWidgets built as DLLs
Build configurations Debug and Release are for wxWidgets built as static libraries
PluggableGUI - plugin hosting application
SampleTabPlugin - plugin which creates a wxNotebook tab in hosting application
SampleDockPlugin - plugin which creates floating window with wxAUI

http://rapidshare.de/files/29427010/Plu ... I.rar.html

Regards,
T-Rex

upCASE
Site Admin
Site Admin
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Postby upCASE » Tue Aug 15, 2006 12:14 pm

Hi!
This may take a while...
I just had a look at the sources and I'll try to convert things in order to get it working.

BTW: Using a DLL build of wxWidgets would simplify compilation and usage a lot. But it's not the only way to get GUI controls working. I'll see if I can come up with a solution using a static build.
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda

upCASE
Site Admin
Site Admin
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Postby upCASE » Tue Aug 15, 2006 12:54 pm

Hi!
I'm afraid I won't find the time to look at this today. Maybe I can check tomorrow.

In the meantime I'd like to point you to a small example that I did a while ago, based on some other code I can't remember where I got it from.
It loads a simple plugin to a tab page like you do. Anyway, both, host and plugin, are compiled using a static wxWidgets library.
http://www.upcase.de/stuff/wxPlugin.zip
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda

User avatar
T-Rex
Moderator
Moderator
Posts: 1168
Joined: Sat Oct 23, 2004 9:58 am
Location: Zaporizhzhya, Ukraine
Contact:

Postby T-Rex » Tue Aug 15, 2006 2:37 pm

Thank you for your answer.

upCASE, I have already sent you an e-mail regarding your sample. Maybe you missed it.
---
It also has a bug
GUI control created from first loaded plugin does not handle size and paint events but all controls loaded from second, third and next plugins work perfectly. I'll check it once more with wxWidgets-2.7.0 but I think that the problem was not fixed since I'm using the source code based on your sample.

upCASE
Site Admin
Site Admin
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Postby upCASE » Wed Aug 16, 2006 7:37 am

T-Rex wrote:upCASE, I have already sent you an e-mail regarding your sample. Maybe you missed it.

Hmm. I never got one. Maybe I'm wrong and I deleted it by mistake...

T-Rex wrote:It also has a bug
GUI control created from first loaded plugin does not handle size and paint events but all controls loaded from second, third and next plugins work perfectly. I'll check it once more with wxWidgets-2.7.0 but I think that the problem was not fixed since I'm using the source code based on your sample.

You're right. I'll investigate this issue and maybe have some time today and try your code.
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda

User avatar
T-Rex
Moderator
Moderator
Posts: 1168
Joined: Sat Oct 23, 2004 9:58 am
Location: Zaporizhzhya, Ukraine
Contact:

Postby T-Rex » Thu Aug 24, 2006 3:48 pm

Hello.
upCASE, do you have any news/info regarding this topic?

upCASE
Site Admin
Site Admin
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Postby upCASE » Fri Aug 25, 2006 6:32 am

Hi!
To be honest I didn't have much time to investigate.
Things are a bit busy at my end. However I compiled the sources and had a look at them.

The problem I haver is that the plugin is loaded, but I never see it, because after loading it the app exits (not crashes). I saw that you never Detach the plugin which would be a problem in my case. I didn't have a chance to fix the error in my other example, allthough I really don't get why it doesn't work for the first but all following plugins. I'll have to check if there might be some issue using wxNotebook.

Anyway: I haven't forgotten this. I'd really like to investigate that as soon as time becomes available.
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda

User avatar
T-Rex
Moderator
Moderator
Posts: 1168
Joined: Sat Oct 23, 2004 9:58 am
Location: Zaporizhzhya, Ukraine
Contact:

Postby T-Rex » Fri Aug 25, 2006 7:34 am

OK, I understand :)

I'll have to check if there might be some issue using wxNotebook

The problem should not be wxNotebook-related since those window which I place to wxAUI layout does not work also (you can just delete the plugin DLL which places the tab to wxNotebook and see what happens).
I don't detach the plugin because it should be unloaded after the main frame was destroyed (maybe I missed something and I have to unload it manually but I don't get memory leaks report from Debugger and as far as I remember, wxDynamicLibrary unloads itself in its destructor (but I'll check it once more)... Also my PluginManager class deletes the plugin in its destructor and unloads itself.

Regards,
T-Rex


Return to “wx.NET”

Who is online

Users browsing this forum: No registered users and 2 guests