|
You don't have to include headers - just use declaration syntax, such as:
<br />
class A;<br />
class B<br />
{<br />
friend class A;<br />
}<br />
---------<br />
class B;<br />
class A<br />
{<br />
friend class B;<br />
}<br />
Igor Green
http://www.grigsoft.com/ - files and folders comparison tools
|
|
|
|
|
Well it is working ,so I guess it is a solution but what if I want to grant just one function,
in porpuse of grant access not to all private members
you can look at the above situation I wrote in reply for cristian.
Thanks.
Nir
|
|
|
|
|
I have a host, asume it is:
name: www.myhost.com
ip: 111.222.333.444 (I got it from cPanel)
when I pass both as server param to MFC class CFtpConnection and get the same contents.
questions:
1) how to get name (www.myhost.com) if I only know ip address and vise verse?
2) If I set a link on html file, such as:
<a href="http://www.myhost.com">link</a>
the page (index.html) can be loaded.
but for link
<a href="http://111.222.333.444 ">link</a>
the page can not be found.
why?
thx
includeh10
-- modified at 17:03 Tuesday 15th November, 2005
|
|
|
|
|
You could use the existent API for that:
gethostbyname and gethostbyaddr
What you are looking for is either resolving a domain name into an IP address or resolving an IP address into domain name
Have a look here (eventhough is a VB page, it uses the same API):
http://www.activeserverpages.su/redir.asp?link=http://www.vbip.com[^]
SkyWalker
-- modified at 17:26 Tuesday 15th November, 2005
|
|
|
|
|
CString csAdd="111.222.333.444"; //assume
int iType=AF_INET;
HOSTENT*ph=gethostbyaddr(csAdd,csAdd.GetLength(),iType);
the function faield with last error 0x2AFC (no message for it).
why?
includeh10
|
|
|
|
|
The first parameter of gethostbyaddr() is the address as a binary number in network byte order, not a CString . Use the inet_addr() [^] function to convert the address.
|
|
|
|
|
thx, it works now.
is there a function to get ip address from domain name?
includeh10
|
|
|
|
|
MSDN example:
hostent* remoteHost;
char* host_name;
unsigned int addr;
printf("Input name of host: ");
host_name = (char*) malloc(sizeof(char*)*16);
fgets(host_name, 16, stdin);
if (isalpha(host_name[0])) {
host_name[strlen(host_name)-1] = '\0';
remoteHost = gethostbyname(host_name);
}
else {
addr = inet_addr(host_name);
remoteHost = gethostbyaddr((char *) &addr, 4, AF_INET);
}
if (WSAGetLastError() != 0) {
if (WSAGetLastError() == 11001)
printf("Host not found...\nExiting.\n");
}
else
printf("error#:%ld\n", WSAGetLastError());
SkyWalker
|
|
|
|
|
remoteHost does not contain info of ip address.
includeh10
|
|
|
|
|
|
While working with windows forms, in Visual C++.net there are three options for TextAlign for a TextBox: Right, Left, Center. What about justified or blocked style text for the multi line option? Is it somewhere in the TextBox Base class? If not, I could code my own, but was wondering if it was already out there somewhere. Seems there is not much on the subject.
Thanks,
RRL
|
|
|
|
|
sveige wrote: What about justified or blocked style text for the multi line option?
That would require a rich edit control.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
I would like to embed XML files in my MFC project so that they are linked into the executeable rather than installed with the application.
The XML files should than be used to fill combo boxes etc.
Has anyone used this way to embed language files (instead of string tables or dlls)?
Thanks
Andre
|
|
|
|
|
The only I know to do this is as a resource. See RT_RCDATA for more.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
I am working on accessing a directory to copy its contents (file directory, subdirectories, and all files) to another folder, which would be created via the program (eg C:\test), my question is that knowing I need to employ recursive direcotry copying what code should I look at using. I am avoiding .Net framework, and sticking to basic win32 calls. So far I have thought of using:
[CODE]RecursiveCopyFolder(CString csPath, CString csNewPath)
{
BOOL bRet = TRUE;
if( !CreateDirectory(csNewPath, NULL))
bRet = FALSE;
CString csPathMask;
CString csFullPath;
CString csNewFullPath;
csPath += _T("\\");
csNewPath += _T("\\");
csPathMask = csPath + _T("*.*");
WIN32_FIND_DATA ffData;
HANDLE hFind;
hFind = FindFirstFile(csPathMask, &ffData);
if (hFind == INVALID_HANDLE_VALUE){
return FALSE;
}
// Copying all the files
while (hFind && FindNextFile(hFind, &ffData))
{
csFullPath = csPath + ffData.cFileName;
csNewFullPath = csNewPath + ffData.cFileName;
[/CODE]
I don't know though... Am I on the right track? This seems to make sense to me, but it is not cooperating. I know that I will need to employ this in order for my project to work, so I am trying to ask around to get a better idea of whats out there. Thanks.
Rob
|
|
|
|
|
bobfilar wrote:
my question is that knowing I need to employ recursive direcotry copying what code should I look at using.
Use SHCreateDirectoryEx() and SHFileOperation() for this.
bobfilar wrote:
I am...sticking to basic win32 calls.
Using MFC is not considered basic Win32.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
U'll have to fix few things:
1. CreateDirectory works only one dir down from an existing dir so u have to write your own function that splits the path on '\\' and create "C:\\a", then "C:\\a\\b" and then "C:\\a\\b\\c" and so on
2. FindFirstFile may return INVALID_HANDLE_VALUE if there are no files to match the mask - returning FALSE isn't always the right thing to do
3. After FindFirstFile the output struct contains the first file's details so writing FindNextFile right after that skips the first file.
4. U must filter out the "." and ".." directories (yes they still exist..)
5. U must check the attributes and recurse directories
6. Use unicode - u know files can have weird names
|
|
|
|
|
At runtime, is it possible to set the (+) for a tree item even if there are no children under that item ?
I'm doing the following :
BOOL bRet = m_Tree.SetItemState( hMyItem, TVIS_EXPANDED , TVIS_EXPANDED );
I have a large dataset that will be inserted in a tree hierarchy, and I am only inserting items in the tree when the user clicks on a node that will display leave items (instead of inserting them when I load the file ) ; but I need to show the user that there are items under that collapsed node.
for example :
Root
|
+ Item1
+ Item2
|
- SubItem2
Thanks.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
How about adding a 'dummy' item so that the '+' is shown, and then when it is clicked, remove the 'dummy' item and insert the real items? Would that work?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Check out the TVITEM::cChildren member, specifically the I_CHILDRENCALLBACK flag.
Causes the control to use the TVN_GETDISPINFO notification message to check whether the '+' needs to be displayed or not.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
Thank you both ( David and PJ ) I will look at this tomorrow morning .
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Hi,
I've written an application (SDI), which runs a thread in my derived CWinApp class. The thread is mainly for collecting data from a RS232 Interface. Sometimes I want to assign parts of this data to variables in my document class (for storing and displaying).
How can I adress these variables?
I know that it somehow works with the DocTemplate pointer m_pDocManager->GetFirstDocTemplatePosition() but I don't know the correct syntax. Can anybody give me a short introduction?
Thanks for your help.
|
|
|
|
|
The document can be accessed from anywhere like:
AfxGetMainWnd()->GetActiveDocument(); It can be accessed from the main application object like:
GetMainWnd()->GetActiveDocument();
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Thanks for your help. But I still have a problem. GetActiveDocument() is not a member of CWnd. With GetMainWnd() I can only access GetActiveWindow(). What is my mistake? Do I have to do a type cast? I've tried the following:
CFrameWnd* pFrame = (CFrameWnd*)GetMainWnd();<br />
CMyDocument* pDoc = (CMyDocument*)pFrame->GetActiveDocument();<br />
pDoc->myVariable = myValue;
With this code I don't get a compile error but a runtime error;
|
|
|
|
|
Franken wrote: GetActiveDocument() is not a member of CWnd.
Right, it's part of the frame.
Franken wrote: With GetMainWnd() I can only access GetActiveWindow().
Not necessary in this case.
Franken wrote: With this code I don't get a compile error but a runtime error;
Which is?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|