|
Hi
Thankx a lot to you too......
U'r quote also helped me a lot.
Mahesh
|
|
|
|
|
An ISP connection does not mean the network cable is plugged in but would provide you with similar capabilities. I am assuming you want to see if you have network connectivity which requires you take any IP capable connection into consideration. Checking the routing table for a default route is the best technique I've come across so far as it does not require checking a URL, pinging an IP address, or other techniques that will not be entirely accurate in all contexts.
I got the idea from someone on CodeGuru before they upgraded their website and lost all the legacy comments. Unfortunately, I do not know the name of the person who passed on the idea so I can't give credit where credit is do but I'll pass it on...
The function to use is GetIpForwardTable(). I use a timer to periodically check for connectivity and update my status indicator accordingly. There is a slight delay maybe a second or two if you unplug the cable or plug it in (assuming your timer is set to fire every second). No noticeable delay when disabling the connection using a GUI tool.
Don't forget to include in StdAfx.h...
#include <iphlpapi.h> // For Routing table query
And make sure to reference the Platform SDK lib file...
iphlpapi.lib
BOOL CNetworkConnectionDlg::IsInternetAvailable(void)
{
MIB_IPFORWARDTABLE * pRoutingTable;
DWORD dwBufferSize=0;
BOOL bIsInternetAvailable=FALSE;
DWORD dwResult;
DWORD dwIndex;
DWORD dwRowCount;
// Get the required buffer size
GetIpForwardTable(NULL,&dwBufferSize,FALSE);
pRoutingTable=(MIB_IPFORWARDTABLE*)new BYTE[dwBufferSize];
// Attempt to fill buffer with routing table information
dwResult=GetIpForwardTable(pRoutingTable,&dwBufferSize,FALSE);
if (dwResult==NO_ERROR) {
dwRowCount=pRoutingTable->dwNumEntries; // Get row count
// Look for default route to gateway
for (dwIndex=0;dwIndex<dwRowCount;dwIndex++) {
if (pRoutingTable->table[dwIndex].dwForwardDest==0) { // Default route designated by 0.0.0.0 in table
bIsInternetAvailable=TRUE; // Found it
break; // Short circuit loop
}
}
}
delete pRoutingTable; // Clean up. Just say "No" to memory leaks
return bIsInternetAvailable;
}
|
|
|
|
|
Hi
Thankx thankx thankx thankx........I can't describe it in words...
Any way have a nice time
Mahesh
|
|
|
|
|
Great code, thank you a lot!
|
|
|
|
|
Hello,
I've got a Problem with the "Reusable base class for SplitterWnd" from Daniel Zuppinger:
http://www.codeproject.com/splitter/st_splitterwnd.asp
I splitted the MainFormView vertical and added to each Pane a View in the OnCreateClient Method of the MainFrame:
m_pRightBottomSplitterWnd = m_pRightSplitterWnd->AddSubDivision(BOTTOM_SIDE, RUNTIME_CLASS(CViewChooser), RUNTIME_CLASS(CView1), pContext, true);
Now I click on a Button in the right Pane and going to change the View in the Left Pane. For Example from CFormView to CHTML View or whatever. Therefore I call a Method in the MainFormView Class by clicking the Button, with the following code:
m_pRightBottomSplitterWnd->AddView(RIGHT_SIDE, RUNTIME_CLASS(CView2), NULL);
But that still doesn't work and I got a runt-time-error. The Debugger stops at the following code, from the SplitterWnd Class:
<br />
inline void SideToRowCol(int nSide, int* nRow, int* nCol) <br />
{<br />
if (m_bVertical) {
*nRow = 0;<br />
*nCol = nSide;<br />
}<br />
else {<br />
*nRow = nSide;<br />
*nCol = 0;<br />
}<br />
};
I hope you understand my Problem and can help me.
|
|
|
|
|
hever wrote: I've got a Problem with the "Reusable base class for SplitterWnd" from Daniel Zuppinger:
Has he been able to help?
hever wrote: Now I click on a Button in the right Pane and going to change the View in the Left Pane.
Are you using ST_SplitterWnd::SwitchToView() for this?
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
DavidCrow wrote: Has he been able to help?
There are no answers in the article forum and I don't have any contact data about him.
DavidCrow wrote: Are you using ST_SplitterWnd::SwitchToView() for this?
No, I try to use the AddView Method:
m_pRightBottomSplitterWnd->AddView(RIGHT_SIDE, RUNTIME_CLASS(CView2), NULL);
And I'm not sure what SwitchToView() exactly do?!
-- modified at 14:16 Tuesday 31st January, 2006
|
|
|
|
|
hever wrote: And I'm not sure what SwitchToView() exactly do?!
Ok SwitchToView() was a good idea!
And I've to read the tutorial better!
This is the example code:
m_nViewNo1 = m_pSplitterWnd->AddView(RIGHT_SIDE, RUNTIME_CLASS(CSplitterWndTestView), pContext);<br />
<br />
m_nViewNo2 = m_pSplitterWnd->AddView(RIGHT_SIDE, RUNTIME_CLASS(CSplitterWndTestView6), pContext);
AddView returns an integer, which identicates the View. (Just begining with 0 and then increments)
To Switch a View in a Pane, you can use the SwitchToView Method.
The first argument indicates the pane and the second the view (The number returned by AddView).
SwitchToView works to me, but only when I call it directly after creating and filling the Panes.
My Problem is still, that an error occurs by calling the SwitchToView Funcion a bit later. As I described above, for example by clicking on a button...
What could this Problem be?
|
|
|
|
|
Ok I solved it
And as I said it was a simple one:
I accessed the MainForm with the following code:
reinterpret_cast<CMainFrame*>(GetDocument())->UpdateFunction;
But I have to use this one:
((CMainFrame*)theApp.GetMainWnd())->UpdateFunction;
I'm not a MFC expert and can not describe really what the problem was but when you try to change a view use the SwitchToView Function and acess the MainFrame like the second code post.
Perhaps it could help someone.
|
|
|
|
|
Hi,
How can you set that your dialog box's size cannot be changed anymore upon load? (cannot be maximized). I've already removed the maximize and minimize buttons but it still maximizes. Can anyone help me? I'm using mfc.
Thanks a lot.
waxie
|
|
|
|
|
Intercept the WM_SHOWWINDOW message, and only allow SW_SHOW and SW_HIDE as parameter for a base class call.
~RaGE();
|
|
|
|
|
|
I want to run 2 different exes one by one when i start my VC++ application.(1 should run, after 1 min that has to be automatically closed and 2nd exe should be run automatically). I tried shellexecute, WinExec for starting the exes automatically. But i don't find any application for terminating automatically. Please help me
|
|
|
|
|
Precise if MFC or not. Here is the MFC a solution:
Use CreateProcess to fire up the first .exe. Save the handle returned by CreateProcess . Start a timer. When the timer expires, use TerminateProcess() with the handle as paramter to kill the first app. Then start the second app.
Reply back if you need help with timers.
~RaGE();
-- modified at 11:11 Tuesday 31st January, 2006
|
|
|
|
|
I'm just curious what your suggestion has to do with MFC. Those two functions are not MFC-specific.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
The timer solution that I wanted to explain, and decided finally not to.
~RaGE();
|
|
|
|
|
Thanks Rage,
As per your suggestion, i tried the code. CreateProcess and TerminateProcess do the things required for me. Thanks again for helping me in the right time.
|
|
|
|
|
Hi all
While using CreateProcess() for running an EXE from the VC++ application the application works fine when i directly use EXE. When i specify the path of the shortcut the CreateProcess is failed. please suggest me to run the exe from shortcut.
Thanks in advance
|
|
|
|
|
S.R.Sasi Kumar wrote: When i specify the path of the shortcut the CreateProcess is failed. please suggest me to run the exe from shortcut.
Try ShellExecute() .
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
Another question: are you waiting with the timer to be sure that the first app is finished before running the second one ?
~RaGE();
|
|
|
|
|
Use CreateProcess to start your first app.
Monitor that app, and wait for it to terminate.
In your 1st app, set a timer to fire after one minute, and let the app close itself (send WM_CLOSE).
When you detect that the 1st app is terminated, run the 2nd app with CreateProcess().
ShellExecute and WinExec are brain-dead cousins of CreateProcess(). Avoid using them.
------- sig starts
"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: ShellExecute and WinExec are brain-dead cousins of CreateProcess(). Avoid using them.
I agree with your WinExec() sentiment, but how would you propose to use CreateProcess() when your task is to "run" or "print" an .html or a .doc file?
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
Hi Friends,
I have local as well as network printers. I want to assign printing quota for each user and want to control the printing only is it is valid.Is there any way to do such things?
Vikram S
|
|
|
|
|
Could you call EnumJobs() with JOB_INFO_1 or JOB_INFO_2 ?
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
Yes I can do that....thanx...
Is there any way to terminate/remove that job from spooler?
|
|
|
|