|
Hmmm, off the top of my head, may I suggest you try creating your own struct/class that holds a string, float, int, etc. Infact, this is how VARIANTs in VB/COM are implemented under the hood anyway. Then use this struct/class in your maps, lists, and other STL structures. You might want to experiment with unions as well.
You could also take a look at MFC's COleVariant, and see if you can bend it to meet your needs (this is mostly used for database related stuff, but am sure you can use it for other needs as well).
|
|
|
|
|
If I understand you want one place to hold variables of different type(long, int, string, etc.).
The only way I'm aware of is to use VARIANT, but this has its draw backs. Using a VARIANT adds bulk and slows down your code. If you don't need to support VB or scripting languages then don't use VARIANT.
Is this for MFC? Then you can COleVariant << and >> operators, otherwise I don't beleive _variant_t has that capability.
Can you use seperate containers for each type? list<int>, list<long>, etc.
|
|
|
|
|
If this is what you want to do, I suggest that you uses a wrapper class like COleVariant or _variant_t (or maybe your own class).
At least those class properly handle memory managment and help a with initialisation. The one to uses depends on your needs. If you need more functionaly, then you should create your own class that may derive or embed a COleVariant or _variant_t.
_variant_t class may be a bit easier to uses since it allows conversion from the variant to another type:
_variant_t v(3.2);
double d = v;
but it does not support writting to CArchive...
You may also uses _variant_t for the container and create ColeVariant object at place you need extra functionaly.
Philippe Mori
|
|
|
|
|
I think this will work
http://www.boost.org/libs/any/index.html
gonna try it out...
|
|
|
|
|
|
with SetCursorPos(x,y);
cheers!!!
Carlos Antollini.
|
|
|
|
|
In MFC, if I didn't want my program to close by hitting Esc or Alt+F4, or any other escape sequence, how would I disable that? I can't find any code that works.
I Want Chicken, I Want Liver, Meow Mix, Meow Mix, Please Deliver...
|
|
|
|
|
I am not sure what you mean by "program". But one way to stop the user closing your dialog would be to overload the OnCancel or OnOK methods of your CDialog inherited class. (eg. They could do nothing at all.)
Accept that some days you are the pigeon and some days the statue.
|
|
|
|
|
|
Hello every1!
I am looking at some sample code that microsoft is giving out with MSDN and i can't understand what is going on...if some1 knows it...
Here's the problem - the project palmap(can be found in any MSDN library) is a dll file that is used as an extension of aviview(a prog for viewing avi files and also can be found in the MSDN). A part of the source of palmap.c says:
typedef struct {
IAVIStreamVtbl FAR * lpVtbl;
ULONG ulRefCount;
//
// instance data
//
PAVISTREAM pavi;
PGETFRAME pgf;
AVISTREAMINFO sinfo;
HPALETTE hpal;
LPBYTE lp16to8;
LONG lLastFrame;
LPBITMAPINFOHEADER lpdibLast;
} PALMAPSTREAM, FAR*PPALMAPSTREAM;
There is something sneaky in this struct since IAVIStreamVtbl is defined nowhere(i checked the headers and tried to see if any IDLs exist). I searched the whole project directory for that string and there is no match. It is obviously the vtable and also has an interface prefix but i don't find any interface definitions too. BTW: i tried to look for the definition by clicking with the right button on the "IAVIStreamVtbl" and choosing "Goto definition...." but there is no brosing files with that project. After building the project there are no errors or warnings. so - Where could this IAVIStreamVtbl be defined?
Thanks for any reply!
Vladimir Ralev
|
|
|
|
|
Hi, I'm hoping someone here can help me with a synchronization question.
I have a global function that adds entries to a log file. This function can be accessed by several threads in my program, and this function will also be used in different programs to write to the same log file. Because the log file is opened with the CFile::shareDenyWrite flag, I can only allow one thread to have access to this function at one time.
void WriteLog (LPCTSTR EntryString)
{
CMutex mutex(FALSE, _T("WriteLog - {AE4E28C0-84E6-11d5-B625-F80C283F7922}"));
CSingleLock lock(&mutex, FALSE);
while (lock.IsLocked());
lock.Lock();
COleDateTime dt = COleDateTime::GetCurrentTime();
CString LogEntry = dt.Format("%d/%m/%y %H:%M:%S - ");
LogEntry += EntryString;
CRotatingLog rl(_T("C:\\Bird_Log.txt"), 1000, 100);
rl.AddLine(LogEntry);
} As this is the first time I am using this method, I would like to know if this is the correct way of doing this, or will this just give me problems in the future? Is there a better way to wait for the CSingleLock object to unlock? The while loop seems to be very processor intensive. Any advice appreciated.
TIA
---
Multitasking: Screwing up several things at once.
|
|
|
|
|
You can delete the 'while' loop. The default value of Lock method parameter is INFINITE, this means that CSingleLock::Lock will wait until mutex is released. This waiting will have no impact on CPU usage - it's implemented using ::WaitForSingleObject.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Thanks, I'll try it;)
---
Multitasking: Screwing up several things at once.
|
|
|
|
|
Does anyone know of any algorithms to convert degrees to pixels. I need to be able to rotate a bitmap by a given degree.
|
|
|
|
|
|
As degrees are an angular measure and pixels lateral the convertion would depend on how far from the rotation point you are. I have been playing with images for a while now and was going to write a lot of the code myself, but found it was better to concentrate on the rest of the project and do the image handling with a library written be someone who has more experience than I do. In the end I opted for ImgSource
http://www.smalleranimals.com/
It is inexpensive (note I don't say 'cheap') and does a very good job for what I need to do. Have a look it may do what you want.
Happy programming!!
|
|
|
|
|
Is there a way to understand if a port is listened by a server process on winsock ? If you know how to do this can you post a code sample.
Orcun Colak
orcuncolak@yahoo.com
|
|
|
|
|
What do you actually mean?!?!
You want a 'client' be able to test if a 'server/service' exist on a service-port over UDP?
UDP is a connectionless protocol, so the only way for the 'client' is to check the connection is waiting for any response on your message.
I write 'client' and 'server' between brackets, since client-server in UDP environment is not really a client-server architecture. With TCP/IP you split a socket when a connection is make (by listen -> accept), UDP doesn't do this, but you can use recvfrom to collect the others ip-address+port.
EiSl
|
|
|
|
|
I'm using CToolbar in an MDI w/ sliders,edits,comboboxes,etc.
And I need to place multiple rows of buttons for
one toolbar.I can make the toolbar wider, but I
don't know how to wrap the buttons on the toolbar
to make multiple rows.I've tried getctoolbarctrl(?)
but i can't get a wrap.
|
|
|
|
|
One of the examples on this site explaines the usage of multiple checkboxes in one 'placeholder' In stead of checkboxes buttons should be possible to. Be care full about keeping the GUI user friendly!
Give a yell if you need more help
EiSl
|
|
|
|
|
Does anyone know of a quick and easy way to encrypt / decrypt a phrase stored in a CString variable?
I'm looking for 40 bit (or lower) encryption that uses a hardcoded key for encryption / decryption.
Can anyone point me to a good resource, or give me some pointers?
Thanks,
Frank
|
|
|
|
|
You might try Wei Dai's Crypto++ library. It is:- easy to use,
- very C++ oriented,
- cross-platform,
- open source and royalty free.
There's an article on CodeProject with an example of use.
Regards,
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I looked at Crypto++ and backed away from it for these reasons:
<l>
Way too much for what I need...I just need a simple encrypt/decrypt function.Import / Export restrictions. I think that 40 bit is cool with the US DOD, but i'm not exactly sure.
All I really need is a way to encrypt registration information for my app that is secure but at the same time not too difficult to implement. I've tried XoR and a few other "Simple" encrypt / decrypt methods but they dont seem to fit well into my scheme of things. If I could be specific, I'm looking for something that will give me an output similar to a PGP public key signature you would receive in an email.
Thanks for the suggestions,
Frank
|
|
|
|
|
But it's need to allow the writing only to my program.
Is it possible ???;)
|
|
|
|
|
When you crete the file, you must not put the otion shared
Cheers!!!!
Carlos Antollini.
|
|
|
|