|
preceding is some code I can't get to work. It's a simple structure
I've created and there doesn't seem to be any difference at all with
it and the one in the book I'm studying other than i've got 3
structure variables and the book's example has 2. My only clue is the
book mentions that external structure declaration is necessary to
allow all functions that follow to use it. I did that to start with
and tried placing it inside main as well; coming up with the same
error each time. ms visual studio.net is what I'm using the error I'm
getting is "structure error LNK2019: unresolved external symbol _main
referenced in function _mainCRTStartup" the help on this error isn't
much help to me, it's just too cryptic for me to apply to my problem.
Sorry if this is a really easy problem, it seems like it should be,
but I can't get it to work...
|
|
|
|
|
dont u have to do it like
struct item ksoh{
"kings sword of haste",
25,000
};
struct item gpow =
{
"godly plate of the whale",
278,000
};
struct item demonspike =
{
"legit demonspike",
492,000
};
|
|
|
|
|
i tried your suggestion, it gave me a bunch of "too many intializer" errors. I think using struct creates a structure each time you do it... oh, I created a profile fyi
|
|
|
|
|
This works fine for me:
struct item
{
char name[35];
int price;
};
void main( void )
{
item ksoh =
{
"kings sword of haste",
25000
};
item gpow =
{
"godly plate of the whale",
278000
};
item demonspike =
{
"legit demonspike",
492000
};
cout << "garth's equipment shoppe\n";
cout << "how about a nice " << ksoh.name << "for a mere ";
cout << ksoh.price <<"?\n";
cout << "or\n";
cout << "a high ac " << demonspike.name;
cout << " for only " << demonspike.price;
cout << " could really liven things up when laz is in the house. ";
cout << " be sure to take special note of our 2fer special today: ";
cout << "a " << ksoh.name << " and a burly ";
cout << gpow.name << " would most certainly be essential ";
cout << "if you plan on doing anything significant beyond level 12.";
cout << " on sale today only, a 2fer special of ";
cout << ksoh.price + gpow.price;
cout << "!!\n ";
}
|
|
|
|
|
that did it. comma's in the integer values (something I threw
in because of the other error and never took out). and my last line
statement had an extra cout in it. after I fixed those things it worked fine. Still no idea where the other error came from, or why. I spent forever trying to figure it out and it was a fluke. *frustration* I think I'll re-install, I've had some other unusual problems with it opening up a dos console with no output and then adding the output in the console on a successive build with no changes. Thank you very much for your posts, i appreciate your time!
|
|
|
|
|
I'm trying to adjust my program so it runs in silent mode, meaning it does the work without opening up the main window for the user to click.
I have the following code in my InitInstance function: This code does go to silent mode, but I need to adjust it a bit.
When I get the command line, I want to be able to see if the lpszCmd is "/s",
then run in silent mode, else, run in regular mode(open up the main window).
I dont know how to adjust my program to do that. Is it possible?
BOOL command_line_keys_detected;
LPSTR lpszCmd=GetCommandLine();
// parse lpszCmd
if(command_line_keys_detected)
{
// do all your tasks here
CMainFrame* main = dynamic_cast<cmainframe*>(m_pMainWnd);
main->GetCheckedItems();
CFileProgress dlgPrg;
dlgPrg.DoModal();
return FALSE;
}
|
|
|
|
|
Look at the CCommandLineInfo class. Its ParseParam() method can be overridden to handle your app's specific needs.
|
|
|
|
|
Could anyone give me a code sniplet of how to pass an array of structures (user-defined types) from VBA to a C++ dll. The structure contains various data types: longs, doubles, floats, as well as byte arrays.
Thank you.
|
|
|
|
|
Hi guys,
I was wondering if anyone was successful in changing the height of a header in CListCtrl without Subclassing.
I tried this recommeded method, but did not work as it keeps adjusting the column width and not the height
void CTestListCtrl::SetHeadersHeight( int Height )
{
HDITEM pHeaderItem;
CHeaderCtrl* m_npheader = GetHeaderCtrl();
pHeaderItem.mask = HDI_TEXT | HDI_HEIGHT | HDI_FORMAT | HDI_ORDER;
if( m_npheader->GetItem(0, &pHeaderItem) == FALSE )
return;
pHeaderItem.cxy = Height;
m_npheader->SetItem(0, &pHeaderItem);
}
|
|
|
|
|
say I have a class named MyNewClass
this is how the MyNewClass.h looks
<br />
typedef struct udt{<br />
int val1;<br />
void * thisObj;<br />
}pair ;<br />
<br />
<br />
class MyNewClass {<br />
<br />
<br />
<br />
public :<br />
static pair pairTable[20];<br />
static int pairCount;<br />
};<br />
<br />
<br />
this is how MyNewClass.cpp looks like <br />
<br />
#include "MyNewClass.h"<br />
<br />
<br />
int MyNewClass::pairCount=0;<br />
<br />
static MyNewClass * GetThisObject(int val1)<br />
{<br />
MyNewClass::pairTable[MyNewClass::pairCount].val1<br />
..<br />
}<br />
<br />
<br />
MyNewClass ::MyNewClass(){<br />
<br />
pairTable[pairCount++].thisObj=(void *) this ;<br />
}
I am getting linking error becaus of the line in the constructor !!! What am i doing wrong here ? Please help
|
|
|
|
|
The help text for C2600 pretty much sums it up: your class is missing a default constructor.
class MyNewClass
{
public :
MyNewClass();
static pair pairTable[20];
static int pairCount;
};
|
|
|
|
|
Sorry I forgot to mention , my class does have the constructor specified in the .cpp file .
|
|
|
|
|
Have you defined pairTable in the cpp file as:
pair MyNewClass::pairTable[20];
If you haven't, it will probably result in an unresolved external linker error. If this isn't the problem, post what the actual linker error is - it might make it a bit easier to solve.
Dave
http://www.cloudsofheaven.org
|
|
|
|
|
Thanks I just had to do that . Having done this I'd like to know why this is essential !
|
|
|
|
|
act_x wrote:
Having done this I'd like to know why this is essential
think of it this way: a static member variable (different from a static member function) exists outside the lifetime of any single instance of the class it's declared in. therefore you need to give it a place to live outside the class. by adding that single line to the cpp, you've given it a place to live. the line in the header only tells the compiler "this variable will be of this type, i'll allocate space for it somewhere else".
another way to think of statics is that they're basically global variables that can only be addressed in the context of the class they're declared in: cFoo::myVariable.
-c
|
|
|
|
|
Hello,
I have an application that show multiples forms. They show ok on the task bar with but when there is not more space on the taskbar WinXP group them together and them the name that shows on the taskbar is CMYApp instead of the application title. I don’t have a problem with the grouping but I will like to show the title of my application not CMyApp.
Any ideas?
|
|
|
|
|
What is the title of your application as it should be displayed?
|
|
|
|
|
|
So when there are but a few windows in the taskbar, you see "Payroll Reports" but when there are multiple windows in the taskbar, you see "CMyApp" instead. Is that correct?
|
|
|
|
|
|
Can you provide a few screen shots that exhibit the problem? I've never heard of such a thing.
|
|
|
|
|
Hello,
I have an application that starts with a CListView on the list view the user can click on items and then another frame will show but this time with a CFormView. The user can have more than one CFormView open at any time. Since the user can have more than one CFormView open I don't want them to show on the task bar.
Any help on show to do this. I found an example but it disables the main view and I need that view active.
|
|
|
|
|
hi, how acn i set the dialog font by code om my cdialog class
Please reply,
Thanks,
Bye
miquid
|
|
|
|
|
SetFont(), or modify the template in the .RC file.
|
|
|
|
|
I have a CFormView Project.
I'm trying to call a function which is located in LeftMenu.cpp which is my implementation file
(CLeftMenu::CLeftMenu()
: CFormView(CLeftMenu::IDD)), from AnonWasher.cpp which Defines the class behaviors for the application.(CAnonWasherApp)
This is the function that I'm trying to call:
void CLeftMenu::GetCheckedItems()
{
char *checkedItems=NULL;
if( m_hWnd != NULL )
{
CMainFrame *main = (CMainFrame*)m_hWnd;
checkedItems=main->GetCheckedArray();
}
}
When I call GetCheckedItems from AnonWasher, I get undeclared Identifier error.
I don't know how I could do this.
|
|
|
|