|
First of all you're using a simple Edit box. You need to change its style to "multiline", then you can write multiple lines into it. But if you want to list up a list of URLs the user has entered, I suggest you using a CListBox . It's nice, cute, simple and the best control for your purpose. You can find it in the toolbar as well. You can then add a URL to it with m_listBox.AddString(strURL); .
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thanks David and Greg for your responses.
//You can then add a URL to it with m_listBox.AddString(strURL);.
Greg: When i set the member variable for listbox, is it correct that i set the category to "control"? i set to "value" before and i gave me error.
But there is another problem that appear.
after compling,
IETEST2.exe - 0 error(s), 0 warning(s)
it seems that nothin has happen. The exe doesnt seems to load (pop up).
Anyones who knows what problem is this due to?
I'm a newbie to visual c++. Simpler terms please
|
|
|
|
|
//is it correct that i set the category to "control"?
yes, it is
To the second question:
Seems like there are some rests of your old edit control, try to delete anything in your files dealing with the edit control in case you placed a new ListBox control on the dialog.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Yeah~ Thanks a lot Gerg. I manage to achieve it. But i was hoping to make it into something like this http://www.codeproject.com/listctrl/XListCtrl/XListCtrl1.jpg[^] whereby there can be more than 1 column. Can this be done by list box?
Thanks for the help again.
I'm a newbie to visual c++. Simpler terms please
|
|
|
|
|
Hi
If you want multliple columns you need to use a CListCtrl with LVS_REPORT -style turned on (can be in the control properties. Here's a nice article how to use this control.
But if you want to insert progressbars and checkboxes into your listcontrol, like on the picture, you need to draw all the things yourself, which is quite difficult for a newbie. You can simpler pick one of the custom listcontrol provided - here -.
Remember, a simple CListBox has only one column, whereas you can do a lot of things with a CListCtrl .
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I see. Yeah Thanks for all the help.
I would try my best to learn and play around with it.
Really thanks for all your help
I'm a newbie to visual c++. Simpler terms please
|
|
|
|
|
Erm sorry about it. Mind if i ask another question?
I was wondering how to save the data that was display by the List box? like maybe saving it to a text file?
Thanks for the help again.
I'm a newbie to visual c++. Simpler terms please
|
|
|
|
|
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
|
|
|
|