|
pFrom must be a double-null-terminated string. It is actually the Win32 version of a string list - one null-terminated string after the other, with two nulls to mark the end. The version where you set pFrom to a string literal just happens to work, even though the correct literal is "c:\\dummy.txt\0".
You'll need to set up a character buffer (not a CString because CString does not handle embedded nulls) and use that for pTo.
--Mike--
Just released - RightClick-Encrypt v1.3 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
I had noticed in the documentation that .pFrom (and .pTo) had to be double-null terminated, but I did not realize that CStrings would not handle the nulls. Thanks.
Oh, BTW, it worked with "c:\\Dummy.txt", "c:\\Dummy.txt\0", and "c:\\Dummy.txt\0\0".
However, I confess that I'm lame where string manipulation is concerned. I've fiddled with it and still can't get it to work. Here's what I've got:
fileOp.hwnd = this->m_hWnd;
sSrc = pItem->sCol4;
char szSrc[255];
strcpy(szSrc, (LPCTSTR)sSrc);
int iSize = strlen(szSrc);
strcat(szSrc, "\0\0");
iSize = strlen(szSrc);
fileOp.pFrom = szSrc;
fileOp.pTo = "\0\0";
fileOp.fFlags = FOF_NOCONFIRMATION | FOF_SILENT;
fileOp.wFunc = FO_DELETE;
SHFileOperation(&fileOp);
Ugh! I'm clearly missing something rather fundamental.
Thanks.
|
|
|
|
|
strcat(szSrc, "\0\0"); has no effect. Watch the szSrc array in the memory watch window and you'll see. None of the C string functions work with embedded nulls, because the first null ends the string. What I do is zero-fill the array so no matter how long the actual file name is, there will be zeros after it.
char szSrc[MAX_PATH+1] = {0};
--Mike--
Just released - RightClick-Encrypt v1.3 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Yeah, I noticed that the strcat(szSrc, "\0\0") did nothing.
Thanks for the suggestion (zero filling the array) -- it worked like a charm.
I just don't think I would have ever thought of it.
BTW, I've enjoyed your articles. Keep up the excellent work and thanks a bunch.
|
|
|
|
|
I want to transform a expression to a binary tree but I face some problems. So I need some examples. Where can I find such sources?
|
|
|
|
|
What kind of expression ?
~RaGE();
|
|
|
|
|
|
Ok, if i remember right, someonehas already asked for such a thing. I remember having programed such a thing a long time ago. If u let me 2 days, i´ll find that code back.
Background is simple : you have to parse the expression backwards (i think this was because i´ve used functions such as cos(), so if you are not you may parse it forwards), watch for the parenthesis level (each time a ( is opened, par. level increases an decreases when a ) is found)). Once you get the max level (so you´ll get the first thing to compute regarding operation priority), you look for *+-/ or ^ which are always nodes in the binary tree. Numbers (4, 5647, etc) are always leaves. These operators have two children. Functions like sin() and the - have only one child.
bla bla ... i guess the code will be more explicit Just mail me back in 2 days if i forgot you
Mmmh ... i smell an article ...
~RaGE();
|
|
|
|
|
a google search turned up plenty of them.
-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
|
|
|
|
|
Hi,
I have 2 dialog boxes. Dialog box 'A' will call dialog box 'B'. Both have same list control. If I update list control of dialog box 'B' after it is been called by using dialog box 'A', list control of dialog box 'A' must also update. How do I do it?..Please anybody
|
|
|
|
|
This is bound to be in the FAQ. You need to store a pointer to the other dialog box, so you can interact with the controls. They cannot be synched automatically, you'll need to do it yourself.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
|
|
|
|
|
Another solution (but i warn you the real one is the one with pointer which Christian told you about), is to simply post a user defined message with PostMessage, intercept it with a OnMyMessage function in which you update the list.
~RaGE();
|
|
|
|
|
Hi,
How to save the data from the editable multi-column List Control
to a txt file? Would you please tell me a simple method or a project for doing this?
Thanks in advance!
chen
|
|
|
|
|
Hello,
All of a sudden, I am having this bug. When I open a file with a .raw
extension, the serialize function gets called, file read and everyone is
happy. However, when I try to open another file, .dat, the serialize
function does not get called at all. I put a breakpoint at the beginning of
the function but the code does not even go there.
The function checks the file extension and can handle both file types.
The open file dialog shows both types and I can select either.
It was working fine this morning, and I do not know what happened. I compiled my backup copy from yesterday which I know was working, same thing. However, the same code works just fine on another PC.
I am running windows XP pro.
Any ideas?
Many thanks,
CN
|
|
|
|
|
Probably the extension .dat has been reassociated with another program. Try opening the explorer, right clicking on a .dat file while pressing the shift key, selecting "Open with...", pushing "Another..." and selecting your program.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hello all,
This is code from the MSDN page. I used there code to create Child windows and am a little lost. I made a onFileNew2 and when I click New2 (based on the ID_FILE_NEW2) it runs this code (which by the way is in the Mainframe class of an MDI project)and opens a child window.
I wrote code that opens Bitmaps, but I can't open a bitmap onto this. How coudl I utilise this code to something?? it sure would be nice to use it to open Bitmaps.
Thanks,
And sorry for asking so many questions
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
// Example 1:
// CMainFrame::OnFileNewCMdiChildWnd() is a menu command handler for the
// CMainFrame class, which in turn is a CMDIFrameWnd-derived class.
// It shows the creation of a standard Windows MDI child window using
// the registered CMDIChildWnd class.
void CMainFrame::OnFileNewCMdiChildWnd()
{
CMDIChildWnd* pMDIChildWnd = new CMDIChildWnd;
VERIFY(pMDIChildWnd->Create(
NULL, // standard CMDIChildWnd class
_T("My MDIChildWnd"), // caption of MDI child window
WS_CHILD | WS_VISIBLE |
WS_OVERLAPPEDWINDOW, // window styles
rectDefault, // default rectangle size
this)); // parent window; can be NULL
// the default PostNcDestroy handler
// will delete this object when destroyed
}
|
|
|
|
|
OK I am creating a EMF/WMF DC
if I pass in a a filename to the CreateEnhMetaFile/CreateMetaFile
function and then use the resulting DC
to draw with and draw text on it, no text shows up
when I load the file in a program like PowerPoint, etc
(though curiously the File Open Dialog's preveiw does
show the text IF I output a WMF - nothing for a EMF)
Now if I create the meta file with a NULL filename (which
according to the docs is supposed to make one on memory)
and then say copy it to the clipboard and paste it into
PowerPoint all is good.
Any clues ? I have wasted the better part of an afternoon in
extreme frustration so any help would be much appreciated !
Thanks
|
|
|
|
|
Hmm, can't say i know off the top of my head... Never had that problem (you're not using white as the text color or something are you )...
Would you care to try narrowing down the code to a few lines that still show the problem & posting that?
- Shog9 - Aaah... It's time to relax. You know what that means: a glass of beer, your favorite ergo chair... And of course, The Code Project loaded on your Personal Computer System. So go on, and indulge yourself, put your feet up. Lean back and just enjoy the articles. After all, CP sooths even the savage
|
|
|
|
|
can anyone tell me how to use printpreview() , i couldn't find any example in c++ but vb.
in vb,
worksheets sheets;
sheets.("sheet1").printpreview
what bout in vc++?
I had tried,
worksheets sheets;
sheets.PrintPreview(COleVariant((short)TRUE));
but i can't view the printpreview.
|
|
|
|
|
how can i call a win32 console application from dialog based application.
let's say, win32 console application takes an argument... like CString or char[ ]
how can i calling console app and passing an argument at the same time from the dialog based application??
|
|
|
|
|
ShellExecute or ShellExecuteEx
HINSTANCE ShellExecute(
HWND hwnd,
LPCTSTR lpOperation,
LPCTSTR lpFile,
LPCTSTR lpParameters,
LPCTSTR lpDirectory,
INT nShowCmd
);
-- or --
BOOL ShellExecuteEx(
LPSHELLEXECUTEINFO lpExecInfo
);
typedef struct _SHELLEXECUTEINFO{
DWORD cbSize;
ULONG fMask;
HWND hwnd;
LPCTSTR lpVerb;
LPCTSTR lpFile;
LPCTSTR lpParameters;
LPCTSTR lpDirectory;
int nShow;
HINSTANCE hInstApp;
// Optional members
LPVOID lpIDList;
LPCSTR lpClass;
HKEY hkeyClass;
DWORD dwHotKey;
union {
HANDLE hIcon;
HANDLE hMonitor;
};
HANDLE hProcess;
} SHELLEXECUTEINFO, *LPSHELLEXECUTEINFO;
That will do it
Sjoerd van Leent
LPCSTR Dutch = "Double Dutch "
|
|
|
|
|
but how?
for my dos based application, which takes 3 arguments,
<br />
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])<br />
is lpParameters will be the one i should set for my an argument?
what about int argc and the third parameter envp in main?
I dont' really understand because I have never call any applications from one applications.
thanks
|
|
|
|
|
This is how I had tried but it is not working!
the following code is in the dialog based application
<br />
void DialogBasedApp::OnTesting()<br />
{<br />
SHELLEXECUTEINFO lpExecInfo;<br />
const char* verb = "open";<br />
lpExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);<br />
lpExecInfo.lpFile = "c:\\printExcel\\Debug\\printExcel.exe";<br />
lpExecInfo.fMask=SEE_MASK_DOENVSUBST|SEE_MASK_NOCLOSEPROCESS ; <br />
lpExecInfo.hwnd = NULL;<br />
lpExecInfo.lpVerb = verb; <br />
lpExecInfo.lpParameters = "c:\\testing.xls";<br />
lpExecInfo.lpDirectory = NULL;<br />
lpExecInfo.nShow = SW_SHOW ; <br />
lpExecInfo.hInstApp = (HINSTANCE) SE_ERR_DDEFAIL ;
ShellExecuteEx(&lpExecInfo); <br />
if(lpExecInfo.hProcess != NULL)<br />
{<br />
::WaitForSingleObject(lpExecInfo.hProcess, INFINITE);<br />
::CloseHandle(lpExecInfo.hProcess);<br />
}<br />
MessageBox("Finished Printing Excel");<br />
}<br />
my dos based application, which is called printExcel.cpp, is right below
<br />
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])<br />
{ <br />
AfxMessageBox(argv[0]);<br />
return 1;<br />
<br />
}<br />
Honestly, i don't even know how to get the argument so no doubt that i have no idea where the program got wrong.
can you tell me what and where it got wrong and how to fix it, please.
|
|
|
|
|
Hi Win,
In this line:
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
is actually all you need. The 'argc' is the number of items specified on the commandline.
The array argv are all commandline arguments (including the name of the executable itself, printExcel.exe).
You can retrieve every argument by just using the index in the array:
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
CString strArgument;
for (int i = 0; i < argc; i++)
strArgument = argv[i];
} // Not compiled, assuming it's correct
--
Alex Marbus
www.marbus.net
But then again, I could be wrong.
|
|
|
|
|
I see two odd things here.
First, how can you call AfxMessageBox in a DOS-based app ? If it is really a DOS app then shouldn't you use printf ? You can add a getch() to see what the console window says before it closes.
FWIW, argv[0] will be the name of the executable always, regardless of what args are passed.
argv[1] will be the first passed argument and argc will tell you how many were passed. I think this has been said already but I will reiterate. Here is a loop to print out all passed args except for the exe's name (which is why we start at 1) :
for( int index = 1; index < argc; index += 1 )
fprintf( stdout, "arg %d is '%s'\n", index, argv[index] );
Second is a stylistic issue. You appear to be using Hungarian notation. Well, lp stands for long pointer and you have an instance of the structure so it is not a pointer.
|
|
|
|
|