|
Hi
USe this in WM_CTLCOLOR
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
hbr = CreateSolidBrush(RGB(134,179,174));
pDC->SetBkColor(RGB(255,0,255)); // Pass the RGB of RED color
return hbr;
Cheers
"Peace of mind through Technology"
|
|
|
|
|
Hello, everyone!
I encounter a strange question.
I defined a singleton class like this:
static CMySocket& GetMySocket();
CMySocket& CMySocket::GetMySocket()
{
static CMySocket temp;
return temp;
}
In single thread, it works properly, but in Multi-thread, (I can ensure
in main thread, invoke CMySocket::GetMySocket first), when invoke GetMySocket
I get different instance , who can tell me , why?
Thanks a lot and best regards.
|
|
|
|
|
As i recall u need to declare a certain macro for a singleton class both when using it in a single threaded and apartment. try to look in the MSDN for DECLARE_CLASSFACTORY_SINGLETON macro.
hope this helps you
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
YaronNir wrote: try to look in the MSDN for DECLARE_CLASSFACTORY_SINGLETON macro.
that use to make COM Class SingleTon!
|
|
|
|
|
right!
if he isn't using COM, i suggest he use a protection (critical section) because if in multithreaded application both threads recquire an instance to the class, one should acquire a real one while the other acquire a false one.....
hope this helps
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
hi all,
is there a simple way to get as an input an english string i.e. "hello world" and then result a translated string say in russian/chinees/hebrew?
What I am looking for is that component for translating....? i know there are many programs that translates complete sites...just wondering what those program use?
thanks in advanced
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
YaronNir wrote: i know there are many programs that translates complete sites...just wondering what those program use?
I very large word list!
Did you ever download one of those Translation applications? Didn't you ever wonder why it was so large?
If you are thinking of creating such a program there are many resources scattered over the internet. Try searching for word list and open source dictionaries. I recently developed an English/Chinese dictionary for a new PDA company in China. I used the open source CEDICT, with a few modifications I managed to create a reasonable app with 'enough' words at just under 3mb.
|
|
|
|
|
thanks for the reply.
i will search for word list as you suggested, chinese is very popular hopefully i will find my lingo as well
thanks again
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
Hello everyone,
I have some questions about the keyword "__cdecl",
1. What is the function of this keyword? I read through the MSDN document, but still confused. Could anyone give me some brief and clear descriptions which are better than Microsoft?
2. If I am porting the source codes from Windows to Linux, does on Linux platform exist similar (or the same) keyword like __cdecl? How should I port source codes which has __cdecl keyword?
thanks in advance,
George
|
|
|
|
|
George_George wrote: Could anyone give me some brief and clear descriptions which are better than Microsoft?
This[^] should do.
Nibu thomas
Software Developer
|
|
|
|
|
Cool stuff! Thank you Nibu!
Do you have any ideas of how to deal with such keyword when porting to Linux?
regards,
George
|
|
|
|
|
George_George wrote: Do you have any ideas of how to deal with such keyword when porting to Linux?
I don't think it should make a difference. It will work the same way in Linux too. Well these are standard calling conventions hence porting it to Linux shouldn't cause problems.
But the bottom line is that these are implemented by compilers so the makers will make sure they implement the standard conventions.
__cdecl should behave the same way.
Note: This is my personal opinion. I cannot say how correct these are.
Nibu thomas
Software Developer
|
|
|
|
|
Thanks Nibu!
What means "But the bottom line is that these are implemented by compilers so the makers will make sure they implement the standard conventions"? Do you mean some compiler vendor does not implement this option?
Another question is that, how could I verify that __cdecl works and works the same approach as that under Windows?
regards,
George
|
|
|
|
|
1. In fact you have several calling conventions. A calling convention define which part, from the caller or the callee, will clean the stack when the function return. You have the standard convention and the C calling convention. Typically, cleaning the stack means: when you call a function and supply parameters to this function, these parameters are pushed onto the stack. These parameters needs then to be pulled off the stack when returning from the function. The calling convention defines which part will clean the stack (sorry, but I don't remember for __cdecl which part clean the stack).
2. Sorry, no idea about that
|
|
|
|
|
Thank you Cedric!
Great answer!
regards,
George
|
|
|
|
|
George_George wrote: 2. If I am porting the source codes from Windows to Linux, does on Linux platform exist similar (or the same) keyword like __cdecl? How should I port source codes which has __cdecl keyword?
The GCC compiler has function attribute cdecl which appears to be similar in meaning, but the syntax is different:
http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Function-Attributes.html[^]
|
|
|
|
|
Thanks markkuk,
I found the attribute name is the same -- cdecl. Why do you say that the syntax is different?
regards,
George
|
|
|
|
|
Hi,
I am storing all the barcode into below declared list
<br />
typedef std::list<char* > SERIAL_NUM_BARCODE_LIST;<br />
SERIAL_NUM_BARCODE_LIST SerialNumDescList;<br />
Now before adding to list I have to check whether barcode exist in the list or not. If barcode does not exist than only I have to add it.
<br />
typedef std::list<char* >::iterator BARCODE_LIST_ITER;<br />
BARCODE_LIST_ITER BarcodeListIter; <br />
for(BarcodeListIter = SerialNumBarcodeList.begin(); BarcodeListIter != SerialNumBarcodeList.end();BarcodeListIter++)<br />
strcmp(SerialNumBarcodeList.front(),Barcode)<br />
Is there simple find method present in STL to check inside the list.
Thanks
|
|
|
|
|
You can simply compare the contents of the iterator (so, the string) with the name of the new barcode. To access the string through the iterator, just use this:
(*BarcodeListIter)
|
|
|
|
|
Ideally, you should store the barcodes as strings instead of a pointer. For example:
std::list<std::string> SerialNumBarcodeList;
...
std::list<string>::const_iterator it = std::find(SerialNumBarcodeList.begin(), SerialNumBarcodeList.end(), BarCode);
if (it != SerialNumBarcodeList.end())
{
...
}
-- modified at 2:56 Monday 27th March, 2006
|
|
|
|
|
Thank dear, I hope it will take care the boundary condition where it is checking the barcode with SerialNumBarcodeList.end()
|
|
|
|
|
Hi All,
How can I implement the shared memory concept with C language on windows platform?
Here I want to share a common data with 2-3 executable of C language files on windows platform.
Thanks in advance,
-Ramesh
|
|
|
|
|
For C++, you have quite a few classes in Codeproject's Threads and IPC section[^].
Examples:
CMemMap[^] Which seemed to inspire...
XQueue[^]
and even Microsoft's own CAtlFileMapping class[^].
Raymond chen notes another method[^], but this one opens a security hole.
But for managing variables via shared memory, you'll definitely want to use a helper class.
|
|
|
|
|
Hi,
Anyone know how to enumrate printers from active directoty ?
VikramS
|
|
|
|
|
there is a function called EnumPrinters() which can enum all printers, including networking's.
but I am not sure if it is related to your "active directory".
A nice hyper tool for optimizing your Microsoft html-help contents.
A best image tool for Windows C++ programmers, don't miss it!.
Includeh10
|
|
|
|