|
|
Hi all,
What function can I use to monitor whether or not a computer has network connectivity. For example, if the network cable was unplugged the function would trigger. I suppose I should do this in a thread?
Many thanx
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r My Blog: ^_^
|
|
|
|
|
Have a look at InternetGetConnectedStateEx() and InternetGetConnectedState() from wininet.dll
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Thanx for your reply..
BOOL InternetGetConnectedState(
OUT LPDWORD lpdwFlags,
IN DWORD dwReserved
);
Retrieves the connected state of the local system.
Returns TRUE if there is an Internet connection, FALSE otherwise.
Will this work for a local (LAN) connection aswell ?
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r My Blog: ^_^
|
|
|
|
|
Sorry, I didn't read your question good enough before answering.
If you know for sure that the computer in question is connected to Internet via the LAN-connection, you should be able to use either InternetGetConnectedState() or InternetGetConnectedStateEx()
Check for INTERNET_CONNECTION_LAN
Else, I found this at MSDN:
1.
Use IsNetworkAlive()
2.
I found this sample at MSDN[^]
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
|
Programm3r wrote: kakan, thank you very much for your help ...
if you can use ISensNetwork, that will provide you accurate detail!
|
|
|
|
|
Hi,
When i change the background color of my dialog, along with that the color of the edit box in my dialog is changing.. but i want the editbox color to be white only..
Is there anyway to do?
Is there any function like in the case of listcontrol(SetBkColor()) to get the color of Editbox to the color i want to.
Harsha
|
|
|
|
|
harsh_2961 wrote: When i change the background color of my dialog, along with that the color of the edit box in my dialog is changing.
How you have done this ?
|
|
|
|
|
I put the code in my reply just now.. please see the code..
Harsha
|
|
|
|
|
harsh_2961 wrote: please see the code
Where ? I cannot see it .
|
|
|
|
|
I used following function
HBRUSH CFileopenDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
return m_brush;
}
along with the line m_List.SetBkColor(RGB(255, 255, 255));
in oninitdialog().
Harsha
|
|
|
|
|
I'm not sure, how you have done it, but modify your code to,
CFileopenDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
return m_brush;
}</blockquote>
To skip edit control painting do this,
HBRUSH CFileopenDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
m_brush= CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if (nCtlColor == CTLCOLOR_EDIT)
{
return brush
}
else
{
}
return m_brush;
}
|
|
|
|
|
harsh_2961 wrote: When i change the background color of my dialog, along with that the color of the edit box in my dialog is changing..
can u show the code...
Do your Duty and Don't expect the Result
|
|
|
|
|
I used following function
HBRUSH CFileopenDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
return m_brush;
}
along with the line m_List.SetBkColor(RGB(255, 255, 255));
in oninitdialog().
harsha
|
|
|
|
|
harsh_2961 wrote: along with the line m_List.SetBkColor(RGB(255, 255, 255));
in oninitdialog().
Hope the m_List is your CEdit control.
harsh_2961 wrote: HBRUSH CFileopenDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
return m_brush;
}
Instead of simply returning m_brush(hope this the brush to paint the dialog background). Try this,
CFileopenDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if (CTLCOLOR_EDIT != nCtlColor)
return m_brush;
return hbr;
}
The above change the background color for all the controls in the dialog except for the CEdit controls.
If you want to change the color only to the dialog then change the 'if' condition as below
if (CTLCOLOR_DLG == nCtlColor)
Do your Duty and Don't expect the Result
|
|
|
|
|
Thanks a lot ... its perfectly working
Harsha
|
|
|
|
|
Default color of editbox is white but if you want to change color of editbox use of WM_CTLCOLOREDIT
|
|
|
|
|
Over ride WM_ERASEBKGND and put this code over there.
CPen myPen;
int i =100;
CRect rect ;
myPen.CreatePen(PS_SOLID, 1, RGB ((i * 4),0,0));
CPen *oldPen = pDC->SelectObject(&myPen) ;
GetClientRect(&rect);
for(i = 0 ; i <= rect.bottom;)
{
pDC->MoveTo(0, i);
pDC->LineTo(rect.right, i);
pDC->SelectObject (&myPen);
}
pDC->SelectObject(oldPen) ;
return TRUE ;
The edit box would not be painted to match the dialog back color and would show as white. See if this helps
_AnShUmAn_
-- modified at 4:55 Wednesday 14th March, 2007
|
|
|
|
|
harsh_2961 wrote: When i change the background color of my dialog, along with that the color of the edit box in my dialog is changing.. but i want the editbox color to be white only..
HBRUSH CFileopenDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH OrgBrush=CreateSolidBrush(RGB(255,255,255)); // make it white
if(pWnd->GetSafeHwnd() == GetDlgItem(IDC_EDIT1)->GetSafeHwnd())
{
return OrgBrush;
}
return m_brush;
}
|
|
|
|
|
ThatsAlok wrote: if(pWnd->GetSafeHwnd() == GetDlgItem(IDC_EDIT1)->GetSafeHwnd())
if (pWnd->GetDlgCtrlID() == IDC_EDIT1) would be better.
|
|
|
|
|
I am working on email program in VC++. Thru my application I can send mails now. But i want to give user login and password fecility to that.
Here the condition is
<BR>->I want to check the given Mail-id(UserID) & password are correct or not.<br />
->For example User id = "abc@gmail.com"<br />
->respective gmail password = "hello"<BR>
If user entered these two details to my application i need to check the mail id is valid or not and whether password is correct or not. How i can do this.
Could any one please help me in this.
Nice talking to you. If you judge people, you have no time to love them. -- Mother Teresa
|
|
|
|
|
Could any one help me.
Atleast i need idea. Please.
Nice talking to you. If you judge people, you have no time to love them. -- Mother Teresa
|
|
|
|
|
Hi Every one.
I need authentication details. Could any one please kindly helpme in this.
What is authentication, and how to check this authentication. How to use SSL concept in the Email sending program. please help me. this is urgent for me.
Nice talking to you. If you judge people, you have no time to love them. -- Mother Teresa
|
|
|
|
|
Does CString allocate memory on the heap or on the stack?
<br />
#include "stdafx.h"<br />
<br />
#include <afxwin.h>
#include <afxext.h>
#include <afxtempl.h><br />
<br />
#include "TestCString.h"<br />
<br />
#ifdef _DEBUG<br />
#define new DEBUG_NEW<br />
#undef THIS_FILE<br />
static char THIS_FILE[] = __FILE__;<br />
#endif<br />
<br />
<br />
CWinApp theApp;<br />
<br />
using namespace std;<br />
<br />
<br />
void SomeFunc(CList<CString, CString> &oList) {<br />
CString strOriginal = L"ABCDEF";<br />
CString strNewString; << Local variable declared on Stack but seems like it allocates on heap since it can be called from "Main".<br />
<br />
strNewString = strOriginal.Mid(2);<br />
oList.AddTail(strNewString);<br />
<br />
return;<br />
}<br />
<br />
<br />
<br />
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])<br />
{<br />
int nRetCode = 0;<br />
<br />
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))<br />
{<br />
cerr << _T("Fatal Error: MFC initialization failed") << endl;<br />
nRetCode = 1;<br />
}<br />
else<br />
{<br />
CList<CString, CString> oList;<br />
CString strString;<br />
<br />
SomeFunc(oList);<br />
strString = (CString) oList.GetHead();<br />
<br />
printf("%s", strString);<br />
}<br />
<br />
return nRetCode;<br />
}<br />
|
|
|
|