Re: user defined WM_ question: update
Stoyan Damov <[email protected]>
| Newsgroups | gmane.comp.windows.off-topic |
|---|---|
| Message-ID | <[email protected]> |
I'm sorry, how did you come up w/ these INTERNET_STATE_CONNECTED, etc. masks? The function's test flags are: INTERNET_CONNECTION_CONFIGURED INTERNET_CONNECTION_LAN INTERNET_CONNECTION_MODEM INTERNET_CONNECTION_MODEM_BUSY INTERNET_CONNECTION_OFFLINE INTERNET_CONNECTION_PROXY On Wed, Aug 26, 2009 at 11:27 PM, Eric Strain<eric_strain1-/[email protected]> wrote: > > > Nope, same objective, I was just trying to re-word the help request. I wrote > a test app that implements InternetGetConnectedState( ) and even on a > machine with an active internet connection, such as this one, I get > INTERNET_STATE_DISCONNECTED as the return and that of course fires my > message box stating that fact. I don't know how much yahoo will mangle my > code but what I am using is pasted below. It is inside an OnClicked( ) > handler attached to a UI button on an MFC Dialog app. > > //start code > > BOOL bConnected; > DWORD dwFlags; > > bConnected = InternetGetConnectedState(&dwFlags, 0); > if(bConnected) > { > if(dwFlags & INTERNET_STATE_CONNECTED) > { > bConnected = TRUE; > MessageBox("Network Is Connected...","Network Connected",MB_OK); > } > else if(dwFlags & INTERNET_STATE_DISCONNECTED) //this keeps firing > even if > > { > //connected to internet > bConnected = FALSE; > MessageBox("Network Disconnected...","Network Not > Connected",MB_OK); > } > else if(dwFlags & INTERNET_STATE_DISCONNECTED_BY_USER) > { > bConnected = FALSE; > MessageBox("Network Disconnected By User Request...","Network > Not Connected",MB_OK); > } > else if(dwFlags & INTERNET_STATE_IDLE) > { > bConnected = TRUE; > MessageBox("Network State Idle...","Network Not Busy",MB_OK); > } > else if(dwFlags & INTERNET_STATE_BUSY) > { > bConnected = TRUE; > MessageBox("Network Busy: Wininet requests ...","Network > Busy",MB_OK); > } > else > { > //empty for now > } > } > else > { > MessageBox("Network Not Connected...","Network Failure", MB_OK); > } > > > //end code > > As a side note, I'm still trying to figure out how to get a WM_USER event > to fire automatically. Any ideas? > > -Eric > > --- On Tue, 8/25/09, Richard Howells <[email protected]> wrote: > > From: Richard Howells <[email protected]> > Subject: RE: [OT] user defined WM_ question: update > To: [email protected] > Date: Tuesday, August 25, 2009, 3:57 PM > > > > Hey – did you change your objective? > > Original “event that I need to trap is a network failure of any kind”, > > Recent “network has limited or no connectivity” > > > > Network.IsConnected does call InternetGetConnectedState (not the Ex version) > but it does a whole stack of other stuff FIRST. > > > > Cheers, > > > > Richard > > richard-yP/[email protected] > > www.dynamisys.co.uk > > L: (+44) (0)1793 731225 > > M: (+44) (0)7732 971786 > > > > Dynamisys Ltd is registered, No 4152561, in the UK > > > > From: [email protected] > [mailto:[email protected]] On Behalf Of Eric Strain > Sent: 25 August 2009 23:49 > To: [email protected] > Subject: Re: [OT] user defined WM_ question: update > > > > > > I looked at that function and it looks like that might do the trick. I'll > have to write a test app and test it first but it looks promising. Thanks. > > -Eric > > --- On Tue, 8/25/09, Stoyan Damov <[email protected]> wrote: > > From: Stoyan Damov <[email protected]> > Subject: Re: [OT] user defined WM_ question: update > To: [email protected] > Date: Tuesday, August 25, 2009, 3:26 PM > > You could poll the interfaces in interest by calling > InternetGetConnectedStateEx, or harness your Google skills ;) > > On Wed, Aug 26, 2009 at 1:23 AM, Eric Strain<eric_strain1-/[email protected]> wrote: >> >> >> primarily I am trying to duplicate the functionality in windows that >> notifies the user when the network has limited or no connectivity. I want >> my app to know when the network has limited or no connectivity. Any idea >> how >> windows detects that condition? >> >> -Eric >> >> --- On Tue, 8/25/09, Stoyan Damov <[email protected]> wrote: >> >> From: Stoyan Damov <[email protected]> >> Subject: Re: [OT] user defined WM_ question: update >> To: [email protected] >> Date: Tuesday, August 25, 2009, 2:52 PM >> >> You *can't* possibly be thinking that every Windows machine >> continuously polls all machines on the network to detect if any of >> them is down. >> If that's what you're trying to accomplish, develop an app which >> multicasts heartbeats on a configurable time interval and run it on >> all machines. Then, on the machine on which you'd like to detect >> outages, create and run an app which listens for such heartbeats, >> collects all ips from the heartbeats, and if it detects that an ip >> hadn't sent a heartbeat in some time interval it notifies the UI. >> >> Anything "simpler" sounds like "I need a Delphi component which can >> put a lion in a cage which I can drop on my form"... >> >> Cheers >> >> On Wed, Aug 26, 2009 at 12:41 AM, Eric Strain<eric_strain1-/[email protected]> >> wrote: >>> >>> >>> Hi Curt, >>> Thanks for the reply. What I am trying to do is have my application >>> automatically know as soon as any network failure of any kind occurs. >>> This >>> includes anything from someone unplugging the network cable, to a server >>> on >>> the network going down for some reason. I'm using MFC with VC6.0 >>> Professional IDE on WinXP. I'm hoping there is an API available and that >>> I >>> don't have to resort to .NET to accomplish what I want. Any ideas? >>> >>> -Eric >>> >>> --- On Mon, 8/24/09, Curt Hagenlocher <[email protected]> wrote: >>> >>> From: Curt Hagenlocher <[email protected]> >>> Subject: Re: [OT] user defined WM_ question: update >>> To: [email protected] >>> Date: Monday, August 24, 2009, 4:24 PM >>> >>> >>> >>> I imagine you still need some kind of listener for the "targeted event". >>> Your listener could then use PostMessage(WM_MYEVENT, 0, 0) to tell the UI >>> thread that the event has happened. You haven't provided any specific >>> information about the "targeted event", though -- for all I know, it's >>> got >>> a >>> specialized API to do exactly what you want. >>> On Mon, Aug 24, 2009 at 2:00 PM, Eric Strain <eric_strain1-/[email protected]> >>> wrote: >>>> >>>> >>>> OK, I got the WM_USER code to work, now is it possible to get the event >>>> handler to fire automatically? I really don't want to use polling, even >>>> if >>>> it is on a separate thread. Currently I have the WM_USER event being >>>> triggered through SendMessage(WM_MYEVENT,0,0); inside an OnClicked( ) >>>> handler attached to a UI button. Although this is working in my test >>>> app, >>>> I >>>> want the event to be fired automatically by the OS when the targeted >>>> event >>>> occurs. >>>> >>>> Any ideas? Thanks guys. >>>> >>>> -Eric >>>> >>>> --- On Sun, 8/23/09, Eric Strain <eric_strain1-/[email protected]> wrote: >>>> >>>> From: Eric Strain <eric_strain1-/[email protected]> >>>> Subject: [OT] user defined WM_ question >>>> To: [email protected] >>>> Date: Sunday, August 23, 2009, 5:17 PM >>>> >>>> >>>> >>>> Hi All, >>>> I have a function that I need to fire when a specific event occurs. The >>>> event that I need to trap is a network failure of any kind. I have the >>>> code >>>> that detects when a network failure has occurred but at present the >>>> function >>>> is inside a command line interface program and I want to transfer that >>>> function into an MFC app and have the function activated by a WM_ event. >>>> My >>>> question is, is it possible to get the user defined WM_ to fire >>>> automatically, or does the user have to send the event message manually, >>>> such as by clicking a UI button or something? >>>> >>>> Also, I considered using WM_USER to define the custom WM_ message, but >>>> my >>>> research indicates that WM_APP is the preferred method for defining a >>>> custom >>>> message. Any thoughts on this? Even better, any concrete examples? ; ) >>>> I've >>>> looked all over the net and through my library of books with no luck. >>>> It's a >>>> shame a person can't loose weight by running in circles, because I seem >>>> to >>>> be getting nowhere fast. Thanks guys. >>>> >>>> -Eric >>>> >>>> >>>> >>>> >>>> >>>> >>> >>> >>> >>> >>> >> >> >> ------------------------------------ >> >> Yahoo! Groups Links >> >> >> >> >> > > > ------------------------------------ > > Yahoo! Groups Links > > > > > > > ------------------------------------ Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/win_tech_off_topic/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/win_tech_off_topic/join (Yahoo! ID required) <*> To change settings via email: mailto:win_tech_off_topic-digest-hHKSG33TihhbjbujkaE4pw@public.gmane.org mailto:win_tech_off_topic-fullfeatured-hHKSG33TihhbjbujkaE4pw@public.gmane.org <*> To unsubscribe from this group, send an email to: win_tech_off_topic-unsubscribe-hHKSG33TihhbjbujkaE4pw@public.gmane.org <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/