|
GetCaretPos will return caret position using client coordinates. You'll have to convert that into screen coordinates with ClientToScreen.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Suppose i know the name of a computer of my network...how do i find shared resources belonging that computer (like those which appears in Network neighborhood)?
I also mention that FindFirstFile("\\\\comp_name\\directory_name\\*.*",...) WORKS.IN COMMAND PROMPT DIR \\comp_name\\directory_name WORKS TOO.
But FindFirstFile("\\\\comp_name\\*.*",....) fails. IN COMMAND PROMPT dir \\comp_name FAILS TOO. IN EXCHANGE, NET VIEW \\comp_name RETURN EXACTLY WHAT I NEED.
My conclusion is FindFirstFile doesn't solve my problem. I tried WNet but i failed...
Thank you all.
|
|
|
|
|
Hi,
you can do it using this functions:
WNetOpenEnum
WNetEnumResource
You'll find all the information on MSDN.
I wrote a little program that walks through all machines in the local network looking for shared directories (it was 3 or 4 years ago), this is a snippet:
void CNetScanDlg::StartScan()
{
ULONG ulDataSize = 16000;
NETRESOURCE* pData = new NETRESOURCE[ulDataSize];
DWORD dwEntries = 0xFFFFFFFF;
OpenContainer(NULL);
delete [] pData;
}
BOOL CNetScanDlg::OpenContainer(NETRESOURCE* pNetRes)
{
//Datos necesarios para la API de NetWorking
ULONG ulDataSize = 16000;
NETRESOURCE* pData = new NETRESOURCE[ulDataSize];
DWORD dwEntries = 0xFFFFFFFF;
DWORD dwResult;
HANDLE handle;
//
dwResult = WNetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_ANY, 0, pNetRes, &handle);
if( dwResult == NO_ERROR )
{
dwResult = WNetEnumResource( handle, &dwEntries, pData, &ulDataSize);
if( dwResult == NO_ERROR )
{
for( DWORD i = 0; i < dwEntries; i++)
{
AddItem( pData[i] );
if(RESOURCEUSAGE_CONTAINER == (pData[i].dwUsage & RESOURCEUSAGE_CONTAINER))
{
OpenContainer( &pData[i] ); //Recursividad
}
}
}
}
delete [] pData;
return FALSE;
}
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
this one could be helpful too:
BOOL CNetScanDlg::AddItem(NETRESOURCE NetRes)
{
// CSADDR_INFO AddrInfo[100];
// DWORD dwSize = sizeof(CSADDR_INFO)*100;
// HOSTENT hostent;
CString strTemp;
switch( NetRes.dwDisplayType )
{
case RESOURCEDISPLAYTYPE_ROOT:
case RESOURCEDISPLAYTYPE_NETWORK:
{
m_htiNetwork = m_NetTree.InsertItem( NetRes.lpRemoteName, 1, 1, TVI_ROOT );
} break;
case RESOURCEDISPLAYTYPE_DOMAIN:
{
m_htiDomain = m_NetTree.InsertItem( NetRes.lpRemoteName, 0, 0, m_htiNetwork );
} break;
case RESOURCEDISPLAYTYPE_SERVER:
{
m_htiServer = m_NetTree.InsertItem( NetRes.lpRemoteName, 3, 3, m_htiDomain );
//int iGetResult =
/*
hostent = gethostbyname(NetRes.lpRemoteName);
if( iGetResult == ERROR_INSUFFICIENT_BUFFER )
m_NetTree.InsertItem("Error!", 4, 4, m_htiServer);
*/
//Incremento el numero de maquinas y actualizo la pantalla
m_nMachines++;
strTemp.Format("%d", m_nMachines);
SetDlgItemText(IDC_STATIC_MAQUINAS, strTemp);
//
} break;
case RESOURCEDISPLAYTYPE_GENERIC:
case RESOURCEDISPLAYTYPE_SHARE:
{
//Intento listar los archivos
CFileFind FileFind;
CString strPath(NetRes.lpRemoteName);
strPath += "\\*.*";
BOOL bResult = FileFind.FindFile(strPath, 0);
//
if( bResult ) //Si pude acceder a los archivos
{
m_NetTree.InsertItem( NetRes.lpRemoteName, 4, 4, m_htiServer );
//Incremento el nro de dir. habilitados y actualizo la pantalla
m_nDirHabilitados++;
strTemp.Format("%d", m_nDirHabilitados);
SetDlgItemText( IDC_STATIC_DIR_HABILITADOS, strTemp );
}
else //No pude acceder a ese SharePoint
{
m_NetTree.InsertItem( NetRes.lpRemoteName, 2, 2, m_htiServer );
//Incremento el nro de dir. Deshabilitados y actualizo la pantalla
m_nDirDeshabilitados++;
strTemp.Format("%d", m_nDirDeshabilitados);
SetDlgItemText( IDC_STATIC_DIR_DESHABILITADOS, strTemp );
//
}
//Incremento el numero de directorios y actualizo la pantalla
m_nDirectorios++;
strTemp.Format("%d", m_nDirectorios);
SetDlgItemText(IDC_STATIC_DIRECTORIOS, strTemp);
//
} break;
default: return FALSE;
}
m_NetTree.Invalidate();
return TRUE;
}
Anybody knows how to paste a code snippet into the forum with the original formatting (like tabs) ?
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
Hi,
I wrote a small dll which should be the link between two application (allow communication between them). Each application can use the dll, but the data is not shared. I had a look at the article "How to share a data segment in a DLL" by Phil McGahan to implement a shared data segment.
Unfortunately this didn't work. Also the compiler always says:
LINK : warning LNK4039: section "SHARED" specified with /SECTION option does not exist
My dll looks basically like this:
#pragma data_seg("SHARED")
int counter;
#pragma data_seg()
#pragma comment(linker, "/section:SHARED,RWS")
extern "C" __declspec(dllexport) void test()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
counter++;
CString tmp;
tmp.Format("Counter=%i",counter);
AfxMessageBox(tmp,MB_OK|MB_ICONSTOP|MB_APPLMODAL);
}
What am I doing wrong
Can someone help
Thanks
|
|
|
|
|
You have to initialize counter (add the underlined part below):
#pragma data_seg("SHARED") <br />
int counter = 0;<br />
#pragma data_seg()
--Mike--
http://home.inreach.com/mdunn/
"....." -- Silent Bob
your with and
|
|
|
|
|
Sounds too easy... but is working!!
Thanks
|
|
|
|
|
I have a listview on a dialog, and I want to set a dialog variable, when the user clicks a column header (which sorts the list view on that column, and I want to save which column and the sort order in that variable). Problem is, I searched all over MSDN, and I can't find a "user clicked listview X" Message Map from the main dialog (so that when the user clicks a column header, the main dialog then goes to the listview (a derived lv class which has a function to return column number and sort order) and gets the column number and sort order. Though there are ways I could work around this, it would be the cleanest implementation possible. Anyone have any ideas, or if there is an "list view header clicked" message map for the dialog?
|
|
|
|
|
Notification messages are sent to a control's parent. That means that header notifications are sent to the list control, not your dialog. You'll need to write a CListCtrl-derived class and use that in your dialog. The list can then either handle the sorting or send a private message (such as WM_APP) to the dialog to make the dialog do the sorting.
--Mike--
http://home.inreach.com/mdunn/
"....." -- Silent Bob
your with and
|
|
|
|
|
Hi all,
I'm writing simple ActiveX with MFC ActiveX Wizard ...
I have problem in my properties ...
I add new property: Disable(external name and BOOL m_disable member variable and void OnDisableChanged() notification function).
I add Checkbox to my property page for changing Disable property ...
I wanna add member variable for the Checkbox, but i can't see my property name in 'Optional property name' section in Add Member Variable dialog !!!
How can i solve it ?
In last, what is 'Optional property name' performance ?
Help me, plz ...
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
I writed ATL COM DLL via AppWizard and added to it ATL class "AtlObj".
after I imported function from Extention DLL that I created before. so:
------------------------------------------------------------
extern "C" __declspec(dllimport) void ShowDialog();
STDMETHODIMP CAtlObj::show()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
AfxMessageBox(".....");
ShowDialog();
return S_OK;
}
-----------------------------------------------------------
The problem : When I run it by client program (exe) the atl it works !
but the imported function (ShowDialog) dont performed. WHY ????????
|
|
|
|
|
I didn't answer yesterday because I'm not really knowledgable with regard to dll's in general. But have you tried putting in a breakpoint to see what happens if you trace into your ShowDialog function ?
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Does CString and LPCTSTR only carry as much as 256 characters or is there a way to augment this to carry what I want. I have a SQL query that is 289 characters long and I'm needing a string variable that could carry it.
(shuffling through MSDN. yuck)
Thanks!
"Why are we hiding from the police, Daddy?"
"We use VI, son. They use Emacs."
|
|
|
|
|
CString doesn't have a 256 char limit.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Nope. If you dig through the MFC Source, you'll discover that it stores the string in a LPTSTR variable called m_pchData. Looking further, LPTSTR is defined as char * or wchar * (depending on whether or not you're using UNICODE). So in essence, CString can handle strings as large as your have memory for.
Jamie Nordmeyer
Portland, Oregon, USA
|
|
|
|
|
CString::GetLength() returns an int [32 bit number in win32]
So I guess if you have that much RAM, then that's the limit....
a 32 bit number can have a max value of 4,294,967,295
and GetLength() returns the byte count
thus we can have that many bytes [approx 4.29 GB] in a CString
Hmmmm
wait wait wait
I think int means signed-integer
if that's the case then we only have 2.14 GB
Nish
|
|
|
|
|
It's not unsigned, so it's 2gb.
To hell with those thin-skinned pillow-biters. - Me, 10/03/2001
|
|
|
|
|
We're making an ATL object to be used in ASP or Visual Basic.
I want to be able to return a BSTR to make it nice and pretty for my VB partner.
Ok ok, we all know that you can say...
///////////////
STDMETHODIMP Foo([out,retval] BSTR outstring)
///////////////
..and have it returned in a variable in the Implementation. (duh)
But can we get this a function in an object to look like:
///////////////
BSTR Foo(BSTR instring);
///////////////
or just something with the emphasis on returning a BSTR in the "real" return parameter place.
"The Master Wang" doesnt have money to buy a COM or ATL book...
and plus I know I'm asking questions from the best!
SHABBA!!
*Please Contact Me if you have a Donation to give to a poor college student who needs money for a engagement ring for the greatest girl in the world.
-~= The (still learning) Master Wang =~-
SHABBA!!
|
|
|
|
|
STDMETHODIMP Foo([out, string, retval] BSTR* outstring)
cheers!!!
Carlos Antollini.
|
|
|
|
|
hey, cool, umm... can you explain "how it works"? i kinda need to know why i'm doin' this. One more question (which is most important), in VB am i gonna be able to say:
(VB mumbo jumbo)
set thingy = STRTESTLib.blahblah
dim StringAction
///////////////////////
StringAction = thingy.WhatStringDoIHave()
///////////////////////
^^^This is what i want it to look like.
So what you just showed me will let me do this?
SHABBA!!
|
|
|
|
|
You will must to register your object for example STRTESTLib. You must to use the lib in your VB project with the option Components...
If your interfase is STRTESTLib.blahblah
From VB, you will must to do this.
Dim thingy As New blahblah
Dim String as string
String = thingy.WhatStringDoIHave
Best Regards....
Carlos Antollini.
|
|
|
|
|
sweet dude! ok it works.. i'm sure that was something simple, but when you dont have a book, things get incredibly stupidly difficult because you dont know what things are.
great, thanks again!
\\\\\\\\
Tim
SHABBA!!
|
|
|
|
|
Can I recommend the book 'ATL Internals' as the *best* ATL book, especially if you already know enough to not need a 'how do' for basic things.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
How could I abort an http download if the connection is too slow?
For instance, if I have this code using MFC_Tear_Sample
void getHttp()
{
CString pszURL = "http://weather.noaa.gov/weather/current/";
CString uneURL;
BOOL bStripMode = FALSE;
DWORD dwAccessType = PRE_CONFIG_INTERNET_ACCESS;
DWORD dwHttpRequestFlags =
INTERNET_FLAG_EXISTING_CONNECT | INTERNET_FLAG_NO_AUTO_REDIRECT | INTERNET_FLAG_RELOAD;
const TCHAR szHeaders[] =
_T("Accept: text/*\r\nUser-Agent: MFC_Tear_Sample\r\n");
FILE *fp1;
int nRetCode = 0;
CTearSession session(_T("TEAR - MFC Sample App"), dwAccessType);
CHttpConnection* pServer = NULL;
CHttpFile* pFile = NULL;
uneURL=pszURL+selEstacion+".html";
try
{
// check to see if this is a reasonable URL
CString strServerName;
CString strObject;
INTERNET_PORT nPort;
DWORD dwServiceType;
if (!AfxParseURL(uneURL, dwServiceType, strServerName, strObject, nPort) ||
dwServiceType != INTERNET_SERVICE_HTTP)
{
MessageBox(0,"Error: Solo se pueden usar direcciones que comiencen con http://","Error en URL",MB_OK);
ThrowTearException(1);
}
pServer = session.GetHttpConnection(strServerName, nPort);
pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_GET,
strObject, NULL, 1, NULL, NULL, dwHttpRequestFlags);
pFile->AddRequestHeaders(szHeaders);
pFile->SendRequest();
if((fp1=fopen("temp.htm","wb"))!=NULL)
{
TCHAR sz[1024];
while (pFile->ReadString(sz, 1023))
{
fputs(sz,fp1);
}
httpLeido =TRUE;
}
else AfxMessageBox("No se han podido encontrar, en estos momentos, datos sobre dicha estación");
fclose(fp1);
}
catch (CInternetException* pEx)
{
// catch errors from WinINet
CString szErr;
szErr.Format("Internet Exception Error %d", pEx->m_dwError);
MessageBox(0,szErr,"ERROR",MB_OK);
pEx->Delete();
}
catch (CTearException* pEx)
{
// catch things wrong with parameters, etc
nRetCode = pEx->m_nErrorCode;
TRACE1("Error: Exiting with CTearException(%d)\n", nRetCode);
pEx->Delete();
}
if (pFile != NULL)
{
pFile->Close();
delete pFile;
}
if (pServer != NULL)
{
pServer->Close();
delete pServer;
}
session.Close();
}
|
|
|
|
|
Hey!
I developed an ActiveX control, using ATL, and then packed it inside a CAB file, and signed the file.
Then I created an HTML with the proper <object> tag and everything, and tried it out. Worked great on my Win2k. Also works great on Win98/ME.
Doesn't work on Win95 (IE5) or WinNT4 (IE5.5).
The problem on both platforms seems to be the same - the CAB is downloaded, the "Do you trust..." dialog box appears. I click YES. Then the icon on the top left corner of the rectangle where the control should appear, changes to reflect the fact that the component can't be downloaded.
Since components are downloaded to C:\WINDOWS\Downloaded Programs - I checked this directory - and couldn't find the DLL there!
Perhaps this is the time to mention that my DLL in the CAB has a DLL extension, not OCX (does it / should it matter?)
I also didn't write an INF file. The DLL is the only file contained in the CAB.
Any suggestions?
Thanks,
Oz
|
|
|
|
|