|
in my program i use a list of pointers to objects like this:
class object
{
public:
int x;
int y;
};
class A
{
public:
std::list<object*> list_b;
};
now.. i do have got problems, because i should sort this list by object.x . i have tried to use te list::sort() function.. but it obviously doesn´t work, case the program doesn´t know how to compare this objects..
is there any member function i can override?
or is there any possibility how to use a set instead of that (would be perfect) ?
i am sorry.. i really tried to find a solution on my own.. but in all the docs and webpages i was searching in this problem seemed to be too obvious... so nobody ever told me how to do this
thanx in advance
|
|
|
|
|
Use the code below, just don't ask why it's done this way.
template<>
struct std::greater<object *>
{
bool operator()(const object* &lhs, const object* &rhs) const
{
return (lhs->x < rhs->x);
}
};
std::list<object *> lst;
lst.sort(std::greater<object *>());
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi,
I would like to be able to create small thumbnail previews of word documents and HTML documents.
Can anyone offer any advice.
Cheers
Rich
|
|
|
|
|
Check out IViewObject::Draw, one parameter lets you specify DVASPECT_THUMBNAIL
|
|
|
|
|
I am wondering if there is possibility to strip zeroes from floating point number using printf () function. I searched all printf options and didn't find any suitable one. Is there any other function convenient for this easy task?
Example: I have an array of doubles and I want to display them with .3 precision:
printf ("%.3f\n" f[i]);
Some numbers will look like 45.100 and some like 568.897. In case of 45.100 I want it 45.1 without trailing zeroes.
|
|
|
|
|
I searched all printf options and didn't find any suitable one.
Well, your search quality isn't very good. Use %.3g, 'g' instead of 'f' will strip trailing zeros.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
How can switch the different view in the SDI with the docking TreeCtrl?
|
|
|
|
|
May I know what MFC class is suitable to act as a canvas that used to
display an animating frame image. I want to add that canvas on my dialog based
application.
thank you.
|
|
|
|
|
just can tell you how i do this..
i don´t think that this is the best solution.. but it works..
you have to make a new CView derived class (works with the derived classes like CScrollview perfectly too).. then you change the CView into a control. (like paul dilascia did it in the c++ q&a in msj jan 2000)
in this control you can do whatever you would do in the view..
don´t be afraid.. it is not as complicated as it may sound like.. all you have to do is to override 3 or 4 member - fun´s..
but i don´t have got the energy right now to post in the whole thing.. but if anyone is interested in my solution you can write me an email..
and if anyone of you knows a better aproach.. i would be happy too..
|
|
|
|
|
Could somebody please help me with this?
I have a client program and server program... I am just testing if data in specific structure is being sent to the server program..... ok... In my client program there are 3 edit boxes.. so i want these three variables being sent to server program.. so let me just write down some of source codes... and please modify it... Everthing related to socket
works fine... Using IP addresses, the client project can be connected to Server project. I guess it's a matter of receiving
datas in the structure from the server. Garbage datas are being sent to the server program....
//Those 3 variables for Edit Boxes...
CString m_Age;
CString m_Email;
CString m_Name;
// class
class sMsg
{
public:
char cUserEmail[50];
char cUserAge[10];
char cUserID[10];
};
// Client program
void CStructTestClientDlg::OnSend()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
sMsg *msg = new sMsg;
strcpy(msg->cUserID,m_Name);
strcpy(msg->cUserAge,m_Age);
strcpy(msg->cUserEmail,m_Email);
m_ClientSocket.Send((LPVOID)msg,sizeof(msg));
}
//Server Program
void TChildSocket::OnReceive(int nErrorCode)
{
sMsg *msg = new sMsg;
m_pServerSocket->Receive(msg,sizeof(msg));
CString i = msg->cUserID; //(just checking if one variable could be printed out....)
AfxMessageBox(i);
}
|
|
|
|
|
m_ClientSocket.Send((LPVOID)msg,sizeof(msg)); You should use sizeof(sMsg) or sizeof(*msg), or you will send/receive only 4 first bytes of your message.
|
|
|
|
|
sizeof(msg) returns 4 which is the size of the pointer, instead you should use sizeof(sMsg)
BTW, is it possible to send binary data through a socket connection. I thought it was a text_only_thing
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
There's really no difference between "text" and "binary data", both are simply a stream of bytes. Sockets don't care about the bytes you send. It's true that most Internet protocols are text-based, but that's for interoperability of different computer architectures (no byte ordering or word length problems)
|
|
|
|
|
Is there any message fired when an application looses the focus by Alt+Tab and gets back the focus?
I have an application which has a modal dialog.
I need to call one function from the dialog when my application gets back focus after switching to another application (say Notepad) and comes back ro mine.
Can anybody help?
|
|
|
|
|
|
Is there any message fired when an application looses the focus by Alt+Tab and gets back the focus?
I have an application which has a modal dialog.
I need to call one function from the dialog when my application gets back focus after switching to another application (say Notepad) and comes back ro mine.
Can anybody help?
|
|
|
|
|
How to Maximize a Dialog Based Program But not Covering the Task Bar?
I use the statement "SetWindowPos(&wndTop, 0, 0, 800, 600, 0)" or the statement "ShowWindow(SW_SHOWMAXIMIZED)" ; But the dialog based program still covers the task bar. Why?
Thanks
|
|
|
|
|
1. Right click on your taskbar, select properties, and check the "Always on top" item.
2. Use ShowWindow(SW_SHOWMAXIMIZED);.
3. All sorted
|
|
|
|
|
Programmatically, you can find out the size and position of the taskbar with the following:
// Find the taskbar
HWND hWndTaskbar = FindWindow("Shell_TrayWnd", NULL);
RECT rc = {0,0,0,0};
::GetWindowRect(hWndTaskbar, &rc);
Then just work around it.
|
|
|
|
|
I have a question, that is, how to show a window maximized but not covering the task bar.
|
|
|
|
|
ShowWindow ( hwndYourWindow, SW_MAXIMIZE );
--Mike--
http://home.inreach.com/mdunn/
A recent survey reports that 1/4 of all internet users in England surf for porn.
The other 3/4 just didn't want to admit it.
|
|
|
|
|
I'm having a terrible time with the date and time picker control. I 'm using the "Microsoft Date and Time Picker Control, version 6.0" which created dtpicker.h for me, but maybe there's a better way to go about this, because I can find no documentation for it anywhere.
Life is quite ironic because I figured out my problem just now as I was writing this email. But my solution isn't very elegant. I was just wondering if anyone could provide me with a good place to get some information on this class.
Right now I don't know how to properly initialize the VARIANT variable that I pass to:
void CDTPicker::SetMinute(const VARIANT& newValue)
(This is just an example the other "Set" functions are equally thwarting.)
So I'm cheating by calling GetMinute() first to set the value, which I then change slightly. But I would appreciate it if someone could tell me what I would need to do to avoid this hack.
Thank you
-john
|
|
|
|
|
Why are you using ActiveX control? CDateTimeCtrl doesn't expose some functionality?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I have the feeling that the answer is, "Because I am a beginer and don't know quite what I'm doing." I'm using VC 5, and I couldn't figure out how to put a CDateTimeCtrl into my project so I used the ActiveX control since that's the only thing that I could figure out how to put into my dialog. Any advice on how to mend the error of my ways would be appreciated.
-john
|
|
|
|
|
HI Folks
I am writing an application which receives traps from different network devices and the output is in the form of predefined data structure, and the application receives traps continously it is a NT Service.
Now i want to send this output to the other application as input using a Message Queue concept can any one help me in this regard ASAP.
Any kind of help is appreciated
Thanks in Advance
Sudheer
sudheer reddy bandaru
|
|
|
|