|
char *m_pSentences[MAX_SENTENCES_PER_FILE];
but, you'd be much better off using CString or std::string and some kind of container class:
vector< std::string > sentences;
sentences.push_back("this is sentence 1.");
sentences.push_back("this is sentence 2.");
or
CStringArray sentences;
sentences.Add("this is sentence 1.");
sentences.Add("this is sentence 2.");
messing around with multi-dim arrays is more trouble than it's worth, in most cases.
Do the chickens have large talons?
-- modified at 22:42 Monday 17th July, 2006
|
|
|
|
|
Chris Losinger wrote: messing around with multi-dim arrays is more trouble than it's worth, in most cases.
What is it worth?
|
|
|
|
|
it's worth knowing how multi-dim arrays work. not everything can (or should) be put into a vector - strings definitely should.
Do the chickens have large talons?
|
|
|
|
|
Chris Losinger wrote: it's worth knowing how multi-dim arrays work
Trixy answer... I like it!
|
|
|
|
|
I’m trying to create a function that creates an array of strings when reading from a text file.
This object seems to require afxcoll.h to be included and I've included them in my console application, however a couple of errors crop up. I also tried to include it within an MFC application, since this is an MFC class, but they won't compile as well.
Sentences error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in libcpd.lib(newop.obj)
Sentences error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCD.lib(dbgdel.obj)
Sentences error LNK2005: "void __cdecl operator delete[](void *)" (??_V@YAXPAX@Z) already defined in LIBCD.lib(delete2.obj)
Sentences error LNK2019: unresolved external symbol __endthreadex referenced in function "void __stdcall AfxEndThread(unsigned int,int)" (?AfxEndThread@@YGXIH@Z)
Sentences error LNK2019: unresolved external symbol __beginthreadex referenced in function "public: int __thiscall CWinThread::CreateThread(unsigned long,unsigned int,struct _SECURITY_ATTRIBUTES *)" (?CreateThread@CWinThread@@QAEHKIPAU_SECURITY_ATTRIBUTES@@@Z)
Code (to test):
CStringArray strSentences;
strSentences.Add("mary");
strSentences.Add("george");
Any idea why?
Jon
|
|
|
|
|
looks like you're mixing different versions of the C run-time libraries - one or more files in your app are compiled with the single-threaded CRT, but others are built with a different CRT. "new" and "delete" are defined in both, and the linker doesn't know which one to use. so, make all your files/modules/libraries use the same CRT version.
Do the chickens have large talons?
|
|
|
|
|
How would I check the CRT version?
Also, why is the following error being displayed?
Error
.cpp(17): fatal error C1010: unexpected end of file while looking for precompiled header directive
Code example:
#include ".\SentenceAr.h"
#include <string>
#include <iostream>
CSentenceArray::CSentenceArray(string strFileToRead, bool bCreateArray)
{}
CSentenceArray::~CSentenceArray()
{};
Jon
|
|
|
|
|
jon_80 wrote: How would I check the CRT version?
two different places:
project Properties (or Settings) General / Microsoft Foundation Classes
or, C/C+ / Category:Code Generation / Use Run-time Library.
that's VC6. VS03/05 are in similar places.
jon_80 wrote: Also, why is the following error being displayed?
you need to add #include "stdafx.h" to the top of the file.
Do the chickens have large talons?
|
|
|
|
|
Does the project have to be an MFC project or can I include the MFC classes by including files?
I am using a console project to develop the classes because the code is simpler to test that way.
I have tried all the options within VS2003 for Run-time library but the code wouldn't compile in any case.
Also, I could not find stdafx.h, is it because it's not an MFC project?
Jon
|
|
|
|
|
jon_80 wrote: Does the project have to be an MFC project or can I include the MFC classes by including files?
it's far easier to do it from a project that was created to work with MFC than it is to add MFC after the fact. i'm not sure of all the steps, but you'll need to #include some stuff, set some #defines for the compiler, link the appropriate MFC libs, etc..
if you already have a non-MFC project, you might be better off with using std::string and std::vector:
#include < string>
#include < vector>
using namespace std;
...
vector < string > sentences;
sentences.push_back("this is a sentence");
sentences.push_back("this is another sentence");
...
string s = sentences[0];
etc.
Do the chickens have large talons?
|
|
|
|
|
|
Hi fellows
I`m trying to create a treeview in my app but I don`t have any sucess.
I`ve read the Microsoft article [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/treeview/treeview.asp[/url]
and I`ve tried to do something like that. The problem is that whem I create a node in a function that I created it returns NULL. I think that my code is right, so what`s going on??
Thanks for the support.
Below is my code?
I created my treeview like this:
<br />
treeViewHwnd = CreateWindowEx(WS_EX_LEFT, WC_TREEVIEW, "theTreeView", WS_CHILD|WS_VISIBLE|TVS_EDITLABELS|TVS_HASBUTTONS|TVS_HASLINES|TVS_LINESATROOT, 0, 0, 150, 600, hwnd, NULL, hCurrentInstance, NULL);<br />
treeViewHwnd is a global HWND.
In this part I want to put a node in the treeview
<br />
case WM_CHAR:<br />
{<br />
switch(wParam)<br />
{<br />
case 'a':<br />
{<br />
InitCommonControls();<br />
treeViewHwnd = GetDlgItem(hwnd, IDC_TREE1);<br />
OpenedWindows(GetForegroundWindow());<br />
for(int i = 0 ; i < sNameHwnds.size() ; i++)<br />
{ <br />
InsertNodeInTV(hwnd, sNameHwnds[i], 1);<br />
MessageBox(NULL, sNameHwnds[i].c_str(), "", MB_OK);<br />
break;<br />
}<br />
break;<br />
}<br />
.....<br />
And here I create the node:
<br />
#define IDC_TREE1 10<br />
HTREEITEM InsertNodeInTV(HWND tvHwnd, string sNodeName, int iLevel)<br />
{<br />
static HTREEITEM ParentItem, BeforeItem, RootItem;<br />
ParentItem = (HTREEITEM)TVI_FIRST;<br />
BeforeItem = RootItem = NULL;<br />
TVINSERTSTRUCT treeViewInsert;<br />
treeViewInsert.item.mask = TVIF_TEXT;<br />
treeViewInsert.item.pszText = (char*)sNodeName.c_str();<br />
treeViewInsert.item.cchTextMax = sizeof(treeViewInsert.item.pszText)/treeViewInsert.item.pszText[0];<br />
treeViewInsert.hInsertAfter = TVI_ROOT;<br />
treeViewInsert.hParent = NULL;<br />
ParentItem = (HTREEITEM)SendDlgItemMessage(tvHwnd, IDC_TREE1, TVM_INSERTITEM, 0, (LPARAM)&treeViewInsert);<br />
if(ParentItem == NULL)MessageBox(NULL, "aaa", "", MB_OK);<br />
return ParentItem;<br />
}<br />
|
|
|
|
|
Besides the fact that "int iLevel" is not used the rest of the code runs correctly when I have good values like tvHwnd, IDC_TREE1, etc. Therefore I suspect one of your values is incorrect.
|
|
|
|
|
cchTextMax = sNodeName.size()
Kuphryn
|
|
|
|
|
Wow... how did i miss that
|
|
|
|
|
Dear all,
I have MFC application Which As button named Download file ,which pop up a user dialog named "file download". which provides buttons to browse file and start downloading the selected file.
When i press download button it call a dll function to perform the download operation and waits for download to complete.what i need is to close the dialogbox(named file download)whenever the file download completed messagebox pop up .
Manjunath S
GESL
Bangalore
|
|
|
|
|
|
If it's a modal dialog, call EndDialog() . If it's modeless, call DestroyWindow() .
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
and you can se WM_DESTROY
whitesky
|
|
|
|
|
Using the designer to create the main form for an application generated the following code in the .cpp file:
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
System::Threading::Thread::CurrentThread->ApartmentState = System::Threading::ApartmentState::STA;
Application::Run(new DataForm(lpCmdLine));
return 0;
}
The DataForm class has a button which generates a new form:
linkedForm = new LinkedForm() ;
The LinkedForm class exists in the same namespace as the DataForm class.
What needs to be done to allow this child form to see public methods in it's parent, since a DataForm ptr cannot be declared globally? Are there any examples of parent/child form communications of this nature?
Thanks,
MrHonus
|
|
|
|
|
seems this is not a standard MFC program, u might post it to Manage C++/CLI forum.
life is like a box of chocolate,you never know what you r going to get.
|
|
|
|
|
|
Is it CI/C++?
It was created using Visual Studio and .NET, so I guess the answer is yes.
|
|
|
|
|
I have created an ActiveX Control using VC6 with MFC Automation built in. I'm able to add the control to a VB6 form and run it successfully(for most parts : I'm not able to observe any of the events fired within the control). Anyway, the real problem is when I try to use the ActiveX control in a VC6 Dialog based app. it crashes on me at design time, right after I 'Insert ActiveX Control' into the Dialog. It triggers a 'Debug Assertion' within the MS VC6 IDE and then shuts down the IDE. Verrrry frustrating...
I think I may have narrowed it down to the OnDraw method for the control:
Within the Control I have a member called 'configPanel' derived from CDialog, which is used to control runtime settings for the Control. It contains several components: buttons, edit box, check boxes, etc... I've implemented the OnCreate for the Control, as well as for the child 'configPanel'. I'm using the MoveWindow to size and position the 'configPanel'. See code below. This works fine in the VB6 container but won't even place the component in the CDialog container at design time. Note: the code below will work using the GDI functions, but bombs with the 'MoveWindow'. How do I go about rendering the child dialog 'configPane' and its control components(button, edit box, etc...)????
<br />
void CSomeCtrl::OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)<br />
{<br />
CBrush brBackGrn(RGB(255,100,100)); <br />
pdc->FillRect(rcBounds, &brBackGrn);<br />
<br />
CRect rcPanelRect(rcBounds.TopLeft(),CSize(rcBounds.Width(),rcBounds.Height()/4));<br />
<br />
}<br />
Someone please enlighten me!
You are my last, greatest hope...
MissingLinkError
|
|
|
|
|
I am not realy sure the problem but I think you should move:
<br />
CRect rcPanelRect(rcBounds.TopLeft(),CSize(rcBounds.Width(),rcBounds.Height()/4));<br />
configPanel.MoveWindow(rcPanelRect,TRUE);<br />
to OnSize event handler.
|
|
|
|
|