|
do you want to use Create() and ShowWindow() instead to show the dialog?
|
|
|
|
|
Hi,
In my program, I've used multithread (many clients) to send message to one thread(Server). However, I realized that only the first client can get access to the server from start to end, other clients are blocked. Can anyone help me to solve this problem??
The following is the code of the server:
if ( svrSocket.Accept(socket))
AfxMessageBox("Socket is created Succesfully");
while (...)
flag = socket.Receive(buff,sizeof(buff));
....
Please HELP! Thank you!!
|
|
|
|
|
while( ...)
{
if ( svrSocket.Accept(socket))
{
CSockThread sockThread = new CSockThread(sock);
// class CSockThread : CWinThread
}
}
Receive in Thread
while (...)
flag = socket.Receive(buff,sizeof(buff));
....
|
|
|
|
|
hi ,
I use an array to store all thread ID:
CWinThread* thread[10];
thread[i] = AfxBeginThread(.....)
then, in the thread function, I will use pThread = AfxGetThread(); in order to get the thread ID of that thread. (CWinThread* pThread)
In another function, i will use: (e.g.)
if (pThread == thread[i])
.....
Is it workable????
|
|
|
|
|
Try this:
if(AfxGetThread()->m_nThreadID == thread[i])
{
//Do something
}
instead of:
if(pThread == thread[i])
{
//Do something
}
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
thread[i] is not an ID, but address of CWinThread-derived objects. You can use it to identify the thread assuming that you're using AfxBeginThread for thread creation.
Tomasz Sowinski -- http://www.shooltz.com ** If you're going to rape, pillage and burn, be sure to do things in that order. **
|
|
|
|
|
Hi,
I am working on eVC++ and I want to place a bitmap on a atatic control.
I am using the following code. It compiles but I am not able to see the bitmap on the screen.
Any pointers ??
MyBmp.LoadBitmap(IDB_BITMAP1);
myStatic.SetBitmap(MyBmp);
An expert is one who has made all the mistakes.
|
|
|
|
|
When you create your static control, add SS_BITMAP to the dwStyle parameter.
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
How to retrieve a RGB value of Bitmap directly in memory without use GetPixel of the CDC with logical coordinate of the point to be examined?
thx
|
|
|
|
|
You can do that only if you have so-called DIBSection. DIBSection is a bitmap that application can read and write to directly.
Tomasz Sowinski -- http://www.shooltz.com ** If you're going to rape, pillage and burn, be sure to do things in that order. **
|
|
|
|
|
First you will have to get a pointer to the buffer with a DIB section.
Then you can use LPtoDP to convert the logical coordinate to the device coordinate in the bitmap.
|
|
|
|
|
see GetDIBits, if you want to do it yourself. or, look for one of the many DIB wrapper classes available on this site.
(or try http://www.smalleranimals.com/isource.htm)
-c
Smaller Animals Software, Inc.
Few things are harder to put up with than the annoyance of a good example.
Mark Twain
|
|
|
|
|
hello everybody
forgive my poor english, it's not my native language.
i have vc++6.0 and i have installed it on win XP home edition.
All seems to work fine, but i wonder:
-which are the 'limitations' or 'pitfalls' of applications developed in this platform? I mean: can they run fine also in win95/98/ME?
-is there a list of functions etc. to not use and that we have to know in order to avoid any 'compatibility trouble'?
any suggestion will be greatly appreciated
thanks in advance
Joe
|
|
|
|
|
Joe IT wrote:
I mean: can they run fine also in win95/98/ME?
Of course.
Joe IT wrote:
is there a list of functions etc. to not use and that we have to know in order to avoid any 'compatibility trouble'?
The reverse is true - you can't write W98/ME/2000/XP specific code without installing the platform SDK. Try TransparentBlt - the compiler won't know what it is ( it's been there since W98 ). You need a PSDK to provide the lib and header files for the compiler to call these functions, even though they are present in the OS.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
hello Christian
thank you for your reply
so, just to summarize, if i work with vc++6.0 / win XP (as i like to do) i can be sure that my MFC applications will run properly also in the previous platforms. this is my concern
>The reverse is true - you can't write W98/ME/2000/XP >specific code without installing the platform SDK
do you mean of course the case of working inside win xp?
by the way, are the platform SDKs downloadable from msn?
sorry but my knowledge of the vc++6.0 is little and related to MFC only
thanks again
Joe IT
|
|
|
|
|
Hi,
I've found this equation in here:
#define Randomize(min, max) ((rand() % (int)(((max) + 1) - (min))) + (min)) //get a random number between min and max
and I realized that the result generated are the same each time, so I've added this before calling the above equation:
srand((UINT)time(NULL));
But then, when I use multithread, (e.g. 2 threads), they call the Randomize function and the one above, and generate the exact same result.
So, my question is:
How can I get two different results when 2 threads are created at the same time??
(By the way, I've also tried Sleep(Randomize(....)) to let them start at different time...)
PLEASE HELP!!! THANKS!!!
|
|
|
|
|
Try with srand(((unsigned)time(NULL))^GetCurrentThreadId()) .
PS: I substituted ^ for | . XOR is better suited for this purpose.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
FINALLY!!! I got stuck for so long!!
|
|
|
|
|
Hi,
I use the following code:
if ( svrSocket.Accept(socket))
AfxMessageBox("Socket is created Succesfully");
flag = socket.Receive(buff,sizeof(buff));
....
Is it true that everytime "socket.Receive(..)" must wait until it actually receives something?? What if I want it to pause the receiving for a small period?? Because it would be simply dead if it never receive anything.
Can anyone please give me advance??
Thank you
|
|
|
|
|
Use asynchronous sockets (CAsyncSocket , if you're doing it the MFC way).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thank you for your reply!!
Yes, I am doing the MFC way. But the socket cannot receive correctly if I use CAsyncSocket instead of CSocket.
Is there a problem of my program?? Or is there another way to do it??
Thanks!
|
|
|
|
|
The mode of use of CAsyncSocket is different than CSocket . Put briefly, with asynchronous sockets you've got to wait for the socket to tell you that reading/writing is permissible. Check the docs for this class.
So I'm afraid you'll have to rewrite portions of your code to change to asynchronous.
An alternative ad hoc solution I just ran into is using Tim Kosse's CSocket-Derived Class that Checks for Timeouts, which hopefully can be plugged into your program with minimum effort.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Great! Thank you!! Let me try that!!
|
|
|
|
|
Hi,
Can anyone tell me why I got the error?? And what I can do??
"error C2039: 'AfxBeginThread' : is not a member of 'CWinThread'"
CWinThread* pthread;
pthread = AfxBeginThread (Check, this);
UINT CMyClass::Check(LPVOID p)
{
CMyClass * me = (CMyClass *)p;
me->Check();
return 0;
}
void CMyClass::Check()
{...}
Please give advance!! Thank you!!!
|
|
|
|
|
You may try to these:
define the Check() to static,not a member function.
|
|
|
|