Here is the way I pass it through the first function:
Code: Select all
th = new ThreadServer(WxMenuBar1);
Code: Select all
f->open_session_auto( WxMenuBar1);
Code: Select all
wxMenuBar* WxMenuBar1
Code: Select all
WxMenuBar1->EnableTop(1,true);
Code: Select all
th = new ThreadServer(WxMenuBar1);
Code: Select all
f->open_session_auto( WxMenuBar1);
Code: Select all
wxMenuBar* WxMenuBar1
Code: Select all
WxMenuBar1->EnableTop(1,true);
I'm not sure to understand. You mean that I should create a kind of virtual menu item and set an event on it? If it's the real meaning, I would have to create a custom event...and this does not resolve my problem, cause I have to treat the request in a thread. How could I send this event from the thread to the main api???Jorg wrote:I assume you are doing this in a different thread? This is not recommended. wxWidgets as many toolkits is not thread safe.
I would suggest create a mechanism where you post to an "non present" menu item, which ID you only handle in the event list but is never created. In that menu handler, update the thread status which reflects on the GUI.
- Jorgen
Code: Select all
EVT_MENU(ID_SOME_MENUITEM, wxSomeWindow::OnMenuItem)
Code: Select all
wxCommandEvent event;
event.SetId(ID_SOME_MENUITEM);
event.SetClientData(... /* ptr to some thread data */ ..);
wxPostEvent(mainForm, event);
You wrote "mainForm", what does it represent in fact? I know that wxPostEvent waits for a wxEvtHandler object in its first argument, but I'm lost, I don't know what I should write instead of mainForm.Jorg wrote:wxPostEvent(mainForm, event);
Code: Select all
BEGIN_EVENT_TABLE(newProgramFrame,wxFrame)
// ...
EVT_MENU(ID_SOME_MENUITEM, newProgramFrame::OnMenuItem)
// ...
END_EVENT_TABLE()
Code: Select all
#include "newProgramFrameApp.h"
#include "newProgramFrame.h"
IMPLEMENT_APP(newProgramFrameApp)
bool newProgramFrameApp::OnInit()
{
newProgramFrame *myFrame = new newProgramFrame(NULL);
SetTopWindow(myFrame);
myFrame->Show(TRUE);
return TRUE;
}
int newProgramFrameApp::OnExit()
{
return 0;
}
Code: Select all
th = new ThreadServer(this);
Code: Select all
wxString login = event.GetClientData();
Code: Select all
ThreadServer * OnClientConnect(wxSocketBase* sock);
Code: Select all
ThreadServer *newProgramFrame::OnClientConnect(wxSocketBase* sock)
{
//...some code
th = new ThreadServer(this);
//...some code
}
Code: Select all
ThreadServer::ThreadServer(newProgramFrame *myFrame ): wxThread()
{
this->myFrame=myFrame;
}
Code: Select all
event.SetId(ID_SOME_MENUITEM);
wxPostEvent(myFrame, event);