|
ChiYung wrote:
1. Can i create these thread by:
for (i=0; i<50; i++)
The for loop will work fine, although you will need to save the return value from AfxBeginThread(). It returns a pointer to the newly-created CWinThread which you will need later.
ChiYung wrote:
2. How to identify Xth thread after creating 50 threads?
Keep an array of CWinThread* and fill it with the return values from AfxBeginThread().
As for suspending/resuming, you should use the built-in thread sync objects, instead of suspending threads yourself. Look up critical sections and mutexes in MSDN.
--Mike--
Rollin' in my 5.0
With the rag-top down so my hair can blow.
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan and Jamie Salé.
|
|
|
|
|
There are many issuies when you're useing multithreading regarding of your question about simultaneous access to data and whether or not you may call SuspendThread(). You should read at least MSDN topics about CriticalSection usage, about functions WaitForSingleObject/WaitForMultipleObjects and some related topics.
Good luck
|
|
|
|
|
Hello,
how do i get a handle from the desktop, or how do i create a window like the desktop.
Need this Info for programming a secure password protection.
thanx.
|
|
|
|
|
Hi.
CryoGate wrote:
how do i get a handle from the desktop
You can call GetDesktopWindow(), which returns an HWND, or you can call CWnd::GetDesktopWindow(), which returns a CWnd*. If you do the latter, be aware that the pointer is tempoary and should not be stored for future use.
Hope that helps.
Chistopher Duncan
Author - The Career Programmer: Guerilla Tactics for an Imperfect World (Apress)
|
|
|
|
|
I'm trying to draw the caption (title bar) of a dialog myself, but I'm stuck.
I can draw to the non-client area, but I cannot prevent the painting of the ordinary caption bar.
I tried something with the WM_NCPAINT and WM_NCACTIVATE messages, but WM_NCPAINT seems only to have to do with the actual border, and WM_NCACTIVATE doesn't seem to have anything to do with painting at all...
Can somebody please tell me what I'm doing wrong?
Cheers
|
|
|
|
|
If you were in a regular window then you would return false in your handler for WM_NCACTIVATE and do not call the defWindowProc windows will not paint the caption for you.
Since you are in a dialog, you will still need to return true to indicate that you handled the message, but you will need to call SetWindowLong(hDlg, DWL_MSGRESULT, FALSE); . This will set the return result of you message to false, and tell windows not to draw the caption. Then you will be responsible for it.
|
|
|
|
|
Thanks for your reply but I still can't get it to work...
When I boot the app no borders or caption are drawn. But when I click the caption, windows paints the system menu and a horizontal line that seperates the client and the non-client area. I couldn't find any messages that could be responsible for this with Spy++.
When NCPAINT messages are send I can override them, but this is quite confusing.
Also, I'm not quite sure where to put the SetWindowLong(hDlg, DWL_MSGRESULT, FALSE); you mentioned.
Please help me out
|
|
|
|
|
Griffith Sutherns wrote:
Also, I'm not quite sure where to put the SetWindowLong(hDlg, DWL_MSGRESULT, FALSE); you mentioned
This goes in your WM_NCACTIVATE message handler. Inside of your DLGProc, and dialog proc cannot return the result of the message the same way a window proc does, therefore you need to call set window long and set the result there instead.
|
|
|
|
|
How to change his display effect , and changes into XP's style when the mouse has been swept the Title of menu ?
How to show his shadow effect after the menu pop ?
|
|
|
|
|
http://msdn.microsoft.com/library/en-us/dnwxp/html/xptheming.asp
good luck VitSoft
http://www.development.efficientit.com
|
|
|
|
|
How to respond and heavily paints the push-button in VC++6 when the mouse has been drawn CTabCtrl's push-button ?
Whether takes an example ?
|
|
|
|
|
I know this is a simple question. i forgot how to use create my own copy constructor and operator= when i am using pointers... can anyone help me create one by giving a example? because i forgot that if u use pointers you cant use the default operator= and copy constructor because it would cause memory leaks and stuff. so can anyone help me???
John
|
|
|
|
|
Example class:
class array
{
private:
int n_MaxLength;
int n_array;
bool Clone (const array& rhs);
bool Destroy ();
public:
array ();
~array ();
array (const array& rhs);
array& operator=(const array& rhs);
...
};
Here is the constructor and destructor:
array ();
{
n_MaxLength = 10;
n_array = new int[10];
}
~array ();
{
delete[] n_array;
n_array = NULL;
}
Here is the copy constructor:
array (const array& rhs)
{
n_MaxLength = rhs.n_MaxLength;
n_array = new int[n_MaxLength];
if (NULL != n_array)
{
memcpy(n_array, rhs.n_array, sizeof(int) * n_MaxLength);
}
}
Here is the assignment operator:
array& operator= (const array& rhs)
{
if (this == &rhs)
{
return *this;
}
delete[] n_array;
n_array = NULL;
n_MaxLength = rhs.n_MaxLength;
n_array = new int[n_MaxLength];
if (NULL != n_array)
{
memcpy(n_array, rhs.n_array, sizeof(int) * n_MaxLength);
}
return *this;
}
Notice that the Delete code in the assignment operator is the same as the delete code in the destructor. And also that the copy code in the copy constructor is the same as the copy code in the assignment operator. When my class get larger, and there are alot of variables to manage, I usually organize my classes like this to help reduce redundant code:
void Destroy()
{
delete[] n_array;
n_array = NULL;
}
void Clone()
{
n_MaxLength = rhs.n_MaxLength;
n_array = new int[n_MaxLength];
if (NULL != n_array)
{
memcpy(n_array, rhs.n_array, sizeof(int) * n_MaxLength);
}
}
~array ();
{
Destroy ();
}
array (const array& rhs)
{
Clone();
}
array& operator= (const array& rhs)
{
if (this == &rhs)
{
return *this;
}
Destroy();
Clone();
return *this;
}
|
|
|
|
|
Has anybody tried to download the "core sdk" or the complete sdk (November 2001) from microsoft ????
If someone was able to download it, then please let me know because i have
some big problems with it!!!
thanks!
|
|
|
|
|
I downloaded it 2 days ago.
All 380 MB of it
No problems
I didnt try combining them yet though
Nish
My miniputt high is now 29
I do not think I can improve on that
My temperament won't hold
www.busterboy.org
|
|
|
|
|
What problems have you got cos i had problems comining it under 9x. I fixed this by unzipping it to c:\temp and tehn it worked fine.
Peter
|
|
|
|
|
// Creates a reference of the board then copies
// the reference to a new board
const CBoard& rConstBoard = *mpBoard;
CBoard Board = rConstBoard;
is this call rite? because it causing my whole function not to work properly.
can any tell me whats the problem.
here is my whole function if my question information is insufficient...
// Searches for the best computer move on the board
int CComputer::CheckForMoves(int Depth, int Alpha, int Beta, int& Row, int& Col)
{
// Check if the Entered Depth is greater than the Maximum depth
ASSERT(Depth >= MAXDEPTH);
// Creates a reference of the board then copies
// the reference to a new board
const CBoard& rConstBoard = *mpBoard; <-- the problem
CBoard Board = rConstBoard;
Row = Col = 1;
return 0;
}
And i wanted to return both Row and Col but it wont do that... i have debugged 15X wid the debugger and i still can find my mistake. can anyone tell me what i am doing wrong???
john
|
|
|
|
|
Why don't you just do this:
CBoard Board = *mpBoard; // Assuming mpBoard has been properly instantiated.
What makes you think you need a reference to CBoard? I mean, you've got a pointer to a board, than a reference to the same board and than a local instantiation of the same board. Looks a little convoluted to me.
"There's a slew of slip 'twixt cup and lip"
|
|
|
|
|
that worked but i still cant figure out the bug in my function. it returns both the row and column but it wont set the value.
here is where i call the previous function...
// Handles all the moves done by the computer
void CChildView::ComputerMove()
{
// Set to default values
int row = 0, col = 0;
// Check for a possible move
mpComputer->CheckForMoves(MAXDEPTH,Lose,Win,row,col); <-- this returns
// both the row and column but the following function wont work
// though the row and column is 1...
mpComputer->SetMove(row,col); <-- wont work...
Invalidate();
}
when i comment out this: CBoard Board = *mpBoard;
the whole function works just fine.... can anyone help me well, anways, thank you for your help... in advance
|
|
|
|
|
You have something wrong somewhere in your CBoard equal operator logic. The most likely culprit is that you are overwritting something in memory that something in SetMove does not like. Debug into CBoard& operator=( CBoard& );
"There's a slew of slip 'twixt cup and lip"
|
|
|
|
|
OH ok... thanx... i think your right coz i didnt write a default = operator. so i thnk thats the bug... thank you very much again stan
|
|
|
|
|
Are you writing a chess engine?
-CDudd
|
|
|
|
|
no... i am actually writing a Tictactoe program to so i can practice the alpha-beta pruning method.
|
|
|
|
|
I have few modeless dialogs in a specific time and i want
that the dialog that the user click on her will be above all the dialogs - how can i do that???
Thank
|
|
|
|
|
I think WM_LBUTTONDOWN or WM_ACTIVATE will help you
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|