|
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
|
|
|
|
|
|
Hi,
I have two objects, both point to each other in OO.
e.g.
Class Father
{
private int id; //id of father
private Son son;
}
Class Son
{
private int id; //id of Son
private Father father;
}
so I need to have two tables in database as follow,
Table Father :
(id, SonId)
Table Son :
(id, FatherId)
The problem is, should I eliminate the one of the reference in one of the table, e.g.
Table Father :
(id)
Table Son :
(id, FatherId)
so I just have the fatherID in the son table.
But if I remove the sonID from the father table,
I need to join the two tables when I retrieve fathers
from the father table.
So what are the pros and cons of the two schema design ?
Thanks
|
|
|
|
|
If you keep the references in both the tables, you can improve the efficiency by eliminating joins. You can find all 'children' of a 'father' and vice versa by a simple query on a single table.
The down side however is an additional overhead in maintaining the redundant data consistently. You need to make sure to update the respective fields whenever any child is to be deleted or the other way. Just see what is preferable for your application, efficiency or simplicity...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
I am trying that my program does some task before calling MFC class:
#include <afxwin.h>
class MFC_Window :public CFrameWnd
{
public:
MFC_Window()
{
Create(NULL,_T("whatever"));
}
};
class MyApp :public CWinApp
{
MFC_Window *wnd;
public:
BOOL InitInstance()
{
wnd = new MFC_Window();
m_pMainWnd = wnd;
m_pMainWnd->ShowWindow(1);
return 1;
}
};
int main ()
{
// some tasks...
if (some tasks == true) MyApp theApp;
}
Calling MFC from main() does not work. Does anybody know how to do this? Or how to put the MFC as not visible?
Thanks,
Christian
|
|
|
|
|
Just for clarity, MFC is not a class nor is it callable.
What exactly is it that you are wanting to do prior to displaying any sort of window?
Deriving from CFrameWnd indicates that you are working on an application. Thus you'll not be able to use main() .
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
If I understand u correctly u want to do things before showing the main window.
To do this u don't have to mangle with main(), WinMain() nor constructing MyApp yourself. All u have to do is put some code in MyApp::InitInstance() before the window creation/show.
Just to comment few other things:
First, the way u try to initialize MyApp is invalid syntax.
If u follow the MFC App Wizard, MyApp is created on the "global stack" - the standard library initializes it before calling main().
Second, u can track down MFC's WinMain (just look at the call stack) and alter it. But your code will not run there unless u compile MFC itself.
HTH
|
|
|
|
|
Thank you for your replies.
Yes, what I am trying to do is to do things before showing the main window, or not to show it at all. My programm enumerates NFC boards, and if it detects more than 1, a window should pop up and ask user to select one of them. If it only finds one board, the app should select that board and the window shouldnt pop up.
I tried to set the visible property to false, but nothing happened!?!? The only thing I can imagine is that the release build wont show the window, I dont know and didnt try it.
Thanks
|
|
|
|