|
Thanks very much for the replies - could you please tell me more about how to do the direct draw method? Best regards
NICK
ps I'm on WinNT 4, I believe that may not run the latest versions of DirectX?
|
|
|
|
|
Also, you should not call your OnPaint directly especialy if your using a CPaintDC. Windows does soem extra setup/tear down for on apinf stuff. You should write a Draw() procedure which you pass a HDC to and then use a function which uses GetDC() relaseDC() to call you paint function.
If you vote me down, my score will only get lower
|
|
|
|
|
This has been bugging me for years.
In Visual Studios 6, if I go to the frame menus and go [edit] -> [Find] and enter some text and hit "mark all" button, this all works fine. BUT how do you clear the bookmarks where the text has been found????
This is a problem because if I perform another search and select "mark all" again, the bookmarks from the previous search remains. You get bookmarks everywhere.
Any help appreciated, thanks
IGeorgeI
George W
Software Developer
www.zsystems.ca
|
|
|
|
|
IGeorgeI wrote:
...how do you clear the bookmarks...
Ctrl+Shift+F2.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Thankyou
ARSALAN MALIK
|
|
|
|
|
does anyone know how many bytes are the header for an mpeg file? I'd like to take the first 20 bytes (or however many) of an existing mpeg of about 500 MB, then take the remaining chunks in 50 MB increments, append the appropriate header info to them all, so that I can split the mpg up into 10 smaller files.
[insert witty comment here]
bdiamond
|
|
|
|
|
|
MPEG doesn't have file headers. The file is a sequence of blocks, each with its own header. Just split at block boundaries and the resulting files will be playable.
|
|
|
|
|
thanks. A friend of mine had a little .exe that he got off of planetsourcecode.com that allows you to do what I was talking about. It seems to work fine. Since I have one, there's no need to write one now!!;P
[insert witty comment here]
bdiamond
|
|
|
|
|
I've got a VC++ program in which I need to determine the dotted-numeric IP address of the PC its running on. What's the best/simplest way to do this?
Thanks for any ideas,
Craig
|
|
|
|
|
Call gethostname() followed by gethostbyname() .
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Ok...can anyone help me with this problem. I"m havinng troulbe to figure out how to use the data members and fill them both completely with zeros while initiallize them in the default constructor.
Here is what I have so for the my header (.h) file...
class ConnectFour
{
private:
//date members
int board[12][13];
int numChips[7];
public:
ConnectFour();
//default constructor
};
And here is what I have in my .cpp file....
ConnectFour::ConnectFour()
{
board[12][13] = 0;
numChips[7] = 0;
for(int i=0; i < 12; i++)
{
for(int j=0; j<13; j++)
{
board[i][j] = 0;
}
}
for(int i=0; i<7; i++)
{
numChips[i]= 0;
}
}
IS THIS RIGHT?....BELOW IS HOW IT IS SUPPOSED TO BE DONE ON THE DIRECTIONS FOR THIS PROGRAM!
THANKS GUYS ..YOU GUYS SAVE MY LIFE
Data Members:
1.)a 2-dimensional array to hold the board – To make it easier to check for wins you chould use a board that has 12 rows and 13 columns. Only rows 3 – 8 and columns 3 – 9 will actually hold the board (which has 6 rows and 7 columns). The remaining cells will always contain zeros.
2.)a single-dimensional array of 7 ints to hold the number of chips dropped into each column of the board.
Methods
1.)a default constructor to initialize both arrays – filling them both completely with zeros
|
|
|
|
|
(duh to myself )
board[12][13] = 0;<br />
numChips[7] = 0;
Think harder, how are arrays indexed in C++ ( or C ).
you're getting there ... hang tough ...
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Maximilien wrote:
(duh to myself )
It's been a hard day ??
|
|
|
|
|
ISUstudent wrote:
board[12][13] = 0;
numChips[7] = 0;
Remove this two lines: you are writing a zero outside the arrays (numChips[6] is the last cell of your array because it is zero indexed).
Otherwise it is correct.
|
|
|
|
|
And, does it work? Looks good so far. You may also want to use memset.
memset( board, 0, sizeof( board ) );
Hardy.
|
|
|
|
|
Instead of the for loops, you could simply call memset() . Other than that, what you have so far is okay.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
sweet. i just didn't know if i could have for loops and such in my defalut constructor
|
|
|
|
|
I have a Linked list with the following functions:
Add, Get, Delete.
For thread safe implementation I use a CRITICAL_SECTION handle in each function and everything work well.
The question is:
How I can avoid use of CRITICAL_SECTION on Get function?
Because Get function is called on many threads the performance is low, each thread wait the previous thread to finish Get.
Add and Delete are called rarely.
Thanks!
|
|
|
|
|
yes you can
I've already thought about this problem, too, and I found a very fast solution.
Lock the list by using interlocked functions, which use a LONG member variable of the class (I assume you use a list class) to synchronize access.
Don't try it, just do it!
|
|
|
|
|
I have used 2 interlocked vars and a semaphore. Below is a schematic of the code.
In this case the Get Thread has a very high access on the resource at 2 - 3 mil. of gets/sec
towards 20 - 50 of add and del /sec
If you have a better idea please tell me.
Thank you.
Get()
{
InterlockedIncrement(&_read);
while(_write > 0) Sleep(0);
CList::Get();
InterlockedDecrement(&_read);
}
Add()
{
while(_read > 0) Sleep(0);
InterlockedIncrement(&_write);
WaitForSingleObject(_sem,INFINITE);
CList::Add();
ReleaseSemaphore(_sem,1,NULL);
InterlockedDecrement(&_write);
}
Delete()
{
while(_read > 0) Sleep(0);
InterlockedIncrement(&_write);
WaitForSingleObject(_sem,INFINITE);
CList::Add();
ReleaseSemaphore(_sem,1,NULL);
InterlockedDecrement(&_write);
}
|
|
|
|
|
You can safely eliminate the CRITICAL_SECTION in your Get function if you make sure that your program is playing by the rules: as many threads can have read-only access to the list as long as none of them does an insertion or deletion. This usually involves some other synchronization mechanisms, although at a higher level than on the linked list itself, which presumably will yield better performance.
If you cannot guarantee this behavior in your program, another possibility is to protect access by means of a read/write lock. Such a lock allows multiple threads to enter for read access, except if some thread has reclaimed write access. A web search gives the following article[^] by Ivan Krivyakov on implementing read/write locks in Windows.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi.
A fast way to ensure synchronised access and update, is to use a simple 'mutex' that all three access/update methods conform to, ( as long as it is not a multi processor platform ).
If you do not care about the specific order in which access and/or update is performed, ie) its a free for all, then a simple WaitForSingleObject() on the mutex should provide a simple and fast mechanism.
James.
|
|
|
|
|
I'm afraid I'm not getting your point. If you protect every function of the list (Get , Add and Delete ), with a mutex, you'll get esentially what the original poster has already done with a CRITICAL_SECTION , with the added penalty that mutexes are heavier. My hunch is that the original poster asks for a way to allow many concurrent threads to be granted read access at a time, and not in a strictly one-by-one basis. Do you think this can be done with mutexes?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi.
By using a simple mutex, access and update can be synchonised very easily.
When the list needs to be updated, the mutex is 'set', the update is performed, this excludes all access's, the update is complete and the mutex is 'released'.
Since the majority of the operations, as per the 'poster' are accesses, waiting for the mutex is infrequent.
Since for the majority of the time, the mutex is 'released' the wait for reads' is satisfied 'immediately'
James.
|
|
|
|