|
If running the redist installer is something you want to avoid, the only other choice is to statically-link any libraries you use (MFC, CRT, etc.)
|
|
|
|
|
I am having an application where there is 17 dialogs. now i need to change the size of the font throughout the project. is there any way to do that. i am aware of changing the font using the dialog properties. doing so the whole layout changes. i want to avoid that. is there any other way?
|
|
|
|
|
WM_SETFONT [^].
(if using MFC , CWnd::SetFont [^]).
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]
|
|
|
|
|
Chandrasekharanp wrote: changing the font using the dialog properties. doing so the whole layout changes. i want to avoid that.
Dialog layout is based on the font so there's no way around it.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
so what u mean to say is i need to change the layout manually if i change the font.
|
|
|
|
|
If you don't get the results you want, then yes.
Do you know the font you want to use at design time or will it
be picked at runtime?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
in my application I have to support single instance functionality I tried with FindWindow and sendmessage but it failed in some times so I want to try with mutex,can anybody suggest me how to support single instance with mutex?
Thanks in advance....
|
|
|
|
|
you can add some code like this... in your application initinstance
HANDLE hMutex = CreateMutex( NULL, TRUE, "MyMutex" );
if( GetLastError() == ERROR_ALREADY_EXISTS )
{//application is already running. dont proceed further
CloseHandle( hMutex );
return FALSE;
}
|
|
|
|
|
since w2k sp4 it is better to use global mutexes:
HANDLE hMutex = CreateMutex( NULL, TRUE, "Global\\MyMutex" );
to aovid conflicts in multiple sessions.
Greetings from Germany
|
|
|
|
|
Hi,
Try this Link[^]
The price of anything is the amount of life you exchange for it.
Thanks and Regards.
SANTHOSH V
|
|
|
|
|
|
|
How can i call a URL from a mfc app and POST some values to it (Using get is easy url..?id=1 but how do i do it using POST)
Thanks
C++ where friends have access to your private members !
|
|
|
|
|
If you would do much more than doing a HTTP Post, then consider CURL[^].
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Sorry all about pre-my post
Here is my source code: http://www.in4site.com/hms.txt
When i run compiler i got this error
Error 1 error LNK2001: unresolved external symbol "private: static class std::list > * 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
|
|
|
|
|
Member 2428381 wrote: have looked up LNK2001 error code on MSDN website but no solution for this situation
I don't know what you saw there, and what you tried to fix that out, but :
unresolved external symbol "private: static class std::list > * Hotel::_rooms"
means that the compiler knows the definition of your class (in its .h file most probably), but the implementation is not foundin the directoried the linker is searching into.
do you have the implementation file somewhere else ?
is it an external library ?
if so, you certainly missed to had its path in the linker settings of your project...
|
|
|
|
|
Hi,
I just combinated all code into once file as you saw at http://www.in4iste.com/hms.txt
But when i use vs 2005 to compile i got LNK2001 error and when i use vs 2008 to compile , i got no error, this program run normally.
im a new in c++, please help!
|
|
|
|
|
Looking at the code you posted earlier, Hotel::_rooms is a std::list (I don't know a list of what because the < and > symbols were treated as html tags and disappeared). I'm not sure, but it looks like it is a pointer also. Is that what you want instead of just having a list object ?
Anyway, as I asked in my previous post, static variables need to be defined in a cpp file. Do you have something like this:
std::list<...;>* Hotel::_rooms = NULL;
in your cpp file ?
|
|
|
|
|
Yeah,
the full code of that: std::list<room> Hotel::_rooms = NULL;
but when i put that line into my cpp file, i got "Project : error PRJ0002 : Error result 31 returned from 'c:\Program Files\Microsoft Visual Studio 8\VC\bin\mt.exe"
I have used the "No (/INCREMENTAL:NO)" link option to solved this error
Thanks You!
|
|
|
|
|
Hi,
How do I show a button a button in pressed state using CMFCToolbar. I remember I can be done quite easily using CToolBar by just using the SetCheck function
I am trying to change the style of the button to TBBS_CHECKBOX initially when the button is created and then xor the style with TBBS_CHECKED when the button is pressed but somehow it is not working
So any body has any idea?
Thanks
Farhat
|
|
|
|
|
If I understand what you're trying to do right, I'd just do it using the ON_UPDATE_COMMAND_UI handler for that button and call pCmdUI->SetCheck() to whatever state you want the button to be in. That works fine for me anyway.
Hope that helps.
|
|
|
|
|
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
|
|
|
|
|