|
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
|
|
|
|
|
Now it works somehow. The runtime error only occur if I try to place this code in the worker thread, not if it is placed somewhere else in the main application class. But I think I can find a solution for that.
Thanks.
|
|
|
|
|
Franken wrote: Now it works somehow.
This is usually a good indication that the problem still exists and has simply been masked or moved to a new location.
Franken wrote: The runtime error only occur if I try to place this code in the worker thread,
Which makes sense as worker threads shouldn't be accessing such information. See these two articles for more on threads and how they are supposed to communicate back and forth with the primary thread.
http://www.flounder.com/workerthreads.htm
http://www.flounder.com/uithreads.htm
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Hi All,
Can you guys please help me resolving this error?
Thanks in advance
Preeti9
|
|
|
|
|
You've not provided enough information. See here for possibilities.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Sorry for not providing enough info...
Here are the errors listed:
[code]
Linking...
MSVCRT.lib(MSVCRT.dll) : error LNK2005: __vsnprintf already defined in LIBCMT.lib(vsnprint.obj)
MSVCRT.lib(MSVCRT.dll) : warning LNK4006: __vsnprintf already defined in LIBCMT.lib(vsnprint.obj); second definition ignored
Creating library ReleaseMinSize/WosaIDC.lib and object ReleaseMinSize/WosaIDC.exp
LINK : warning LNK4098: defaultlib "MSVCRT" conflicts with use of other libs; use /NODEFAULTLIB:library
CardReaderDev.obj : error LNK2001: unresolved external symbol _WFSClose@4
CardReaderDev.obj : error LNK2001: unresolved external symbol _WFSDeregister@12
CardReaderDev.obj : error LNK2001: unresolved external symbol _WFMSetTimer@16
CardReaderEvent.obj : error LNK2001: unresolved external symbol _WFMSetTimer@16
CardReaderOper.obj : error LNK2001: unresolved external symbol _WFMSetTimer@16
CardReaderDev.obj : error LNK2001: unresolved external symbol _WFSRegister@12
CardReaderDev.obj : error LNK2001: unresolved external symbol _WFMSetTraceLevel@8
CardReaderDev.obj : error LNK2001: unresolved external symbol _WFSOpen@36
CardReaderDev.obj : error LNK2001: unresolved external symbol _WFMKillTimer@4
CardReaderEvent.obj : error LNK2001: unresolved external symbol _WFMKillTimer@4
CardReaderOper.obj : error LNK2001: unresolved external symbol _WFMKillTimer@4
CardReaderDev.obj : error LNK2001: unresolved external symbol _WFSFreeResult@4
CardReaderEvent.obj : error LNK2001: unresolved external symbol _WFSFreeResult@4
CardReaderOper.obj : error LNK2001: unresolved external symbol _WFSFreeResult@4
CardReaderDev.obj : error LNK2001: unresolved external symbol _WFSExecute@20
CardReaderDev.obj : error LNK2001: unresolved external symbol _WFSGetInfo@20
CardReaderOper.obj : error LNK2001: unresolved external symbol _WFSCancelAsyncRequest@8
CardReaderOper.obj : error LNK2001: unresolved external symbol _WFSAsyncExecute@24
CardReaderReg.obj : error LNK2001: unresolved external symbol _WFMCloseKey@4
CardReaderReg.obj : error LNK2001: unresolved external symbol _WFMQueryValue@16
CardReaderReg.obj : error LNK2001: unresolved external symbol _WFMSetValue@16
CardReaderReg.obj : error LNK2001: unresolved external symbol _WFMCreateKey@16
CardReaderReg.obj : error LNK2001: unresolved external symbol _WFMOpenKey@12
LIBCMT.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
ReleaseMinSize/WosaIDC.dll : fatal error LNK1120: 18 unresolved externals
Error executing link.exe.
WosaIDC.dll - 26 error(s), 2 warning(s)
[\code]
I have included all the lib files also..But still I am getting 26 errors.
Thanks again
Preeti9
|
|
|
|
|
Dear u!
do you use Visual C++ 6.0?
you set again Option setting.
Project/Setting/ Link ..
I Hope that is useful to you!
Best regards.
-- modified at 0:56 Wednesday 16th November, 2005
|
|
|
|