|
the app code is below .i could find any problem, why it isn't work.
BOOL AppFileOperator(LPCSTR lpszSrc, LPCSTR lpszDest, int op)
{
SHFILEOPSTRUCT stFileOP;
string strsrc = lpszSrc;
string strDesc = lpszDest;
stFileOP.pFrom = strsrc.c_str();
stFileOP.pTo = strDesc.c_str();
stFileOP.wFunc = op;
stFileOP.fFlags = FOF_SILENT | FOF_NOCONFIRMATION;
printf("Start to file operator. \n src file : %s\n, desc file is %s\n",
strsrc.c_str(), strDesc.c_str());
return SHFileOperation(&stFileOP) == 0 ? TRUE : FALSE;
}
|
|
|
|
|
If you have a look in the documentation for SHFILEOPSTRUCT, you'll see that pFrom and pTo both need to be double null terminated strings, which the std::string::c_str() operator won't give you.
A couple of minor points too - you should really initialise the entire SHFILEOPSTRUCT structure, and your code isn't UNICODE safe (but I'm assuming that's not an issue for you).
So, one possible version of this code would be (N.B. code is untested):
BOOL AppFileOperator(LPCSTR lpszSrc, LPCSTR lpszDest, int op)
{
SHFILEOPSTRUCT stFileOP={0};
char* pFrom = new char[strlen(lpszSrc)+2];
char* pTo = new char[strlen(lpszDest)+2];
strncpy(pFrom, lpszSrc, strlen(lpszSrc)+2);
strncpy(pTo, lpszDest, strlen(lpszDest)+2);
stFileOP.pFrom = pFrom;
stFileOP.pTo = pTo;
stFileOP.wFunc = op;
stFileOP.fFlags = FOF_SILENT | FOF_NOCONFIRMATION;
printf("Start to file operator.\n src file : %s,\n dest file is %s\n", lpszSrc, lpszDest);
BOOL bSuccess = (SHFileOperation(&stFileOP) == 0);
delete[] pFrom;
delete[] pTo;
return bSuccess;
}
"We are the knights who say Ni" (The Knights Who Say Ni)
|
|
|
|
|
thanks, a good man. ..... i'm a lazy boy
|
|
|
|
|
hi all,
i have to insert some voice data in existing wave file
for that
1.i opend the wave file by using mmioOpen in ReadWrite mode then
2.Read all the header to conform the wave file then
3.i tried to move the cursur position to particular portion in a wave file by using mmioSeek with SET_SEEK( it is failing ) then
4.i am getting the data by using wave functions then
5.i am using mmiowrite function to write the collected data in a particular portion of existing wave file
can any one help me why the mmioseek function fails
and is there good procedure to do this
thanks in advance
anju
|
|
|
|
|
hi All
I want to display text in a window (with scroll bars). I need to trap the user mouse clicks inside the control (line number where mouse was clicked ...like that).
how can i do it...
thanx
|
|
|
|
|
easy.
inherited from CEdit (if u use) to i.e. MyEdit
change member var from CEdit to MyEdit (even u use data exchange)
handle all messages in MyEdit.
includeh10
|
|
|
|
|
hi All
I want to display text in a window (with scroll bars). I need to trap the user mouse clicks inside the control (line number where mouse was clicked ...like that).
how can i do it...
thanx
|
|
|
|
|
handle WM_LBUTTONDOWN (use the class wizard to set up the function for you). this will tell you when a click happens, and where it happened.
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
thanx chris
but can i handle this event in Edit Control?
harish
|
|
|
|
|
Can i use CSocket in thread? If so how?
i wana to use many instance of CSocket in thread in my program to send email.
i try the MSDN way of Attach() and then Detach(),but that method do not work.
help me and thank you!
|
|
|
|
|
|
to Nishant S
thanks for your advice!but i really want to know how to use CSocket with threads!;)
|
|
|
|
|
yes, you can, no problem.
Just don't use the same instance in multiple thread contexts. A CSocket or CAsyncSocket instance can only used in one thread context... compile in debug version and you will get asserts if you brake this rule.
|
|
|
|
|
Hello, the codegurus around the world.;)
Technically possible to use the thread in CSocket program, but
it might be conflicted to the process of GUI stuff.
CAsynSocket class is more flexiable than CSocket, and CAsynSocket
can deal with the socket process asyncriouly. This means that CAsynSocket
can deal with the mutiple sockets without thread.
At the same time, the timer process can check some socket statuses more
easily without thread.
Please, don't send me your email about your questions directly.
Have a nice day!
Sonork - 100.10571:vcdeveloper
-Masaaki Onishi-
|
|
|
|
|
I need a user interface for my program which is simple yet useful. The program is an editing program where there are many parameters each of which the user needs to edit. I've made a a page that descrives 3 ideas that I've come up with so far. Sorry about the many spelling mistakes. Also keep in mind that the average user will probably be 12-18 years of age so it needs to be simple. The site is [here]. Thanks.
-Raffi
|
|
|
|
|
I have a few questions?
I am a little lost on the concept of 1 and Yes, as in "It would display 1 in stead of Yes". Could you explain what you are talking about? Maybe I am dense and everyone else understands it.
Will there be multiple names (manufacturers?) that will be edited? If so, I would use a list control set up in report mode...or a grid control that is setup to edit individual cells (like a spreadsheet). It gets tedious to input lots of data for multiple names (manufacturers) using a dialog box and edit controls.
You are allowing the user to specify any arbitrary category they desire. Is this what you want? Or are there a fixed number of specific categories for the user to choose from? If so, consider using a combobox.
In general, you want to make it as easy as possible to enter the data. Tabbing between fields in a list control or grid control is easier than popping up a dialog each time new entry is to be made...In other words, pop it up once and let the user enter multiple entries.
An example of what I am talking about is a checkbook program like Quicken.
Gary Kirkham
A working Program is one that has only unobserved bugs
|
|
|
|
|
For the 1 and Yes thing, when it reads it from a file, it reads it as a 1 or a 0, which means yes or no. If it was the edit box ui then it would display 1 or 0, if it was one of the other 2 ui's it would display yes or no.
-Raffi
|
|
|
|
|
For a state that is either 1 or 0
eg True or False wouldn't a check box be the best type of control to use.
And a combo dropdown box be best for the other fields ?
Regardz
Colin J Davies
Sonork ID 100.9197:Colin
I am sick of fighting with Martin, I think I will ignore his posts from here on in, and spend the time working on articles instead.
Christian Graus
|
|
|
|
|
I'm looking for sample code on implementing Listview printing using SDK style programming.
|
|
|
|
|
I tried:
CTrain1View * pView = (CTrain1View *)GetActiveView();
pView->m_listdisplay.ShowWindow(SW_SHOW);
in a mainframe handler, where m_listdisplay is a listcontrol in the view,. Compiles fine but crashes when run....memory could not be read.
CAn you please tell me what I'm doing wrong?
Thanks very much,
ns
|
|
|
|
|
In what function are u doing so? is the control already constructed, or is it destructed after ure doing this?!!?!
Check it out!
Papa
Murex Co.
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
i think it's depends on proc your are calling "ShowWindow" from.
window must be created before to show it (:
----------------
muaaa ..
i have no time to do something good ):
|
|
|
|
|
Are you checking m_listdisplay.m_hWnd to ensure the control is a valid window?
|
|
|
|
|
I found that:
CTrain1View * pView = (CTrain1View *)GetActiveView();
if(pView == NULL) AfxMessageBox("trouble");
pView is NULL. I dont even reach the line where I'm trying to get at the control (which probably isnt created yet).
The trouble I had was that I can only modifymenu with the sample i have, if I call it from MAinFrame class menu handler. (My coding inexperience)
CString str;
CString str1 = "Display2";
CString str2 = " Save selection ???";
mmenu->GetMenuString(ID_DISPLAY2, str, MF_BYCOMMAND);
if (str == str1)
{
// m_listdisplay.ShowWindow(SW_SHOW);
mmenu->ModifyMenu(ID_DISPLAY2, MF_BYCOMMAND,ID_DISPLAY2, " Save selection ???");
pMain->DrawMenuBar();
}
if (str == str2)
{
mmenu->ModifyMenu(ID_DISPLAY2, MF_BYCOMMAND,ID_DISPLAY2, "Display2");
pMain->DrawMenuBar();
In response to the menu title changing, in the mainframe handler I'm trying to get the control to get visible in the view. The null pointer is telling me the view isnt active yet, which isnt true since I have seen the gui already (thats where I press the menu to switch titles). I am using another sample that someone gave me to create my view (I need to be switching between views so I use this since it doesnt destroy the hidden view):
BOOL CMainFrame::SwitchView(CMultiDocTemplate *pTemplate, CRuntimeClass *pViewClass)
{
CMDIChildWnd* pChild = (CMDIChildWnd*) MDIGetActive();
if ( pChild == NULL ) return FALSE;
CDocument* pDoc = pChild->GetActiveDocument();
if ( pDoc == NULL ) return FALSE;
CView* pView;
POSITION pos;
pos = pDoc->GetFirstViewPosition();
while( pos != NULL )
{
pView = pDoc->GetNextView( pos );
if( pView->IsKindOf( pViewClass ) )
{
pView->GetParentFrame()->ActivateFrame();
return TRUE;
}
}
pChild = (CMDIChildWnd*) pTemplate->CreateNewFrame(pDoc, NULL ); //error here ERROR: Dialog with IDD 0x0082 must have the child style.
if( pChild == NULL ) return FALSE;
pChild->MDIActivate();
pTemplate->InitialUpdateFrame( pChild, pDoc);
return TRUE;
}
ANy pointers would be greatly appreciated,
thanks,
ns
|
|
|
|
|
Two things I learned:
The view doesnt own a menu
2. The mainframe doent have a view, the childframe does.
|
|
|
|