|
This however is a UI thread with a Message Pump as CasyncSOcket post notificatins via messages
is it SAFE for a message Pump Thread to Wait for event Notification ????
|
|
|
|
|
I see your point. Well you can use MsgWaitForMultipleObjects[^], but even easier would be to use a user defined message instead of an event. One message to "start" and one message to "stop".
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Thankx
to Start CAsynSocketWinthread I can use PostMessageThread
I have to investigate and see how this works
In the Context of a Class or CWnd/Cdialog
thankx for the suggestion I will do some investigation
|
|
|
|
|
Forgot that CWnd/CDialog I have use message maps
Again thankx let me inestigate
|
|
|
|
|
It's something I did once when confronted with a similar problem. The code in your thread should look something like this pseudocode
if PeekMessage == MY_STOP_MESSAGE then
if GetMessage != MY_RESUME_MESSAGE then repeat
See the documentation in MSDN about PeekMessage and GetMessage
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Hi,
Sorry about the Delay'ed reply I had to check out
MsgWaitForMultipleObjects
Since My Code is MFC using MESSAGE_MAPS
was wondering how to handle it
So...
I think I'll have to use the Overridable
CWnd/CDialog Windowproc
to get a first look at the messages before
they are dispatched to the message map
e.g
then if its a message I'll use Peekmessage to
Pull it off the queue
When I have both the Event set and the Message
I'll use the info pointed to by Lparm(which I
saved in some global) area to do my
processing
thankx
|
|
|
|
|
Actually if you use PostThreadMessage you don't need to use MsgWaitForMultipleObjects, as you'll be using messages *instead of* events (hence no need to use MsgWaitForMultipleObjects to wait for events).
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
excuse me as I am probably not understanding
First of I am waiting for a reply in a Cdialog??
MsgWaitForMultipleObjects seem to be a neat way to check on a event in a UI thread or in this case Cdialog
while keeping the message Pump moving
|
|
|
|
|
Well yeah, but since you're already using a message pump, why not send a message instead of raising an event?
i.e. (from your sender thread)
PostThreadMessage MY_STOP_MESSAGE
....
PostThreadMessage MY_RESUME_MESSAGE
instead of
SetEvent MY_STOP_EVENT
....
SetEvent MY_RESUME_EVENT
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Yeah I understand
My two inputs one is from named pipes which I wait Overlapped.hEvent
and the other CAsynSocket
but you right I can wait for Multiple messages
thankx
|
|
|
|
|
what is the meaning of that statement?
*((*ptr+1)+2)
if i can use double dimension array in the declaration like
a[2][2]={1,2,3,4,5}
{2,4,6,8,9}
|
|
|
|
|
kumarashoka wrote: what is the meaning of that statement?
*((*ptr+1)+2)
Syntax error.
Please provide right context.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
kumarashoka wrote: a[2][2]={1,2,3,4,5}
{2,4,6,8,9}
To make this compilable, you'll need to make a larger and correct the syntax errors:
int a[2][5] =
{
{1,2,3,4,5},
{2,4,6,8,9}
};
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I use a computer at work connecting to a group (local network). I wonder how can I disconnect it from the Internet by code?
Thank you masters!
|
|
|
|
|
Just search on google man
clue:- INetConnectionManager in vc++
More clue:-
u need three interface to do that
INetConnection* pConnect
INetConnectionManager* pMgr
IEnumNetConnection* pEnum
Using pMgr->EnumConnections( NCME_DEFAULT, &pEnum ) get all the connection
Loop it and check whether "Local Area Connection" or what ever connection you want to check
and call pConnect->Disconnect() to disconnect your NIC.
Величие не Бога может быть недооценена.
modified on Friday, August 7, 2009 12:20 AM
|
|
|
|
|
Hi All,
I am working on VC2008's MDI application with Ribbon bar and have to provide print preview.
Now, However VC2008 do have print preview, but the client requires it to look it like the VC6.0's Print preview capturing the entire main frame along with some certain buttons, all like VC6.0.
Can some body please help me on it
HARSH
Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.
|
|
|
|
|
I'm not sure if it'll do what you want, but try this:
Find OnFilePrintPreview in your CView-derived class and replace its code with this:
void CYourViewDerivedClass::OnFilePrintPreview()
{
CPrintPreviewState *pState= new CPrintPreviewState;
if (!DoPrintPreview(IDD_AFXBAR_RES_PRINT_PREVIEW, this, RUNTIME_CLASS(CPreviewView), pState))
{
TRACE0("Error: OnFilePrintPreview failed.\n");
AfxMessageBox(AFX_IDP_COMMAND_FAILURE);
delete pState;
}
}
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Hi sashoalm,
First thanks for replying...
I already know the way how to prepare print preview. But i guess i was not clear enough with my requirement.
My requirement is to show the preview capturing the entire main frame including all Menues, Panes, Views etc in VS 2008, how VS 6.0 does.
In VS2008, the preview comes like a view only and menues etc are remain enabled..
Please suggess something else may be that will help...
Thanks
HARSH
Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.
|
|
|
|
|
OK, CMainFrame should have CMainFrame::OnFilePrintPreview method, try to place the code I posted in CMainFrame::OnFilePrintPreview instead and tell me what happened.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Hi,
Thanks for quick reply.
sashoalm wrote: try to place the code I posted in CMainFrame::OnFilePrintPreview
There is an issue in doing as you are saying but there is no such function "DoPrintPreview" in class CMDIFrameWndEx from which the CmainFrame Class is derived..
However, i already have tried:
CView *pView = GetActiveFrame()->GetActiveView();
if(pView == NULL)
{
return;
}
CPrintPreviewState* pState = new CPrintPreviewState;
if (!pView->DoPrintPreview(AFX_IDD_PREVIEW_TOOLBAR, pView,
RUNTIME_CLASS(CPreviewView), pState))
{
delete pState;
pState = NULL;
}
But it prepares the preview in the same document only and not capturing the frame.
And this not what i wanted
Please suggess something else.
HARSH
Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.
|
|
|
|
|
What about minimizing the ribbon? Try minimizing the ribbon before print preview and see if you like it.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Hi Sashoalm,
sashoalm wrote: What about minimizing the ribbon? Try minimizing the ribbon before print preview and see if you like it.
It is not practically possible and good to hide all the ribbons, views and panes on Preview and restore them OnEndPreview since the are many in count..
Like in VC 6.0, i didn't needed to do any thing like that and the compiler was doing this for me, i want something like that.
Thanks
HARSH
Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.
|
|
|
|
|
Harsh Shankar wrote: It is not practically possible and good to hide all the ribbons, views and panes on Preview and restore them OnEndPreview since the are many in count
What do you mean by that? You right-click on the ribbon bar and there's "Minimize the ribbon" *by default* in every MFC9 program. Why didn't you use that? Just do it and see how it looks. Not programatically - as a user - click on "Minimize the ribbon".
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Hi sashoalam,
So do you think i should minimize all the Ribbons by some explicite call. But don't you think, making calls for hiding all the views, menues, tabs, Panes etc and maintaining its previous states is not really a good idea if you may have about 10 Ribbon-tabs, about 10-20 Panes and uncountable Views are possible.
Event on remembering the 6.0 days, you'll notice that we didn't have to do all those things by us and it was MFC's responsbility to do so.
i think must have understood my problem.
HARSH
Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.
|
|
|
|