|
jamiehale wrote:
can I have two threads using PostMessage() into a windows message pump?
Yes. Just remember that thread can have its own message queue. Are your threads queue-less (worker threads) or do they have one (UI threads)?
Tomasz Sowinski -- http://www.shooltz.com
*** Vodka. Connecting people. ***
|
|
|
|
|
I'm trying to decide if I can use my main thread (dialog app) to process asynchronous messages from clients, or if I need to start another thread to handle them. I was curious as to whether or not it would be safe to have another thread posting messages to the main thread - or alternatively, several threads posting to a message queue in yet another thread.
I think, regardless, I'm going to start another thread and build my own message pump (custom, not windows) simply because of the nature of the app...
J
|
|
|
|
|
In
_ClRemoteButton p;
p.CreateDispatch("DllwithForm.Class1");
p.CheckingPB(CMHandle,0,500);
AfxMessageBox ("back from dll");
CheckingPB is a function in a dll and it Sendmessages (not Postmessages) say 100 times in a loop.
When does the messagebox fire? After the function returns? Or as soon as I have called
p.CheckingPB(CMHandle,0,500);
, the code advances to the messagebox? I dont have any threads or anything.
Will I get the 100 messages before the messagebox? I cant really tell in my sample and need to know for sure..
Thanks,
ns
|
|
|
|
|
You have coded:
p.CheckingPB(CMHandle,0,500);
AfxMessageBox ("back from dll");
So AfxMessageBox() is called after CheckingPB() has returned.
And as you have used SendMessage() your messages, you can be sure that they have been handled when the messagebox fires.
|
|
|
|
|
So I dont need to send a message from the dll saying its done! It'll do all its stuff , and then after that the code carries on. THis is good news!
Thanks,
ns
|
|
|
|
|
Correct.
However, if you'd used PostMessage , a hundred messages would be posted, the function would return, the message box would fire, and when Windows got a chance to (eventually) pump its message queue, the 100 posted messages would be handled.
So you're doing the right thing by using SendMessage .
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
My progressCtrl needs to be cleared or hidden away after its done. I dont see any function that will do it in that class. Also is it possible to send a message with Sendmessage that will clear the ctrl?
I am sending PBM_STEPIT messages from a dll, and am wondering how to notify the control that the operation is finished. I cant set the range before hand so it cycles through a few times. Any ideas on how one would notify it that the process in the remote dll is done ? Basically each time the dll function steps through a for loop, it sends off a PBM_STEPIT to the calling apps progressbar. At the end of the loop the progressbar needs to know all is done, and magically clear or vanish.
Appreciate any ideas..
Thanks,
ns
|
|
|
|
|
ns wrote:
I cant set the range before hand
If you can't know how long your task will take beforehand, maybe a CProgressCtrl is not the right control to display its working state? Would a flashing 'LED'-type button not be better to signal 'Process still running'?
ns wrote:
Any ideas on how one would notify it that the process in the remote dll is done
Your thread could send your CProgressCtrl -derived class a message (WM_APP+x or a Registered WM), on which it is set to 100%, a Timer is started and OnTimer disposes the CProgressCtrl .
|
|
|
|
|
Flashing button _ I've never seen that! So it toggles from red to grey or something?
Still trying to make the control clear when done. I'm also trying to absorb the timer idea - need to read about...
Thanks,
ns
|
|
|
|
|
ns wrote:
Flashing button _ I've never seen that! So it toggles from red to grey or something?
I have made this once - From my task, I sent a message whose handler simply did blit a gey and a blue bitmap alternating to the same position on the screen. When the task was completed, I blitted background color there.
You could easily spend any amount of time with improving and beautifying and things like that, but at that time I specifically did not want to have a button flashing beautiful, but to show progress by alternating colors.
|
|
|
|
|
Simply hide the progress control when it's no longer required.
GetDlgItem (IDC_ProgressCtrl)->ShowWindow (SW_HIDE);
Be sure to show it (use SW_SHOW ) just before you need it.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
That works! QUestion - we hide it but dont clear it. So how come when it SW_SHOWs again it looks clear? (My progress bar is rather swift (could nt figure out what to do to make it take time in the sendmessage loop). SO I am 99% sure that when the bar shows up again, it starts from scratch! WHat made it clear?
Thanks,
|
|
|
|
|
ns wrote:
we hide it but dont clear it.
Correct. To clear (i.e. reset) the progress control, you'd need to call SetPos (0) . The progress control doesn't automatically reset - your code must be causing that to happen.
ns wrote:
could nt figure out what to do to make it take time in the sendmessage loop
Aha! I use this trick:
CProgressCtrl* pProgCtrl = ...;
for (long nIndex=0; (nIndex < 100); nIndex++) {
doSomeWork();
pProgCtrl->SetPos (nIndex + 1);
MSG msg;
while (::PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE)) {
AfxGetThread()->PumpMessage();
}
Sleep (50);
}
If you use my TaskTimer[^] class, you can show your user the elasped and remaining times. Makes for good usability, but is certainly not necessary!
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I tried:
(((CMainFrame*)AfxGetMainWnd())->m_wndStatusBar.m_WzdProgressCtrl).ModifyStyle(WS_VISIBLE, SWP_HIDEWINDOW );
to get rid of my progressctrl or just clear it and it doesnt! WHat did I do wrong?
Thanks,
ns
|
|
|
|
|
ns wrote:
ModifyStyle(WS_VISIBLE, SWP_HIDEWINDOW );
Do this: ModifyStyle(WS_VISIBLE, 0); instead because you don't want to add a style, you just want to remove the WS_VISIBLE style.
_____________________
"So in the interests of survival, they trained themselves to be agreeing machines instead of thinking machines. All their minds had to do was to discover what other people were thinking, and then they thought that, too."
Breakfast of Champions, Kurt Vonnegut
|
|
|
|
|
Hmm...tried what you said. It didnt make it disappear. does the fact that the progressbar is in a status bar have anything to do with it?
Thanks,
ns
|
|
|
|
|
When compiling a DLL, a PDB file is generated to help debugging.
The PDB file path is hard coded in the DLL file (at the end of it).
PB: When the DLL file is moved in another directory, the PDB file which is loaded is always the old one.
Q: How to modify the project to not have this hard coded path or how to patch the DLL to modify this path ?
Thanks
|
|
|
|
|
Recompile the DLL project in his new location.
Pavel
Sonork 100.15206
|
|
|
|
|
Of course..., but I'm looking for a solution that doesn't need any compilation or link.
|
|
|
|
|
Did a quick search and found the following:
SymSetSearchPath
Check your MSDN docs...
|
|
|
|
|
Hi All,
I'm running the NetUserGetLocalGroup method.Based on the information I get about the groups a user belongs to I need to Set some settings using the method NetUserSetInfo.But I'm not able to run the NetUserSetInfo Method successfully.I'm getting the system error 2221 as the return value.Can anybody help me to know whys the error.
Thanks
Abhishek.
Learning is a never ending process of Life.
|
|
|
|
|
This error means "Username cannot be found". Does this help?
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
hello!
i make a vc++ programm with a mdi. everytime, when i start the programm a empty document is open. what must i change, that the empty document is not there at the beginning?
thanks
MFC is the best
|
|
|
|
|
Add the following in CYourApp::InitInstance.
...
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
if (CCommandLineInfo::FileNew == cmdInfo.m_nShellCommand)
{
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
}
...
Tomasz Sowinski -- http://www.shooltz.com
*** Vodka. Connecting people. ***
|
|
|
|
|
i'm sorry, it does not fold. it with you folded?
what can be the mistake?
|
|
|
|