Kirix Support Forums

Problems with wxAUI and IMPLEMENT_APP_NO_MAIN

Please post all general questions, comments, bug reports, and any other wxAUI feedback here.

Problems with wxAUI and IMPLEMENT_APP_NO_MAIN

Postby csh on Tue Feb 27, 2007 7:53 am

Hi,
I have encountered some oddities when using wxAUI along with IMPLEMENT_APP_NO_MAIN; for instance, panels can't be docked and undocked anymore. I'm using MSVC2005 and wxWidgets 2.8.0. Has anyone ever encountered these problems before? Is there any workaround?
The behaviour can be reproduced in the auidemo application by replacing lines 49 and 50 in auidemo.cpp:
Code: Select all
DECLARE_APP(MyApp)
IMPLEMENT_APP_NO_MAIN(MyApp)

and adding the following code at the very end of the file:
Code: Select all
#define IDC_TESTAPP 109
#define MAX_LOADSTRING 100

// Global Variables:
HINSTANCE hInst;   
TCHAR szTitle[MAX_LOADSTRING];   
TCHAR szWindowClass[MAX_LOADSTRING];

// Forward declaration:
BOOL InitInstance(HINSTANCE, int);

int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
   MSG msg;
   HACCEL hAccelTable;

   if (!InitInstance (hInstance, nCmdShow))
   {
      return FALSE;
   }

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

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

BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
    WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst);
    wxSetInstance(hInstance);
    wxApp::m_nCmdShow = nCmdShow;
    int argc = 0;
    wxChar **argv = NULL;
    wxEntryStart(argc, argv);
    if ( !wxTheApp || !wxTheApp->CallOnInit() )
        return FALSE;

    return TRUE;
}


Any help would be appreciated.
csh
Registered User
 
Posts: 2
Joined: Tue Feb 27, 2007 6:09 am

Postby Ben on Wed Feb 28, 2007 6:09 am

Hi there,

The short answer is I don't know. I'll have to try out your sample code.

My theory is that there is some code that wx's built-in main function is calling, like maybe InitCommonControls() or some kind of timer initialization that isn't happening. Whatever that call is, it appears to be necessary and is not present in your custom main function.

Best,
Ben
User avatar
Ben
Kirix Support Team
 
Posts: 522
Joined: Mon Dec 19, 2005 6:29 am

Re: Problems with wxAUI and IMPLEMENT_APP_NO_MAIN

Postby trs79 on Tue Jan 29, 2008 6:25 pm

I know this thread is old, but turns out it's because when you use IMPLEMENT_APP_NO_MAIN, no idle events are sent, and wxAUI uses idle events to check when dragging is finishied. I would love to see an alternate implementation that doesn't rely on that, like using mouse up button events instead. I've tried to add this myself without success. I ended up just manually sending idle events
trs79
Registered User
 
Posts: 1
Joined: Tue Jan 29, 2008 6:23 pm

Return to wxAUI Questions, Thoughts & Feedback