|
univega_r304 wrote: If I put *Cancel = TRUE; in NewWindow to prevent it spawning a new window then BeforeNavigate never gets called. It works for anything that doesn't spawn, however.
I would think that would be the case (i.e., BeforeNavigate() getting called) no matter what NewWindow() did to Cancel since BeforeNavigate() would not know about the new window.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Take a look at http://msdn.microsoft.com/workshop/browser/webbrowser/reference/ifaces/dwebbrowserevents2/newwindow3.asp
NewWindow3 may be the better way to go?
|
|
|
|
|
I have a toolbar that when it is floating I can resize ( manually ).
The toolbar contains a combobox, a couple of static (CStatic derived ) controls and some normal standard buttons.
something like drawn in lousy ascii art, where | is the gripper and - is a separator.
<code>|</code>combobox static1 static2 <code>-</code> button1 <code>-</code> button2 <code>-</code> button3 <code>-</code> button4
after I resize I get something like :
<code>|</code>combobox static1
static2 <code>-</code> button1 <code>-</code> button2 <code>-</code> button3 <code>-</code> button4
if I resize further ( including some blank space beforre static2):
<code>|</code>combobox static1
static2 <code>-</code>
button1 <code>-</code> button2 <code>-</code> button3 <code>-</code> button4
It seems that there is no "break" between the combobox and the static1 controls.
What is the mechanism that controls that breaks in the toolbar ? is it the separator ?
I'm not certain what to google for to get an explanation.
Thanks for the help.
Max.
|
|
|
|
|
Hi all,
OK, this is my first multi-threaded program ever. It's more a proof of concept rather than anything really useful. The main problem is that it's not working as I intended.
Overwiev:
An m*n array (double**) is filled with random numbers from -5 to 5. After that a thread gets created for each row of the array (i.e. we know that exactly m threads will be created). That thread will add all entries in that row, write the result to a particular memory location (double *result), decremnt the threadcount and exit.
Problem:
I want main() to create m-threads and then wait until the last thread exits. Then main is supposed to print the result to the screen and exit. So far I can't get main to wait on the threads. It continues execution despite my best efforts.
The code:
See below. It compiles on Microsofts Visual C++ 6.0. I have a lot of
#ifdef Mutex2... in there 'cos I want it to port it to Unix as well. Any hints in that direction are very much appreciated.
Thanks much
Mike
/////////////////////////////////////
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#ifdef WIN32
#include <windows.h>
#include <process.h>
#endif
#ifdef SOLARIS
// ?????? POSIX threads maybe?
#endif
//////// definitions ///////////
#ifdef WIN32
#define MUTEX1 1
#define MUTEX2 0
#endif
#ifdef SOLARIS
#define MUTEX1 0
#define MUTEX2 1
#endif
//////// data struct ///////////
struct data{
int size;
int id;
double *row;
double *result;
};
//////// globals ///////////////
int threadcount;
#if MUTEX1
HANDLE hMutex;
HANDLE doneMutex;
#endif
#if MUTEX2
#endif
//////// functions /////////////
void sum(void*);
////////////////////////////////
int main(int argc, char *argv[])
{
if(argc != 3){
printf("useage: <exe> <# of rows > 0> <#of columns > 0>\n");
exit(0);
}
int i,j;
int row = atoi(argv[1]);
int col = atoi(argv[2]);
double **arr = NULL;
double *result;
struct data *list;
struct data *ptrlist;
#if MUTEX1
hMutex = CreateMutex(NULL, false, NULL);
doneMutex = CreateMutex(NULL, true, NULL);
#endif
#if MUTEX2
#endif
list = new data[row];
arr = new double*[row];
for(i = 0; i < row; i++){
arr[i] = new double[col];
}
result = new double[row];
for(i = 0; i < row; i++){
for(j = 0; j < col; j++){
arr[i][j] = -5 + rand() % 11;
}
}
list->size = col;
for(i = 0; i < row; i++){
result[i] = -99;
}
threadcount = row;
#if MUTEX1
WaitForSingleObject( doneMutex, INFINITE );
// I was hoping that main() would suspend execution when it hits the 2nd WaitForSingleObject( doneMutex, INFINITE )
// a few lines further down. It doesn't. Why?
#endif
#if MUTEX2
#endif
///////////////////////////
for(i = 0; i < row; i++){
list[i].size = col;
list[i].id = i;
list[i].row = arr[i];
list[i].result = result;
ptrlist = list+i;
#if MUTEX1
_beginthread(sum, 0, (void*)ptrlist);
#endif
#if MUTEX2
#endif
}
#if MUTEX1
WaitForSingleObject( doneMutex, INFINITE );
// I was hoping to lock the doneMutex and have the last thread (i.e. threadcount == 0) unlock it.
// ...that strategy doesn't do the job. main() does not wait until the last thread releases this mutex. Why?
#endif
#if MUTEX2
#endif
// This while-loop should never execute IF main() would wait for the doneMutex to be released by the last thread upon exit.
// Sadly it doesn't care.
while(threadcount > 0){
// while this appears to work, I really want main to wait until the last thread exits.
printf("threadcount = %i\n", threadcount);
}
for(i = 0; i < row; i++){
printf("%i. %f\n", i, result[i]);
}
#if MUTEX1
ReleaseMutex( doneMutex );
#endif
#if MUTEX2
#endif
for(i = 0; i < row; i++){
delete [] arr[i];
}
delete [] arr;
delete [] result;
delete [] list;
return(1);
}
//****************************************
void sum(void *arg)
{
double sum = 0;
int i;
struct data *list = (struct data*)arg;
for(i = 0; i < list->size; i++){
sum += list->row[i];
}
list->result[list->id] = sum;
#if MUTEX1
WaitForSingleObject( hMutex, INFINITE );
#endif
#if MUTEX2
#endif
threadcount--;
printf("ID = %i sum = %f\n", list->id, sum);
if(threadcount == 0){
ReleaseMutex( doneMutex );
// Here I figured the last thread exits and releases the Mutex for main().
// Anyway, main() dosn't appear to wait on this Mutex, it continues execution regardless
}
#if MUTEX1
ReleaseMutex( hMutex );
_endthread();
#endif
#if MUTEX2
#endif
}
//****************************************
|
|
|
|
|
so, it doesn't even stop at the first WaitForSingleObject(doneMutex,..) ?
|
|
|
|
|
Should it wait at the first WaitForSingleObject( doneMutex, INFINITE )?
I intended for main() to lock the mutex at the first call. Then create all threads and have the last thread release it. The 2nd WaitForSingleObject( doneMutex... is where main() is supposed to wait on the last thread to exit.
Obviously I am not doing it right, I am open to suggestions. I also tried semaphores, same problem.
|
|
|
|
|
you could try Events.
1. create an Event object (just like creating a Mutex) in your main
2. launch your threads
3. WaitForSingleEvent on the Event in main()
4. SetEvent from the worker thread, when done. that will let your Wait* return.
5. CloseHandle to clean up the Event
|
|
|
|
|
You might have better luck using WaitForMultipleObjects (MSDN). Make an array of your thread handles and pass that into WaitForMultipleObjects with the bWaitAll parameter set to TRUE.
That will be cleaner and much easier to debug than working with a Mutex in this case.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
|
MFC CDatabase and CRecordset (ODBC baby!). but that's because I don't know any better.
I'm one of those stubborn mules who is usually the last on on the bus so don't take my advise but feel free to contemplate it all you want. (Disclaimer for the person who will follow my post with "why not just use ADO?")
-- modified at 15:28 Tuesday 8th August, 2006
|
|
|
|
|
My favourite API for using *ANY* database is OTL.
http://otl.sourceforge.net/
|
|
|
|
|
Hi all
I am doing Win32 based C programming.
How to use _TrackMouseEvent to track mouse movement over a button. ie, I need one signal when mouse moves over the button and another one when it moves away from the button
I am calling _TrackMouseEvent in WM_INITDIALOG message handler...like this
track.cbSize = sizeof(TRACKMOUSEEVENT);
track.dwFlags = TME_HOVER;
track.hwndTrack = handle; // Handle to the Button
track.dwHoverTime = HOVER_DEFAULT;
_TrackMouseEvent(&track);
Then, I am not getting WM_MOUSEHOVER message.
I am not getting how to use these functions.
Any kind of suggestions are welcome..thanks
Manjunath S
Bangalore
|
|
|
|
|
I think the TrackMouseEvent function is to be used only when you receive a WM_MOUSEMOVE message for your button. Therefore try this function in OnMouseMove handler of your button. (I suppose you have to derive your own control from CButton ). After this you should be able to receive WM_MOUSEHOVER and WM_MOUSELEAVE messages inside your button class.
I hope it helps.
|
|
|
|
|
I am trying to create a client that connects to a server on TCP port 80. The connect() is successful. I can also send and receive some packets successfully. After I send a few packets recv() returns error WSAECONNRESET. If I use any port other than port 80 the same problem does not happen. Any ideas on why this could be happening?
|
|
|
|
|
The server is more and likely hanging up on you as you are violating the http protocol. Web servers work best by handling lots of little transactions for many people quickly, if you are debuging it might be timing out on you.
|
|
|
|
|
Thanks for replying. I am not using http web server. It's my own server which listens and accepts connections on port 80!
|
|
|
|
|
lol - well, first, don't use 80.... that port is expected to talk to a web server at the given ip address. I know, I know, it's your machine, but it's bad form .
Now, the part that makes me chuckle is that *your* server is sending this response... Usually, the server is some box out in the network cloud that you have 0 control over. So I'd take a look at what the server is not happy about. I'd guess you are not completely transferring all the data, but it's just a guess.
Charlie Gilley
Will program for food...
Whoever said children were cheaper by the dozen... lied.
My son's PDA is an M249 SAW.
My other son commutes in an M1A2 Abrams
|
|
|
|
|
MS MSDN says that a pattern bitmap brush larger than 8x8 pixels can be created by LOGBRUSH and CreateBrushIndirect on Win98.
My purpose is to fill a rectangle using the pattern brush.
but as I tested, the rectangle is not filled on Win98 because the pattern brush is not created properly.
have u used larger patten brush on Win98?
|
|
|
|
|
includeh10 wrote: My purpose is to fill a rectangle using the pattern brush.
I think you first have to create your pattern brush using CreatePatternBrush function. MSDN says that in Windows 98 brushes can be created from bitmaps larger than 8 by 8 pixels.
|
|
|
|
|
Hi All,
Can anybody tell me the exact "Difference between C++ Structures and C++ Classes".
I came to know that, apart from the access specifier Public(Structures) and Private(Classes) there is no other difference. Is that so?
In that case why do they have 2 difference entities namely Structure and Classes with similar functionality??
Kindly clarify.
|
|
|
|
|
I guess people who created C++ like the name "class".
|
|
|
|
|
Subramaniam s.V. wrote: In that case why do they have 2 difference entities namely Structure and Classes with similar functionality?
'struct' allows for backwards-compatibility with C
edit: what about this deserves a '1' vote?
-- modified at 15:09 Tuesday 8th August, 2006
|
|
|
|
|
Then why class were created?? struct itself is enough ..na?
nave
|
|
|
|
|
but c++ structure can have visibility declarators (public, protected, private), and member functions too..
nave
|
|
|
|
|
that's why i explicitely said C structs , not C++...
|
|
|
|