|
The reason that I placed the CriticalSection variables in the App class is that -just like the CStringList's- I have to access them in different classes, therefore the App seemed to be the most obvious place. The CStringList are "produced" by the worker thread, and displayed by the UI. That's why I need CriticalSections in order to avoid mutual access.
The error I experience is something really weird: a function returns one value and some time later another value without having manipulated it's input, etc.
Another thougth: should the CStringList's be declared volatile if I use them both in my user interface class (for simplicity lat's say: CDialog, where they are declared) and my worker threads?
Thanks for your help.
R.
|
|
|
|
|
Anonymous wrote:
The reason that I placed the CriticalSection variables in the App class is that -just like the CStringList's- I have to access them in different classes, therefore the App seemed to be the most obvious place. The CStringList are "produced" by the worker thread, and displayed by the UI. That's why I need CriticalSections in order to avoid mutual access.
No you misunderstood me. I wasn't talking about where the critical section is defined. I meant that you need to lock it in the app thread, as well as the worker threads. If you aren't doing that, then this could well be the cause of your problem.
Anonymous wrote:
The error I experience is something really weird: a function returns one value and some time later another value without having manipulated it's input, etc.
A function that accesses the CStringList?
Anonymous wrote:
Another thougth: should the CStringList's be declared volatile if I use them both in my user interface class (for simplicity lat's say: CDialog, where they are declared) and my worker threads?
I don't think this is relevant to the problem at hand.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Neville Franks wrote:
No you misunderstood me. I wasn't talking about where the critical section is defined. I meant that you need to lock it in the app thread, as well as the worker threads. If you aren't doing that, then this could well be the cause of your problem.
Bingo. Thanks very much for your help.
R.
|
|
|
|
|
Anyone knows how to communicate with paraller port (lpt1) in visual C++ without MFC?
Help please..
|
|
|
|
|
Look up CreateFile() and WriteFile() in the Win32 API section of the MSDN.
Software Zen: delete this;
|
|
|
|
|
Under Win95, Win98 you can directly write the hex-value to the port (with assembler):
...
void outportb(unsigned int portid, unsigned char value)
{
__asm
{
mov edx, portid
mov al, value
out dx, al
}
}
...
outportb(0x378, 20);
...
Under NT-Systems, like Win2000, WinNT and XP you are not allowed to write directly to the ports.
It this case just use a port-driver like "UserPort" (just take a look on http://www.mattjustice.com/parport/par_nt.html).
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
Hello!,
I am a little stuck with this piece of code, can anyone help me please?
Actually I don’t know how to implement the assignment operator and the overloaded operator. Can you give me some tips and ideas please. As it is apparent, I have just started with C++ programming.
//file myString.h
#include
class myString
{
private:
char* theString;
int length;
public:
myString();
myString(char*);
~myString();
myString(const myString&);
myString(const char*);
//the assignment operator
myString& operator=(const myString&);
myString& operator=(const char*);
int getLength();
const char* GetString();
// == operator overloaded for string comparison
friend int operator==(const myString&, const myString&);
friend int operator==(const myString&, const char*);
};
Thanks
|
|
|
|
|
I am not sure what you mean by the overload operator?
As far as the assignment operator, this is what you need to do:
1: check for a reference to the current object. There is no sense in reassigning of you are doing something like this:
Object A;
A = A;
Here is the code you use to do that check:
myString &operator=(const myString& rhs)
{
if (*this == rhs)
{
return *this;
}
...
}
2: delete all of your existing memory, to prevent memory leaks.
delete[] theString;
theString = NULL;
3: allocate and copy the data from the input parameters.
if (rhs.theString)
{
length = strlen(rhs.theString) + 1;
theString = new char[length];
strcpy(theString, rhs.theString);
}
4: Returns a reference to this object to make things like this possible:
Object A, B, C;
...
A = B= C;
Here is the code to do this:
return *this;
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Hi
Thanks for the reply, i think you are the only person who was able to reply to my problem. I am actually working on string manipulation and i have been provided the myString.h file. Thanks a lot,
|
|
|
|
|
I think that a lot of people skipped over your post because they perceived it as your homework assignment. Many students come here and post questions that basically ask someone from CP to do their assignment for them. Just be sure to ask for help in a way that lets people know you are trying to learn and are willing to the work yourself except that you are stuck.
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Thanks,
It's just that the operator and assignment operator part that kept me stuck, of course i was trying. thanks for the help.
|
|
|
|
|
Sorry for my English , it is not my own language.
I write a program which draw and move a triangels. When i move i must a redraw area. I use double buffering. I use MDI.
When i moving, after a several time colours are disappears. If i want draw
something i write:
CBrush *brush = new CBrush(m_cColour);
CPen *lpPen = new CPen(PS_SOLID,2,(m_bSelected)?RGB(150,100,50):RGB(0,0,0));
pDC->SelectObject(lpPen);
//Draw
delete brush;
delete lpPen;
May be i must free somethings(resourece) another way.
Please Help.
|
|
|
|
|
when you select an object into a DC, you must de-select it before you destroy the DC or the object. you do this by selecting the default object back into the DC:
CBrush brush;
brush.CreateSolidBrush(...);
CBrush *pOldBrush = dc.SelectObject(&brush);
...
dc.SelectObject(pOldBrush);
-c
"[it was..] one of those evenings when you feel that not only will there definitely be a revolution, but that the Association of Manufacturers will foot the bill."
-- Umberto Eco, Foucault's Pendulum
|
|
|
|
|
I cannot find the APIs on MSDN...
|
|
|
|
|
UuidCreate()
--Mike--
"I'd rather you just give me a fish today, because even if you teach me how to fish, I won't do it. I'm lazy." -- Nish
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Hello!
Mr. Dunn is correct. Alternatively, you could use the following code to get a standard CString that contains a new GUID:
GUID l_GUID;
::CoCreateGuid(&l_GUID);
OLECHAR szGUID[40];
::StringFromGUID2(l_GUID, szGUID, 39);
CString sGUID = szGUID;
Hope that helps!
Sincerely,
Alexander Wiseman
Est melior esse quam videri
It is better to be than to seem
|
|
|
|
|
|
I made a MFC extension DLL and it works fine. However, I have one exported class there that is built from another class. THus in the include it has included the header to that other class. However, I do not want to export that "other" class. So far I just exported it so that the program will work. Is there a way around it so that I don't have to export this "other" class?
THanks.
|
|
|
|
|
You only have to export a class, function or variable if you want to import it (use it) in a separate dll or executable. The only way that you will be exporting your class is if you declare it with the __declspec(export) compiler option, or if you have added a def file entry for that class.
Otherwise you can include as many class and function definitions in the main header and they will not be accessible. So if that parameter is defined for your class and it should continue to work and not be exported (as long as it resides in the same DLL that it is trying to be used from).
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
if use CSocket to connect to a remote server through internet, is an ip address in text format, i.e. sss33-23.jfgh.com.au the same as the one in number format, i.e. 2222.22.22.22?
thx
includeh10
|
|
|
|
|
No. Use the gethostbyname() function to convert a name address (abc.def.com) to its IP address (12.34.56.78).
Software Zen: delete this;
|
|
|
|
|
The only thing i can choose in the toolbox dialog under general is the pointer. Anyone know what could be wrong?
Thanks
|
|
|
|
|
open or create a project first. This helps...;P
How low can you go ? (MS rant)
|
|
|
|
|
hi,
I've three questions:
1-How to change boutton color?
2-How to use the horisental bar in a liste boxe, despite a activate when the text bypasse width of the list boxe it still remains deactivated?
3-how to use the progression bar? ( give me an example if it is psossible )
very urgent, I need reply befor tomorrow if you can.
|
|
|
|
|