|
I'm with you in the first section.. but when to use a flag.... how what flag?
can you show me?
|
|
|
|
|
When your app resets the time, you may (I'm not sure) get another WM_SYSTIMECHANGE message, causing your app to thrash. Use a flag to remember that your app manually reset the time. Clear the flag (if it was set) in OnSysTimeChange().
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
The function has to find the mode (number most found in the array, for ex. array[]{1, 2, 1, 1} the mode is 1 since it appears 3 times in the array while 2 only apears once.
movie is a class and it has a array of ints which movie.return_value(int) accesses. right now the mode equals the first number in the array, its like the second if isant getting evaluated right, anyway in my mind this should work and i cant find a way around it.
void getmode(movie_data movie){
int numfound0=0, numfound1=0, mode=0,
*num0ptr=&numfound0, *num1ptr=&numfound1, *modeptr=&mode;
for(int j=0;j<movie.return_count();j++){
*num0ptr="0;
" for(int="" k="0;k<movie.return_count();k++){
" if(movie.return_value(j)="=movie.return_value(k))
" if(*num0ptr="">*num1ptr){
num1ptr=num0ptr;
*modeptr=movie.return_value(j);
}
}
}
cout<<*num1ptr;
movie.put_mode(modeptr);
cout<
|
|
|
|
|
Hi,
Consider this code (yours is not readable):
GetMode(int array[], int count)
{
int freq, max = 0;
for (int i=0; i<count; i++)
{
freq = 0;
for (int j=0; j<count; j++)
{
if (array[j]==array[i])
freq++;
}
if (freq>max)
max = freq;
}
return max;
}
You have to replace array[x] with movie.return_value(x) and maybe some other few things, but the algorythm seems pretty simple.
You simply search for the most frequent value in the array.
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
The function has to find the mode (number most found in the array, for ex. array[]{1, 2, 1, 1} the mode is 1 since it appears 3 times in the array while 2 only apears once.
movie is a class and it has a array of ints which movie.return_value(int) accesses. right now the mode equals the first number in the array, its like the second if isant getting evaluated right, anyway in my mind this should work and i cant find a way around it.
void getmode(movie_data movie){
int numfound0=0, numfound1=0, mode=0,
*num0ptr=&numfound0, *num1ptr=&numfound1, *modeptr=&mode;
for(int j=0;j<movie.return_count();j++){
*num0ptr="0;
" for(int="" k="0;k<movie.return_count();k++){
" if(movie.return_value(j)="=movie.return_value(k))
" if(*num0ptr="">*num1ptr){
num1ptr=num0ptr;
*modeptr=movie.return_value(j);
}
}
}
cout<<*num1ptr;
movie.put_mode(modeptr);
cout<
|
|
|
|
|
Hi,
Consider this code (yours is not readable):
GetMode(int array[], int count)
{
int freq, max = 0;
for (int i=0; i<count; i++)
{
freq = 0;
for (int j=0; j<count; j++)
{
if (array[j]==array[i])
freq++;
}
if (freq>max)
max = freq;
}
return max;
}
You have to replace array[x] with movie.return_value(x) and maybe some other few things, but the algorythm seems pretty simple.
You simply search for the most frequent value in the array.
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
Hi!
I already searched everywhere and took a look at many, many exmaples on how using
DWebBrowserEvents2.
But I never got my DLL to work correctly
If someone has a link for me, where it is explained very easy (please NOT MSDN )
then tell me.
I took a look at the "CookieSpy" sample here at CodeProject, and would like to modify the source, that it will work without a dialog and only listen to DWebBrowserEvents2.
How can I easily modify it?
thanks in advance
|
|
|
|
|
Hi!
How can I change the different Windows cursors programatically?
I want the user of my program to be able to select a cursor file for one of the Windows cursors.
Thanks in advance!
Erik
|
|
|
|
|
Read about the SetSystemCursor in MSDN
|
|
|
|
|
Hello,
Does anyone one know what should be set in the PreCreateWindow function to remove the frame border from the CChildFrame window and\or the CFormView derived class?
I want to have something that looks more like a VB Form / Dialog window in that I would prefer a rasied 3d edge rather than the frame.
I think you have to do something with the cs.style, but cannot seem to get it right.
I thought something like :
BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style &= ~WS_THICKFRAME;
if( !CMDIChildWnd::PreCreateWindow(cs) )
return FALSE;
return TRUE;
}
Any suggestions would be welcome.
Thanks.
Giles
|
|
|
|
|
And if you add WS_DLGFRAME ?
cs.style &= ~WS_THICKFRAME;
cs.style |= WS_DLGFRAME;
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
I have tried this. It does remove the thich frame, and replace it with a thin frame, about have the thickness.
I still cannot get the edge of the MDI window to be just rasied rather than a frame.
The CFormView has no border in the resource editor.
Any ideas?
Thanks,
Giles
|
|
|
|
|
Oh, I understand now what you want to get!
You can't do anything from the dialog editor, because the CFormView is child of your CChildFrame window. I had a demo project that turned a from into a dialog, but I can't find it anymore.
However, try removing WS_EX_CLIENTEDGE from the extended style of the frame window.
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
I tried both
cs.style &= ~WS_THICKFRAME;
cs.style |= WS_DLGFRAME;
cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
and just
cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
by itself, but no luck.
I'm sure it must be simple, but it feels like I've been though all the permutations.
Giles
|
|
|
|
|
Yes, it doesn't work because of:
BOOL CFrameWnd::PreCreateWindow(CREATESTRUCT& cs)
{
if (cs.lpszClass == NULL)
{
VERIFY(AfxDeferRegisterClass(AFX_WNDFRAMEORVIEW_REG));
cs.lpszClass = _afxWndFrameOrView;
}
if ((cs.style & FWS_ADDTOTITLE) && afxData.bWin4)
cs.style |= FWS_PREFIXTITLE;
if (afxData.bWin4)
cs.dwExStyle |= WS_EX_CLIENTEDGE;
return TRUE;
}
Try to do that in OnCreate(), using ModifyStyle().
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
Still no luck. The frame border is still there. I wanted to use this for a database app, which I am converting from Access. I wanted something that had a forms like in Access with no frame.
If you do see an example of this in the future I would be grateful if you could tell me how?
Thanks once again,
Giles
|
|
|
|
|
It was the view...
void CDemoView::OnInitialUpdate()
{
ModifyStyleEx(WS_EX_CLIENTEDGE, 0);
}
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
The correct way:
CMyView::OnInitialUpdate()
{
ModifyStyleEx(WS_EX_CLIENTEDGE, 0, SWP_FRAMECHANGED);
CFormView::OnInitialUpdate();
}
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
Great!!!!!!
Your a genius.
Thanks for all your help!
Giles
|
|
|
|
|
I'm only hard-headed ...
I already did that once, so I should be able to do it again
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
Brilliant Paolo!
Nish
[Signature temporarily down]
|
|
|
|
|
For the whole thread, or just the last sentence?
However, thanks!
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
Paolo Messina wrote:
For the whole thread
Yes. More than the solution, it was your approach which I thought was amazing! Slowly moving towards the goal.
Joaquin had posted this link in one of his posts today [Mar 7th 2002]. That's why I actually replied to a thread that's almost half an year old
Nish
[Signature temporarily down]
|
|
|
|
|
hi, ok first of all, this project is pure win32, no MFC involved. I'm making a server that can accept multiple clients, when a client sends some data, the server sends it back to all connections. I'm using the sockets in asynchronous mode, i've already made the client but i'm having problems with the server and i've been trying to firgure it out for so long, i thought i'd try here. I can't find any example on the net of this, and i'm starting to believe there isn't one, all i could find was a server that used threads and echoed the data back to the connection the data was sent from.
This is what i have so far:
First i create a socket that listens for incoming connections, this socket is called "sd". then i have an array of 50 sockets: ac[50]
i initialize all these sockets with a loop from one to 50 giving them the value "NULL"
This is the code that is executed when the listening socket posts the FD_ACCEPT message to accept any incoming connection:
case FD_ACCEPT:
sockaddr_in sinRemote;
nAddrSize = sizeof(sinRemote);
ac[conn] = accept(sd, (sockaddr*)&sinRemote, &nAddrSize);
MessageBox (NULL, "Accepted incoming connection." , "Accepted", 0 + MB_ICONASTERISK);
conn = conn + 1;
break;
This works fine and multiple connections are accepted. The conn integer keeps up with the number of connections established.
Now here's the problem: every incoming connection is accepted by the ac socket, the first one by ac[0], the second one by ac[1] and so on and so on... till 50.
I used WSAAsyncselect on all ac sockets from 0 to 50 so when they are ready to receive data they post a message. Now what is supposed to happen is that somehow the received data is sent back to all connections, here's what i have now:
case FD_READ:
c = 0;
do
{
bytes_read = recv(ac[c], buf, sizeof(buf),0);
buf[bytes_read] = NULL;
c = c + 1;
}
while(bytes_read<=0);
for (y=0;y<=50;y++)
{
if (ac[y]!=NULL)
{
Len = strlen(buf);
if (send(ac[y], buf, Len, 0) == SOCKET_ERROR)
{
MessageBox (NULL, "error echoing data" , "Error", 0 + MB_ICONHAND);
}
}
}
break;
I tried to make multiple telnet connections and it worked but when i sent something, it got echo'd for the first connection but then it gave me the "error echoing data" messagebox...
Can anyone please tell me how to handle FD_READ so the server sends the data back to all connected clients???
Thanks...
Kuniva
P.S.: this thing is really startin ta bug me
|
|
|
|
|
Maybe more things are wrong in your code, but take a look at that:
case FD_READ:
c = 0;
do
{
bytes_read = recv(ac[c], buf, sizeof(buf),0);
buf[bytes_read] = NULL;
c = c + 1;
}
while(bytes_read<=0);
Since the sockets are asynchronous, there is a good chance that recv(..) will return SOCKET_ERROR for most of the sockets (the ones in which there is no pending data). SOCKET_ERROR equals to -1. Which means that your
buf[bytes_read] = NULL;
statement will overwrite some memory... In debug build there are good chances you won't even notice it - but there is a good chance that in Release build the program will crash.
That would probably also damage the results of your
Len = strlen(buf)
line.
Anyway, whenever you get a SOCKET_ERROR result, check the value returned from WSAGetLastError(). If this value equals WSAEWOULDBLOCK then it means the operation will complete later. I recommend reading Windows Sockets Network Programming by Bob Quinn (I think he's the Charles Petzold of Winsock) and Dave Shute, ISBN 0-201-63372-8.
Another note - writing a server that relies on Windows messages (or event Events) is ok for a small-scale server. But in a large one that should handle thousands, and probably even hundreds of simultaneous connections, you'd probably use some other method (like IOCP).
Good luck!
|
|
|
|
|