|
|
I would like to get into to owner drawn controls (with MFC), can someone point me to and artical/s or example/s that explain how to do this, i cant seen to find any good ones
|
|
|
|
|
there are samples in VC CD, easy to learn
cheers
includeh10
|
|
|
|
|
I have two PC's running on a lan at home, with lan IP addresses of 192.168.0.101, and 192.168.0.100. The router has public IP address for the wan. I can find out what the public IP address, for example at http://www.whatismyip.com/, but I do not know how to write a VC++ application that will run on one of the lan PCs and programmatically find the public IP address. (I can find all the IP address for the local machines running the application.)
Can anyone set me straight? Will your solution work in more complex network environments?
A.G. Neville
|
|
|
|
|
Don't think you can do this from the PC. The public IP is set up on the router, and the PCs will have the internal IP address of the router set as their gateway. The PCs will have no knowledge of the external IP address of the router.
|
|
|
|
|
Thanks; perhaps I was being a bit too constraining in my post when I said execute the app on the local pc. I don't mind if the app has to bounce messages to off site, eg to a web server.
I have seen three 'apps' do it:
1) MyWanIP.exe. They state they send messages to a web server in the marketing blurb.
2) Xolox.exe. This is P2P app, hence there is a good chance there are messages bouncing around, as above
3) http://www.whatismyip.com/ (yes, not really an app and not on my PC) Again there is network traffic to and from my pc.
I can believe Graham is right, and there is no easy, local way. If I do it like the above applications, what network traffic needs to be sent and how do I dig into the result to find that IP address?
AGN
|
|
|
|
|
This: http://checkip.dyndns.org[^], is specifically meant to provide an easy way to parse for and find an external IP.
modified 12-Jul-20 21:01pm.
|
|
|
|
|
Thanks for info.
Yes the parsing looks easy. This certainly gets me started. I hope the web site does not go down ... my app will go with it.
Does anyone know how they do it?
AGN
|
|
|
|
|
That service has been around for years, and that site I posted is actually one of their recommend methods for getting the ip for client programs. The way it works is simple, since the webserver only sees your external IP on the packet, so that's what it shows. I can give you anything super specific, but that's the gist.
modified 12-Jul-20 21:01pm.
|
|
|
|
|
In a multithreaded VC++ program, how can I find %of CPU/ thread from within the program and report it? Also how can I find the memory footprint of the process from within the program? Is it possible? (Not using any external tools like perfmon, just using C++ code from the program itself)
|
|
|
|
|
|
Thanks. How to find the %CPU/thread?
HANDLE hProcess;
PROCESS_MEMORY_COUNTERS pmc;
DWORD processID = GetCurrentProcessId ();
hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ,
FALSE, processID );
if (NULL == hProcess)
return;
if ( GetProcessMemoryInfo( hProcess, &pmc, sizeof(pmc)) )
{
printf( "\tPeakWorkingSetSize: 0x%08X\n",
pmc.PeakWorkingSetSize );
}
|
|
|
|
|
I found that using PDH these can be done. Was wondering if this can be done for individual processes, from within the program.
HQUERY m_hQuery; // the query to the PDH
PdhOpenQuery(NULL, 1, &m_hQuery);
PdhAddCounter(....)
How to use above function for individual processes?
|
|
|
|
|
I have a Date Time Picker in a toolbar, and I have a derived class of CDateTimeCtrl managing the UI object.
What I want to know is how do I specify which days in the month are bold when the user clicks the dropdown button to select the date?
Any help would be greatly appreciated.
Thanks
|
|
|
|
|
You can call CMonthCalCtrl::SetDayState() (MESSAGE: MCM_SETDAYSTATE) to set them or better yet respond to the MCN_GETDAYSTATE message that the control sends when it needs new information. This usually occurs when the month changes.
From my memory, there is an array of 32 bit values where each value represents a month and each bit represents a day. The on BITS cause the day to be bolded in the calendar if it has the MCS_DAYSTATE style set. There is all sorts of documentation on MSDN.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Hi, I created a class that uses the NtNative APIs found in the ntdll.dll. Everything works except the "Hive File" functions. Below is the "LoadKey" function:
<br />
BOOL CKey::LoadKey(CString csHiveFilePathName, ULONG ulFlags )<br />
{<br />
<br />
ASSERT(csHiveFilePathName != _T(""));<br />
ASSERT((m_csRootPath == _T("\\Registry\\User") || <br />
m_csRootPath == _T("\\Registry\\Machine")));<br />
<br />
BOOL bSuccess = TRUE;<br />
<br />
HANDLE hRootKey = NULL, hHiveFile = NULL;<br />
<br />
NT::UNICODE_STRING usRootKeyName, usHiveFileName, usHiveFile;<br />
NT::OBJECT_ATTRIBUTES DestinationKeyName, RegHiveFileName, RegHiveFile;<br />
<br />
int n=0;<br />
<br />
<br />
if (csHiveFilePathName.Left(4) != _T("\\??\\"))<br />
csHiveFilePathName.Insert(0,_T("\\??\\"));<br />
<br />
m_NtStatus = EnablePrivilege(SE_RESTORE_NAME, TRUE);<br />
if(!NT_SUCCESS(m_NtStatus))<br />
{<br />
bSuccess = FALSE;<br />
goto end_it;<br />
}<br />
<br />
WCHAR wszHiveFile[1024];<br />
for (n=0; n<csHiveFilePathName.GetLength(); n++)<br />
wszHiveFile[n] = (WCHAR)csHiveFilePathName[n];<br />
<br />
wszHiveFile[n++] = L'\0';<br />
<br />
usHiveFileName.Buffer = wszHiveFile;<br />
usHiveFileName.Length = wcslen(wszHiveFile) * sizeof(WCHAR);<br />
<br />
InitializeObjectAttributes(&RegHiveFileName, &usHiveFileName, <br />
OBJ_CASE_INSENSITIVE, NULL, NULL );<br />
<br />
WCHAR wszRootKey[2048];<br />
for (n=0; n<m_csRootPath.GetLength(); n++)<br />
wszRootKey[n] = (WCHAR)m_csRootPath[n];<br />
<br />
wszRootKey[n++] = L'\0';<br />
<br />
usRootKeyName.Buffer = wszRootKey;<br />
usRootKeyName.Length = wcslen(wszRootKey) * sizeof(WCHAR);<br />
<br />
InitializeObjectAttributes(&DestinationKeyName, &usRootKeyName, <br />
OBJ_CASE_INSENSITIVE, NULL, NULL );<br />
<br />
if (ulFlags == 0x0000)<br />
{<br />
if (m_ntModeType == 0)
m_NtStatus = NT::ZwLoadKey(&DestinationKeyName, &RegHiveFileName);<br />
else<br />
}<br />
else<br />
m_NtStatus = NT::ZwLoadKey2(&DestinationKeyName, &RegHiveFileName, ulFlags);<br />
<br />
if (!NT_SUCCESS(m_NtStatus)) <br />
{<br />
bSuccess = FALSE;<br />
}<br />
<br />
end_it:<br />
<br />
m_csFunction = _T("LoadKey()");<br />
if (ulFlags == 0x0004)<br />
m_csFunction = _T("LoadKey(2)");<br />
<br />
if (!bSuccess) <br />
Output(DisplayError(m_NtStatus), MB_OK|MB_ICONERROR);<br />
<br />
m_NtStatus = EnablePrivilege(SE_RESTORE_NAME, FALSE);<br />
<br />
<br />
if (!NT_SUCCESS(m_NtStatus)) <br />
{<br />
Output(DisplayError(m_NtStatus), MB_OK|MB_ICONERROR);<br />
m_csFunction = _T("");<br />
return FALSE;<br />
}<br />
else if (!bSuccess) <br />
{<br />
m_csFunction = _T("");<br />
return FALSE;<br />
}<br />
<br />
return TRUE;<br />
}<br />
Appreciate any help you can give me!!!
Regards,
Dan
|
|
|
|
|
to check if the mouse is outside a CWnd, have a look at TRACKMOUSEEVENT ( with TME_LEAVE ) and _TrackMouseEvent .
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
hmm.. i'm using mfc, that's some winapi stuff.. i never merged both things, tough i know that mfc is over winapi. How could i manage those messages if i can't see them in classwizard?
|
|
|
|
|
you can use it with MFC with no problem; the _TrackMouseEvent will generate a WM_MOUSELEAVE event/notification
ON_MESSAGE(WM_MOUSELEAVE, OnMouseLeave)
void CView::OnMouseMove( UINT nFlags, CPoint point )
{
if ( ! ( nFlags & MK_LBUTTON ) )
{
if (!m_bTracking)
{
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(tme);
tme.hwndTrack = m_hWnd;
tme.dwFlags = TME_LEAVE;
m_bTracking = (_TrackMouseEvent(&tme) == 1 )? true: false;
}
}
}
LRESULT CView::OnMouseLeave(WPARAM wparam, LPARAM lparam)
{
m_bTracking = false;
return 0;
}
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Hi, your code seems like it's going to work, but i don't quite understand it. I added the message and the OnMouseLeave function. That's ok. What i can't understand is what's inside your OMouseMove function.
what i basically want to do is this:
void CAreaPizarra::OnMouseMove(UINT nFlags, CPoint point)
{
if ((nFlags == MK_LBUTTON) && (mouse is inside))
{
do_one_thing();
}
else
if ((nFlags == MK_LBUTTON) && (mouse is outside))
{
do_another_thing();
}
would you mind explaining me what you did in your function so i can add it in this code?
thanks!
|
|
|
|
|
|
have a look at this[^], it can be very interesting for you...
TOXCCT >>> GEII power
|
|
|
|
|
i've solved it with:
ClientToScreen(&this->m_RectArea);
ClipCursor(this->m_RectArea);
Now, how do i unclip the cursor?
Those lines are in OMouseMove, while the lbutton is clicked.
I want to unclip it in OnLButtonUp
how could i do it?
thanks!
|
|
|
|
|
set a flag (a bool) into your class for example.
otherwise, i don't really understand... sorry...
TOXCCT >>> GEII power
|
|
|
|
|
With ClipCursor(Rect); , the mouse is trapped in that rect.
what should i call if i want the mouse to be free!.. so that i can move it over all the screen of my monitor?
something like ClipCursor(desktop) or something like that?
|
|
|
|