|
No problem
This is for a listbox:
for(int i=0; i<listbox.GetCount(); i++)
{
CString text;
listbox.GetText(i, text);
-> write "text" into a file
}
And for a listctrl:
for(int i=0; i<listctrl.GetItemCount(); i++)
{
for(int j=0; j<NUM_COLUMNS; j++)
{
CString text;
text = listctrl.GetItemText(i, j);
-> write "text" into a file
}
}
NUM_COLUMNS a constant value for the number of columns. YOu can write into the file via CFile for example.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi Greg,
i paste the code
for(int i=0; i<m_listbox.getcount(); i++)
="" {=""
="" cstring="" text;="" m_listbox.gettext(i,="" text);="" -=""> write "text" into a file
}
inside "void CIETEST2Dlg::OnNavigateComplete2Explorer1(LPDISPATCH pDisp, VARIANT FAR* URL)"
but it gave me this error
error C2143: syntax error : missing ';' before '->'
Error executing cl.exe.
IETEST2.exe - 1 error(s), 0 warning(s)
//did i do it the correct way ?
thanks for the help.
I'm a newbie to visual c++. Simpler terms please
|
|
|
|
|
In what line does the error exactly occur?
I hope you did not copy the line -> write "text" into a file into your source. That's just a placeholder for the code responsible for writing the text into the file.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi greg,
"I hope you did not copy the line -> write "text" into a file into your source. That's just a placeholder for the code responsible for writing the text into the file." <-- haha. i really did that. silly me.
So i manage to compile and the everything goes well. But i didn't see any text file being created, having those data in the controlbox. Did i miss out something? (i was hoping like making a log of those navigation from the listbox;))Thanks again.
I'm a newbie to visual c++. Simpler terms please
|
|
|
|
|
Hi
Yes, you forgot to replace the placeholder with the actual code that writes the string "text" into a file
The easiest way is to use a CStdioFile() . You can then easily write to the textfile with WriteString(text); . The MSDN has a nice example.
You can find here
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi greg,
that's the easiest? Looks like it is quite advance for me
But thanks for your help. Your the best!
I'm a newbie to visual c++. Simpler terms please
|
|
|
|
|
No problem
I suggest you buying a book, you'll quickly get all the basics and will understand how MFC (and winapi) works, actually some things are really easy to do with MFC.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hiya, I have set up 2 test dialogs apps for passing info between them. I am calling the second app with CreateProcess() e.g
PROCESS_INFORMATION ProcessInfo;
STARTUPINFO StartupInfo;
ZeroMemory( &StartupInfo,sizeof(StartupInfo) );
StartupInfo.cb = sizeof( StartupInfo );
if( CreateProcess("\\MyApp1.exe","TestString",
NULL,NULL,FALSE,0,NULL,
NULL,&StartupInfo,&ProcessInfo ))
{
WaitForSingleObject( ProcessInfo.hProcess,INFINITE );
CloseHandle( ProcessInfo.hThread );
CloseHandle( ProcessInfo.hProcess );
}
else
{
cout << "Error - Opening Process..";
}
This is ok. The problem is when in the SECOND APP, I try to output the lpCommandLine parameter. I do this in the InitInstance() of the second app e.g
BOOL MyApp1::InitInstance()
{
CString str = GetCommandLine();
AfxMessageBox(str);
}
But it doesn't output the message box at all. It runs the second app but doesn't display the message box..
Any Ideas on this??
Thanks.
|
|
|
|
|
It may be because the second app's main window has not been created by the time AfxMessageBox() is called. Replace AfxMessageBox() with TRACE() and see what happens, or save the return value from GetCommandLine() to a member variable and call AfxMessageBox() later.
|
|
|
|
|
It sounds ugly but even though that doesn't exist in MSDN documentation (or at least I couldn't find an answer even though I searched a lot for it): If you change the commandline parameter of the CreateProcess call to reflect the executable AND the commandline both, it is going to work.
i.e:
<br />
CreateProcess("app.exe", "somecommandlineparameter", ...)<br />
doesn't work, but:
<br />
CreateProcess("app.exe", "app.exe somecommandlineparameter", ...)<br />
works. And I frankly don't know why.
|
|
|
|
|
How to do contextual menu ?
I think it is very easy, but I haven't got any idea
Please help
|
|
|
|
|
Look for examples of CMenu::TrackPopupMenu().
|
|
|
|
|
Hello,
In my OnDraw() function, I get the width of the page using:
int cWidthPels = GetDeviceCaps(pDC->m_hDC, HORZRES);
It works very well when I print for real, but it doesn't works when I want to draw the print preview.
When OnDraw() is called for the print preview, GetDeviceCaps() returns the width of the screen in pixels.
I want to get the size of the page (width and height) in inches for both: printing and print preview.
How can I do that ???
Is there a mean to know if OnDraw is called for printing or print preview ? and how ?
Thanks for your help,
|
|
|
|
|
bumper wrote:
Is there a mean to know if OnDraw is called for printing or print preview ? and how ?
pdc->IsPrinting() will tell you
-c
|
|
|
|
|
pdc->IsPrinting() returns TRUE for real printing (printer dc) and for print preview (screen dc).
So it can't help me
|
|
|
|
|
The CPrintInfo class (passed to your view's OnPrint override) has a member m_bPreview that is set to TRUE when in Print Preview mode and FALSE when really printing. Additionally, you can override OnBeginPrintPreview and OnEndPrintPreview if you need to do more *advanced* setup for preview mode.
|
|
|
|
|
|
i have a CRichEditCtrl that needs to render to a metafile DC. i create the metafile DC using a screen DC as the "reference device". then i render the contents of the rich text ctrl into the metafile using FormatRange/DisplayBand. the code i have works fine, with one catch:
if the vertical position of the text in the rich text ctrl is larger than the vertical resolution of the screen (ie. if i tell the rich text control to draw text into the metafile DC at (100,1000) and the screen is only 1152x864), the text is clipped. the rich text control is obviously looking at the screen DC resolution and saying "hmm, i must be off the bottom of this DC. there's no need to draw those characters". but, in fact, it's not out of bounds on the metafile DC, since that is created without a bounding rect.
so, my question is... is there a way to create an off-screen DC with an arbitrary height ?
remember, this isn't a CDC+CBitmap issue, this is a metafile DC; i don't think creating and selecting a large bitmap into the metafile DC is going to do anything but waste resources (could be wrong).
-c
|
|
|
|
|
Hi folks,
does anyone know how to change the property page caption inside a Property sheet in MFC? the PropertyPage::SetWindowText does not work, neither changing LPCREATESTRUCT in PropertyPage::OnCreate. This caption is inherited by the property page dialog resource but there should be a way to change it at run-time...
Thanx a lot.
Regards,
andrea
|
|
|
|
|
I'm using this before adding the property page to the property sheet...
MyPP.m_psp.dwFlags |= PSP_USETITLE;
MyPP.m_psp.pszTitle = "The new title..."; Hope this helps
|
|
|
|
|
UAO IT WORKS!!!
Thanx a lot
Regards
andrea
|
|
|
|
|
Hi,
well in the constructor of your derived CPropertyPage try this code:
<br />
m_strCaption = m_aToolText.Anzeige(1);<br />
m_psp.pszTitle = m_strCaption;<br />
m_psp.dwFlags |= PSP_USETITLE;<br />
m_strCaption is a CString variable you must provide. The text to dbe displayed comes from elsewhere or you put in directly.
m_psp is variable/struct for the proprety sheet, and is already defined in the base class by the MFC.
I think you can change m_strCaption afterwards any way you want. But havn't tried this one out.
hope this helps
G. Steudtel
|
|
|
|
|
If I have a path as the next: "\\RESOURCE\\PathToRetrieve" in the Network domain "WORKGROUP", how can I split it in multiple directory for to create a tree path to reach it?
Excuse me for my English.
Thanks to all for help,
Margaria Ivano
|
|
|
|
|
Are you talking about the splitpath() function?
|
|
|
|
|
In Eplorer if you write a path in the toolbar and press ENTER the tree of the explorer go to the folder typed.
I have to do something like that.
Margaria Ivano
|
|
|
|