|
try including stdlib.h in the app's stdafx.h file.
|
|
|
|
|
Doesn't help, and I didn't expect it to - this is a *linking* error.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
Sadly, no. I know about this problem, it's how I solved all my other linker problems. I need to use /MT or the program won't compile at all, and I am indeed using it everywhere.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hello,
I'm trying to create an application, which will be always at bottom Z order. I mean it must be behind all the windows in the desktop. My window may have buttons, edit boxes, etc.
How can I achieve this?
I think I must do all the things that the desktop window of WINDOWS do.
Thank you for valuable help.
|
|
|
|
|
::SetWindowPos has a BottomMost value, if you google SetWindowPos you will find it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thank you.
But I want to create a window that behave like the desktop window of WINDOWS. That is it must not come to top when I click on it or move or size it.
SetWindowPos will make it a bottom window, but when I click it it will become top. But the desktop window of WINDOWS will never come to top in any case.
Can you help me?
|
|
|
|
|
You can handle the click event and put it back to the bottom, apart from that I really don't know what you could do.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I suspect you'd need to handle the WM_ACTIVATE, WM_NCACTIVATE, WM_MOUSEACTIVATE messages. I don't know for certain, but I would start looking at those messages.
|
|
|
|
|
Note the desktop window is the ancestor of all windows, it can never come to the top.
You could probably override CWnd::SetWindowPos() so that the window itself has control over its own Z-order placement.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Ok to start things off i am a complete noob at programming, been trying to learn most of it myslef. Recently i made a property managment Database for the properties i own. I want to try and upgrade this program with implementing classes and Vectors. now im not sure what to do and how to transform it, i think the struct would go in the class in a .h file and the fuctions would go in the .cpp can someone please review the code below and give me a rough indercation of what to do.
----------------------------------------------------------------
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
struct propertyInfo
{
string address;
string suburb;
int price;
};
void displayProperty (propertyInfo property);
void getProperty(propertyInfo &property, int &);
void displayLibrary(propertyInfo properties[], int &);
void displayFile(propertyInfo properties[], int &);
void search(propertyInfo properties[], int &);
void saveproperty(propertyInfo properties[], int &numProperties);
int displayMenu();
const int MAXPROPERTIES = 100;
int main()
{
int numProperties = 0;
propertyInfo properties[MAXPROPERTIES];
propertyInfo property = {};
displayFile(properties, numProperties);
int choice = displayMenu();
while (choice!=0)
{
switch (choice)
{
case 1: search(properties,numProperties);
break;
case 2: saveproperty(properties, numProperties);
break;
case 3: displayLibrary(properties, numProperties);
break;
case 4: getProperty(properties[numProperties], numProperties);
break;
case 5: return 0;
}
choice = displayMenu();
}
system("pause");
return 0;
}
void getProperty(propertyInfo &property, int & numProperties)
{
cout << "\nEnter address: " ;
getline(cin, property.address);
cout << "Enter suburb: ";
getline(cin, property.suburb);
cout << "Enter price: ";
cin >> property.price;
cin.ignore();
cout <<"property: " << property.address << ", " << property.suburb << ", " << property.price << " added";
numProperties++;
}
void displayProperty (propertyInfo property)
{
cout << property.price << " " << property.address << " " << property.suburb ;
}
void displayLibrary(propertyInfo properties[], int &numProperties)
{
cout << endl;
for(int t = 0; t < numProperties; t++)
{
displayProperty(properties[t]);
cout << endl;
}
}
void displayFile(propertyInfo properties[], int &numProperties)
{
string FileName = "";
string Extension = ".txt";
cout << "Enter property filename: ";
cin >> FileName;
FileName = FileName + Extension;
//Convert the sting into a char pointer in order to pass it to open()
const char * TheFile = FileName.c_str();
ifstream fin;
fin.open(TheFile, ios::in);
if(fin.is_open())
{
while (numProperties < MAXPROPERTIES && !fin.eof())
{
getline(fin, properties[numProperties].address);
getline(fin, properties[numProperties].suburb);
fin >> properties[numProperties].price;
fin.ignore(); // ignore new line character left after reading int
numProperties++;
}
fin.close();
}
else
cout << "Could not open filename: " << FileName << endl;
}
void search(propertyInfo properties[], int &numProperties)
{
int searchamount = 0;
cout << "Enter Search amount ";
cin >> searchamount;
cout << endl;
for (int z=0; z < numProperties; z++)
{
if (properties[z].price < searchamount)
{
displayProperty(properties[z]);
cout << endl;
}
}
}
int displayMenu()
{
int choice =0;
cout << "\nMenu:\n";
cout << "1 - Property Search" <<endl;
="" cout="" <<="" "2="" -="" save="" property="" list"="" <<endl;="" "3="" list="" all="" properties"="" "4="" add="" a="" property"="" <<endl;
="" "5="" exit"=""
="" cout<<="" "enter="" menu="" choice="" ";="" cin="">> choice;
cin.ignore(1);
return choice;
}
void saveproperty(propertyInfo properties[], int &numProperties)
{
string fileName = "";
string Extension = ".txt";
cout << "Enter filename: ";
cin >> fileName;
cout << "Property details saved to the file: " << fileName <
|
|
|
|
|
Hi.
You'll probably find this program more useful in the long run if you move it to a windows app instead of a console app. As for moving it to have classes, as it stands, it only needs one, the struct you've already defined, unless you want to move data access into a class perhaps.
I'd also suggest looking into using MSDE or something similar to store your data instead of a flat text file.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
what im trying to do is get rid of the struct and turn it into a class.
|
|
|
|
|
replace
struct
{
with
class
{
public:
a class and a struct are the same thing, the only difference is that a class has private as default, and a struct has public. You can add constructors and methods to a struct, like I say, there is no real difference. Of course, if you create a class in a .h and .cpp file, then as your struct has no methods, you'd put it all in the .h file, the .cpp file would be empty except the #include of the header file. If you add methods, they would be declared in the header, and their body would be in the cpp file.
I recommend getting the build in wizards to build a class and add some methods, so you can see how it all gets laid out. Basically you put the class name and a :: before the name of the method in the .cpp file, to differentiate from global methods.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
if any has the time can they please rewrite the program with the .h file and .cpp file seperate that would help heaps
|
|
|
|
|
just post the code here or send it to my email thanks
|
|
|
|
|
You mean to make the struct a class ? Or you want to seperate it further ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Yes i want to turn the struct into a class in a .h file could someone show me hows it's done its a small simple program would be very happy if someone could do it and show me the finished .h file and .cpp
|
|
|
|
|
It's exactly as I explained it yesterday
the header file:
class propertyInfo
{
public:
string address;
string suburb;
int price;
};
the .cpp file:
#include PropertyInfo.h
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I have a dialog with a start button and I want to add a listen function on it. Below is the code that I try:
void CTCPTestDlg::OnBtnstart(LPVOID lParam)
{
// TODO: Add your control notification handler code here
}
When I compile, ot occur a error:
error C2511: 'OnBtnstart' : overloaded member function 'void (void *)' not found in 'CTCPTestDlg'
I don't know how to solve it. can somebody help me
|
|
|
|
|
check your declaration in the .h file
most probably you have a different declaration there.
void CTCPTestDlg::OnBtnstart(LPVOID lParam) in .cpp
afx_msg void OnBtnstart(LPVOID lParam) in .h (if function is auto-generated)
void OnBtnstart(LPVOID lParam) in .h (if function is manually generated)
|
|
|
|
|
Hi..
how can i select excel cell by index not by name using automation? e.g. cell(1,2) for B1 cell. in VB i can use cells(1, 2) coz it's treated as an array of cells. but in VC++, i got error if i use cells[1][2] to access the cell. There is no such cells( 1, 2) method either. The method available is only Range("B2") which is using cell's name not cell's index. Help.. urgent..
Many Thanks..
mu23ye
|
|
|
|
|
I wanted to make a vb application which would dial a telephone number using
the modem. When the person on the other end lifts up the telephone (answers
the phone), the application should start playing an audio file(eg. .wav
file).
The approach I took was using the Tapi. As my modem is connected to the
serial port on my computer I send AT commands to make the phone call . This
is working fine and the call is being placed.
I wanted to know whether this is possible at all? Whether I am approaching
the wrong way? If it is possible, then please give some suggestions or
samples(vb or vc). If it is not possible , then what is the best way to do
so
|
|
|
|
|
I have no idea, but google[^] did.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
How to solve this error?
Error C2065 : 'ReadPortNo' : undeclared identifier
I got a lot of this same error but not all is ReadPortNo, there are different. I just declare it outside the function by int ReadPortNo; I don't know whether it is right or not. Can help me..
|
|
|
|