Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
#include "MessageBoxThread.h"
MessageBoxThread::MessageBoxThread(NfcUIConfirmProcessUC* dialogUC)
{
this->dialogUC = dialogUC;
}
MessageBoxThread::~MessageBoxThread(void)
{
}
void* MessageBoxThread::Entry()
{
this->dialogUC->Show(true);
return 0;
}
To quote from the wxThread docs:
GUI calls, such as those to a wxWindow or wxBitmap are explicitly not safe at all in secondary threads and could end your application prematurely. This is due to several reasons, including the underlying native API and the fact that wxThread does not run a GUI event loop similar to other APIs as MFC. [...] the recommended way is to simply process the GUI calls in the main thread through an event that is posted by wxQueueEvent()
So basically the best way to solve this problem is rather than calling Show to create an event (for example a wxThreadEvent) post it back to the dialog and then using an event macro or bind connect it to a dialog member which shows the dialog.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 months ago.
Improve this question
I'm making a right click menu in my application. And I want to check whether the menu is shown or not. But I read the Microsoft docs of CMenu and found that there is no way to make it. How to get the menu state, and is there any way to get the menu disappear event?
The system sends a WM_ENTERMENULOOP message to a menu's owner window whenever a menu is about to be shown, and a WM_EXITMENULOOP message after it has been dismissed.
Those messages map to the CWnd::OnEnterMenuLoop and CWnd::OnExitMenuLoop message handlers that your code can override to keep track of the menu state. The bIsTrackPopupMenu argument is set to TRUE for a popup menu.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
Recently I made a program by Qt(c++) to get screen resolution and show it by moving mouse. Currently, it works well but just on the MainWindow form;
How can I make it work when I move mouse on desktop also?
I Really appreciate you if you answer.;)
If you want to get mouse input outside of the widget then you have to call QWidget::grabMouse() and later QWidget::releaseMouse() when done. Bear in mind that it may not work on some operating systems or it may stop working when your widget (MainWindow on your case) loses focus. Also it may work worse with next update of operating system. That is because operating system vendors do not like spyware that spies mouse clicks or malware that locks whole desktop.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I am writing a program that firstly shows Java GUI using JNI and then calls Windows simple GUI.
IF I call Windows simple GUI without calling Java GUI, it shows on the top of other windows so I can see it directly right after it starts.
the problem is, if I call Windows simple GUI after calling JAVA GUI, it shows its windows simple GUI at bottom of other windows: other Windows just hide it.
Here is a picture, you cam see my simple Windows GUI has been hide by visual studio when it starts.
I am not sure I understood the question but I am going to try to answer anyway. What I understand is that you are launching 2 programs and you want to bring one of them to the front of the desktop.
I suppose that you are using CreateProcess to start the programs. There are flags that you can set in the STARTUPINFO structure (wShowWindow), so see if you can use that.
Otherwise you can try calling ShowWindow after launching both programs (and possibly waiting for the Java program to start). You will need to pass the window handle to this function.
You can obtain the window handle by calling EnumWindows, checking the executable file name for each window using GetWindowModuleFileName.
Pseudo code:
foreach window in EnumWindows()
if GetWindowModuleFileName(window) == "program.exe"
ShowWindow(window, ...)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I would like to bring your attention regarding a detail which might be ridiculous for advanced people in Qt" but not for newbies as me.
I would like to connect a pushButton to a signal/slot while the user didn't press on a specified pushButton B:
What I want to do is:
do
{
QObject::connect(pushButton_image, SIGNAL(clicked()), this, SLOT(image()))
}
while (// THE USER DIDN'T PRESS THE PUSHBUTTON B ...)
As soon as the user press the PUSHBUTTON B, I want to disconnect pushButton_image with its previous signal / slot.
Thanks!
Connect it once, out of that while.
That's wrong because:
You can connect a slot to a signal multiple times. But it will be called s many times as you connected it.
You won't get out of that while loop.
A slot is connected as long as it gets disconnected. Being connected Its more like an state that an active task.
To disconnect you use
QObject::disconnect
In slot call
QObject::disconnect(pushButton_image, SIGNAL(clicked()), this, SLOT(image()))
Done
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Qt - c++
Show message when user close program
Thanks
Most general is to connect the aboutToQuit signal to a slot -- but as the docs say
The signal is particularly useful if
your application has to do some
last-second cleanup. Note that no user
interaction is possible in this state.
so if you need to show your message in Qt (so the main event loop must still be running) this won't work. In that case, I'd connect lastWindowClosed (and maybe also set quitOnLastWindowClosed to false, depending on your exact needs). If your app also ends in other ways (buttons, menus, etc) you'll have to connect those too.
If your aim is just to display a message you can follow the answer from Alex Martelli.
Else if you need some sort of execution based on close, (such as asking the user about Do you want to save the changes? kinda thing), then handling the QCloseEvent* will do the trick.
In such case what I will do is that, extend QWidget class and override its
void QWidget::closeEvent ( QCloseEvent * event ) [virtual protected]
Under the definition of closeEvent ( QCloseEvent * event ), I will have my corresponding execution.
Hope it helps..