|
Simply no the code is not thread safe. Using critical section will work just fine. Although I would write it a little differently.
CCriticalSection m_cProtect;<br />
int m_nNumber = 0;<br />
void Increase()<br />
{<br />
CSingleLock lock(&m_cProtect, true);<br />
m_nNumber++;<br />
}
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Hi!
I just try to implement class with members which return const values:
class MyClass{
* * *
protected:
float GetVal() const {return val;}
private:
float val;
}
It compiled well without "const" but with it I got multiple errors. I can not avoid of use "const" becuse I must follow
some coding style.
So your help is very essential for me.
I code in VS 6.
|
|
|
|
|
You function return value why const ?
|
|
|
|
|
The code you posted compiles fine on vc6. Did you missed something ?
There is no spoon.
mail
|
|
|
|
|
What errors did you get?
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Thanks to all.
I just fix it.
The metter was not in "const" but in member name.
|
|
|
|
|
Like Mad___ said, you are returning a value - why would you want to return a const value? Isn't it the member, val, that is const?
The method doesn't know the type of variable the return value is being stored in?
Can anybody help please?!!?
Cheers
Angel
===========================================================
The sooner you fall behind, the longer you have to catch up
|
|
|
|
|
As I said I MUST code in certain style. So 'const' comes out of it.
|
|
|
|
|
You must add const in return type.
Like this:
const float GetVal()const {return val;}
Because the type of val had been upgraded into "const float" in the GetVal function.
|
|
|
|
|
hi all,
I am doing a Project using MFC.But I want to import a DLL.(name of the dll is "toks.dll").
How can I get details of Methods in that DLL file?.I want to get names of Methods,Return value of the Methods like that..
Can anybody please tell me how to get details of Methods in DLL?
thanks in advance.
|
|
|
|
|
open the dll using the depends.exe that comes with visual studio tools. dont know whether it gives the information on the method signature.
There is no spoon.
mail
|
|
|
|
|
A DLL can expose the method names, (see the suggestion to use Depends.exe to find these out), BUT that's only part of the problem. There is no way for C functions to expose their return type or parameter list, so without this information you are hosed. Can't you get a header with the function signatures for this DLL?
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|
|
hey every one... well maybe the title is not good enough to explain what is in my mind, but what i want to do is:
an edit box + button
and when i enter text in the edit box and click on the button then it will copy the text inside the edit box and pasting it.... i hope that i made it clear... so any way to do it?
thanks alot
|
|
|
|
|
Dody_DK wrote:
...it will copy the text inside the edit box...
Use GetWindowText() for this.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
oki, does GetWindowText() only copying... or copying and pasting?
and if it is only for copying.. what i should use to paste?
thenks alot
|
|
|
|
|
GetWindowText() gets the text, SetWindowText(text) sets the text.
Where are you pasting the text to?
Artificial intelligence is no match for natural
stupidity.
|
|
|
|
|
See here.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I want to paste the text in other program... like word...
I took a look at the link that DavidCrow put... but as i said i want it to copy and paste after i click on a button... so any idea?
thaks alot
|
|
|
|
|
If you have the handle of the window you want to paste to, you could try sending it a WM_PASTE message.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
can you give me an example to how use WM_PASTE ??
thanks alot
|
|
|
|
|
MSDN is usually the first place I go to for such things. Google is another.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
OK thanks alot for your help... and sure there are alot of questions in my mind, and i am going to need help soon...hehe
thanks alot.
|
|
|
|
|
I am currently trying to develop a print provider. So, as the first step, I tried to compile and install the example which comes with DDK. So I successfully compiled "pp" and copied the relative DLL into system32/.
Then It comes the time to register into the spooler system the new provider, so I used the following piece of software, which calls AddPrintProvider ().
#include <windows.h>
#include <string.h>
#include <stdio.h>
int main (int argc, char* argv []) {
int result;
PROVIDOR_INFO_2 pi2;
pi2.pOrder = "C:\\WINDOWS\\system32\\pp.dl";
if (argc != 2) {
printf ("Command not recognized. Use ''install'' or ''uninstall''\n");
return 0;
}
if (strcmp (argv [1], "install") == 0) {
printf ("install... ");
result = AddPrintProvidor (NULL, 2, (LPBYTE) &pi2);
} else
if (strcmp (argv [1], "uninstall") == 0) {
printf ("uninstall... ");
result= DeletePrintProvidor (NULL, NULL, pi2.pOrder);
} else
printf ("Command not recognized. Use ''install'' or ''uninstall''\n");
if (result != 0)
printf ("ok\n");
else {
DWORD err = GetLastError ();
printf ("error: %d\n", err);
}
}
Well, I don't need to say that the output of the program is to signal an error. More precisely it signals error code #2 (file not found).
I tried various combinations of values for pi2.pOrder but I still can't understand what's going on and why it always gives me this error. The file pp.dll is into c:\windows\system32
The DDK documentation just says that I have to copy the needed files there and then call AddPrintProvider.
Does anyone know how to register a print provider ???
What am I doing wrong ??
|
|
|
|
|
Hi all,
I wanna how to send data to com.
I have CportController class.I get web.
I use following function.
long CPortController::Write(LPCTSTR WriteBuffer, long NumBytesToWrite, long Timeout)
{
long result;
static BYTE parms[] =
VTS_BSTR VTS_I4 VTS_I4;
InvokeHelper(0x18, DISPATCH_METHOD, VT_I4, (void*)&result, parms,
WriteBuffer, NumBytesToWrite, Timeout);
return result;
}
This function is work.But PLC screen is not display.
Thank.
|
|
|
|
|
Hello guys,
I am trying to play with a List control (report style) and I would like to do the following thing :
I select a row in my list (that becomes highlighted) and, thanks to 2 buttons (UP and Down), I exchange the place of this raw with the previous one (UP) to make it go to the top of the list or with the next one (DOWN) to make it go to the bottom of the list.
After a click on one of my buttons, I exchange the 2 rows, my row is no more highlighted and I would like it to keep highlighted. I have tried to play with the SetItemState to set the focus and the selection bits to make it highlighted again but without success.
So my question is : how do I give my row this selected aspect (highlight) by program?
Thanks in advance
DD
|
|
|
|