|
Hello!
And may be you know also how can I check the button state, is it preessed or unpressed? There is no GetCheck method by CMFCTollBarButton class. So what is the way then?
Thanks a lot in advance.
|
|
|
|
|
As far as I know there isn't a way to do it like that, but that's because updating buttons on toolbars is different to buttons on dialog boxes.
To be honest, I'm not really sure I understand what you're trying to do - because you handle the OnUpdate function for that button (which is the only way to set it as checked), you must know the whether the button is checked or not already?
|
|
|
|
|
Oh no no, the first question is not mine. So I do not set it checked OnUpdate, I just want to know the state of the button.
But probably the solution is to handle global bool variable in ButtonClick handler.
I also found some method
CMFCToolBarButton::SetRadio <br />
Called by the framework when a button changes its checked state.
BUT
Remarks <br />
The default implementation of this method does nothing. Override this method to perform a custom action when the button changes its checked state.<br />
|
|
|
|
|
Hi all,
I have some problems with my program.
My source is follow
//Address.h
#include<string>
#include<iostream>
class Address
{
public:
Address() : _street(0), _city(0), _country(0){}
Address(char* street, char* city, char* country) : _street(street), _city(city), _country(country) {}
~Address(){std::cout<<"Free memory: "<<std::endl;}
public:
void SetStreet(char* street){this->_street = street;}
char* GetStreet()const{return this->_street;}
void SetCity(char* city){this->_city = city;}
char* GetCity()const{return this->_city;}
void SetCountry(char* country){this->_country = country;}
char* GetCountry()const{return this->_country;}
friend std::ostream& operator<<(std::ostream& os, const Address& add){os<<"Address: "<<add._street<<" - "<<add._city<<" - "<<add._country<<std::endl; return os;}
private:
char* _street;
char* _city;
char* _country;
};
//Common.h
typedef unsigned int BYTE;
enum Method : BYTE{Cash=1, BankTransfer=2, CreditCard=3};
enum OrderStatus : BYTE{Booked=1, BookedNotConfirmed=2, CheckedIn=3, CheckedOut=4, Confirmed=5};
enum RoomType : BYTE {Single = 1, Double = 2, Triple = 3};
typedef unsigned long ULONG;
#define TICKS_IN_DAY 86400 // = 24 * 60 * 60
///////////////////////////
// Hotel.cpp
#include<iostream>
#include<list>#include<limits>#include<string>
#include<list>#include "Common.h"
#include "Address.h"
class Room
{
public:
Room(void);
Room(char rid[3], char* name, RoomType type, BYTE noroom, float price, float taxrate, char* notes)
: _rid(rid), _name(name), _type(type), _noroom(noroom), _price(price), _taxrate(taxrate), _notes(notes){}
void SetRID(char rid[3]){_rid = rid;}
char* GetRID()const{return _rid;}
void SetName(char* sname){_name = sname;};
char* GetName()const{return _name;}
void SetType(RoomType type){_type = type;}
RoomType GetType()const{return _type;}
void SetNoRoom(BYTE noroom){_noroom = noroom;}
BYTE GetNoRoom()const{return _noroom;}
void SetPrice(float price){if(price < 0) _price = 0; else _price = price;}
float GetPrice()const{return _price;}
void SetTaxRate(float taxrate){_taxrate = taxrate;}
float GetTaxRate()const{return _taxrate;}
void SetNotes(char* snotes){_notes = snotes;}
char* GetNotes()const{return _notes;}
public:
friend bool operator==(const Room& lr, const Room& rr){return bool(strcmp(lr._rid, rr._rid) == 0);}
friend bool operator>(const Room& lr, const Room& rr){return bool(strcmp(lr._rid, rr._rid) > 0);}
friend std::ostream& operator<<(std::ostream& os, const Room& room);
private:
char* _rid;
BYTE _noroom;
char* _name, *_notes;
RoomType _type;
float _price, _taxrate;
};
class Hotel
{
public:
static void Initiation();
public:
static void SetName(char* name){_name = name;}
static char* GetName(){return _name;}
static void SetPhone(char phone[15]){strcpy_s(phone, strlen(_phone), _phone);}
static char* GetPhone(){return _phone;}
static void SetFax(char fax[15]){strcpy_s(fax, strlen(_fax), _fax);}
static char* GetFax(){return _fax;}
static void SetAddress(Address add){_address = add;}
static Address GetAddress(){return _address;}
public:
static std::list<room>& GetRooms(){if(!_rooms) _rooms = new std::list<room>() ;}
static std::list<room>& GetRooms(RoomType type);
static BYTE GetRoomCount(){return static_cast<byte>(_rooms->size());}
static BYTE GetRoomCount(RoomType type);
static BYTE InsertRoom(char rid[3], char* name, RoomType type, BYTE noroom, float price, float taxrate, char* notes);
static bool UpdateRoom(char rid[3], char* name, RoomType type, BYTE noroom, float price, float taxrate, char* notes);
static bool DeleteRoom(const char rid[3]);
private:
static char* _name;
static char _phone[15], _fax[15];
static Address _address;
static std::list<room>* _rooms;
};
inline std::ostream& operator<<(std::ostream& os, const Room& room)
{
os<<std::endl<<"Room : ("<<room.GetRID()<<")"<<room.GetName()<<std::endl;
os<<"\t"<<"Type(Single: 1,, Double: 2, Triple: 3): "<<(static_cast<byte>(room.GetType()))<<std::endl;
os<<"\t"<<"Number of Room \t: "<<room.GetNoRoom()<<std::endl;
os<<"\t"<<"Price \t: "<<room.GetPrice()<<"\t Tax Rate \t: "<<room.GetTaxRate()<<std::endl;
os<<"\t"<<"Notes \t: "<<room.GetNotes()<<std::endl;
return os;
}
inline void Hotel::Initiation()
{
std::cout<<"Sth here"<<std::endl;
}
inline std::list<room>& Hotel::GetRooms(RoomType type)
{
std::list<room>::iterator ite = _rooms->begin();
std::list<room>* results = new std::list<room>();
while(ite != _rooms->end()){
if( (*ite).GetType() == type ) results->push_back(*ite);
++ite;
}
return *results;
}
inline BYTE Hotel::GetRoomCount(RoomType type)
{
std::list<room>::iterator ite = _rooms->begin();
BYTE count = 0;
while(ite != _rooms->end()){
if((*ite).GetType() == type) count++;
++ite;
}
return count;
}
inline BYTE Hotel::InsertRoom(char rid[3], char* name, RoomType type, BYTE noroom, float price, float taxrate, char* notes)
{
Room* r = new Room(rid, name, type, noroom, price, taxrate, notes);
_rooms->push_back(*r);
return static_cast<byte>(_rooms->size());
}
inline bool Hotel::UpdateRoom(char rid[3], char* name, RoomType type, BYTE noroom, float price, float taxrate, char* notes)
{
std::list<room>::iterator ite = _rooms->begin();
while(ite != _rooms->end())
{
if( strcmp((*ite).GetRID(), rid) == 0 )
{
(*ite).SetName(name);
(*ite).SetType(type);
(*ite).SetNoRoom(noroom);
(*ite).SetPrice(price);
(*ite).SetTaxRate(taxrate);
(*ite).SetNotes(notes);
return true;
}
++ite;
}
return false;
}
inline bool Hotel::DeleteRoom(const char *rid)
{
std::list<room>::iterator ite = _rooms->begin();
while(ite != _rooms->end())
{
if( strcmp((*ite).GetRID(), rid) == 0 )
{
_rooms->erase(ite);
return true;
}
++ite;
}
return false;
}
//main.cpp
#include<iostream>
#include "Hotel.cpp"
int main()
{
Hotel::Initiation();
}
When i run compiler i got this error
Error 1 error LNK2001: unresolved external symbol "private: static class std::list<class room=""> > * Hotel::_rooms" (?_rooms@Hotel@@0PAV?$list@VRoom@@V?$allocator@VRoom@@@std@@@std@@A) HSM.obj
Error 2 fatal error LNK1120: 1 unresolved externals C:\Users\Google\Documents\Visual Studio 2005\Projects\HMSv10\Debug\HMSv10.exe
i have looked up LNK2001 error code on MSDN website but no solution for this situation. Can any1 help me solve it ?
but when i use vs 2005 to compile i got LNK2001 error, but when i use vs 2008 to compile , i got no error, this program run normally ?
i dont know why ? can any1 answer this ?
thanks in advance
|
|
|
|
|
Please read the guidelines[^] before making another post.
Please use the "code block" option in the formatting pane to post code.
Please post only relevant code, explain your query clearly and pin point what is that you need help with.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Please format your code properly using the "code block" tag, it's almost unreadable. Did you define your static variable in a cpp file ?
|
|
|
|
|
and because two answers are not enough in your case, i'm repeating it to you (to be sure you got it well) :
you are supposed to post formatted relevant code only (not a huge copy/paste of an entiere file) !!!
|
|
|
|
|
toxcct wrote: you are supposed to post formatted relevant code only (not a huge copy/paste of an entiere file) !!!
Very well said. Why do some people think that someone on the internet will have the time to wade through the entire lot of code they post?
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Hi All,
Can anybody tell me How to Embed a function in C Structure?
Regards
Sairam
|
|
|
|
|
a C structure is a class in C++.
if you're coding C++, then do it like you do in a regular class.
If you're coding C, no way.
|
|
|
|
|
You may embed a function pointer in a C struct .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I need a sample application for connecting to sql server database in ATL.
Thanks..
|
|
|
|
|
Did you look at CP database section Database[^]?
Regards,
Sandip.
|
|
|
|
|
I need sample application for connecting to Sql server
|
|
|
|
|
MyView wrote: I need sample application for connecting to Sql server
Quote Selected Text
Did you check the link i gave ?
Regards,
Sandip.
|
|
|
|
|
MyView wrote: I need sample application for connecting to Sql server
It's great that you reposted your question because I guess nobody understood it the first time. It's also nice that you took the time to look at the link that was given to you earlier
|
|
|
|
|
Hi All
I heard the term "Fiber" for the first time. What is Fiber? Where exactly it is used (any example)? Is it a good technique to use Fibers in my program? Please provide any related links
Thank you.
|
|
|
|
|
Does this help Fibers[^]
Regards,
Sandip.
|
|
|
|
|
the link answered all my questions
thank you
|
|
|
|
|
Hi,
Please help me to create 4 views using splitterwnd.
i have created 1 left pane,right pane.what to do to show 3 panes in right pane..
plz help me..
thankes in advance..
Srikadi
|
|
|
|
|
I'm working on a small application where i have a combo box and 5 check boxes.
I want to enter the data in the combo box. I can do that while entering in the data column in properties but i wish to do it while writing the code in the program. Please help me.
Secondly i want to change the color of the text of my check boxes. Please advice me how is it possible???
|
|
|
|
|
Ramtangi wrote: I want to enter the data in the combo box. I can do that while entering in the data column in properties but i wish to do it while writing the code in the program.
It never hurts to take a look at the documentation[^] you know.
|
|
|
|
|
I'm a beginner in VC++. I would prefer to know how can get a colored text for my check boxes.
|
|
|
|