|
So what part of your assignment do you need help with?
Which part don't you understand and maybe we can assist?
|
|
|
|
|
The debugger is of big help in such circumstances.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
I create Dialog Box with
case WM_CTLCOLORSTATIC:
{
HDC hdcStatic = (HDC)wParam;
SetTextColor(hdcStatic, RGB(255, 255, 255));
SetBkMode(hdcStatic, TRANSPARENT);
return (long)(g_hbrBackground);
}
but after chusing another program and return to dialog activation -
it don't show dialog box at all!!!
(when I do UpdateWindow in case ON_PAINT, it show dialog, but without color!!)
|
|
|
|
|
The code you posted wouldn't have anything to do with that problem
(I'm assuming that code is in the dialog proc).
Using UpdateWindow in response to WM_PAINT is BAD. It's redundant, and also probably won't do anything.
UpdateWindow causes a WM_PAINT message to be sent by the system if any area of the window
being updated is marked invalid.
You're doing something wrong somewhere in your dialog proc if the window is not redrawing properly.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
The only thing that's changed is a few small icons scattered throughout the page so it's kinda annoying that calling Refresh() loses the current scroll position.
Tried saving and restoring the scroll position used the techniques described here[^] (and in the comments) but despite no failure codes returned, the page doesn't want to scroll
I enjoy occasionally wandering around randomly, and often find that when I do so, I get to where I wanted to be [^].
Awasu 2.3.3 [^]: A free RSS/Atom feed reader with support for Code Project.
|
|
|
|
|
Hello.
I have an application that uses TCP Sockects to see if a port is alive
or dead.
For this I use a thread for every TCP-Ping that I do.
In each thread I open a socket and try to execute a blocking Connect
command.
I test this application on a list of 2000 IP:Port devices
The application tries this TCP-Ping for all these devices in every 10
minutes.
After about 6 hours, on every Connect attempt I get the WSAENOBUFS
error.
Also my computer seems to stuck.
Only if I kill the aplications process - the computer recovers and I
can run this aplication again for another 6 hours.
I tried almost everything to change the TCP parameters through the
registry, and also to kill and free the socket.
Here is the sample code of the thread:
WSAStartup( MAKEWORD(2,2), &wsaData );
m_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if ( m_socket == INVALID_SOCKET )
{
LogMsg.Format("ERROR socket INVALID_SOCKET: %d", WSAGetLastError());
WSACleanup();
hr = E_FAIL;
return hr;
}
clientService.sin_family = AF_INET;
clientService.sin_addr.s_addr = inet_addr(IpAddress);
clientService.sin_port = htons(Port);
rc = connect(m_socket, (SOCKADDR*) &clientService, sizeof(SOCKADDR));
if (rc == SOCKET_ERROR)
{
LogMsg.Format("ERROR connect SOCKET_ERROR: %d", WSAGetLastError());
LOG_OUTPUT(LogMsg.GetBuffer());
hr = E_FAIL;
}
else
{
hr = S_OK;
shutdown(m_socket, SD_BOTH);
}
CancelIo((HANDLE)m_socket);
closesocket(m_socket);
WSACleanup();
return hr; I don't understand why I have this error - it seems like after a
period of time the TCP buffer is filled although I don't use any TCP
command that takes TCP buffer (only createSocket and Connect), does
these commands take TCP buffer? how do I free the buffer?
After finishing this code, the thread exits.
I also tried to use the Select, WSAEventSelect, CreateIoCompletionPort
commands with a non-blocking socket and had the same results.
Can anyone help me?
|
|
|
|
|
itai shmida wrote: For this I use a thread for every TCP-Ping that I do.
In the task manager, Can you check how many threads your application has at
that specific instance?and see if that's the expected count . Also are you sure you are cleaning up all the stuff neatly?
The port no is > 5000 and you are getting this error?
http://support.microsoft.com/kb/196271[^]
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
modified on Sunday, April 6, 2008 6:56 AM
|
|
|
|
|
In addition to VuNic's excellent reply...
It sounds to me like you're got a memory/resource leak somewhere.
The code you posted looks OK, although IMO the CancelIo() call is useless and unnecessary.
itai shmida wrote: I test this application on a list of 2000 IP:Port devices
How? Do you use 2000 simultaneous threads?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
No, I devide the number 2000 in 5 minutes, that means I start a thread every 150 miliseconds.
I can see how many threads run simultaniously - it is about 20-30 threads.
I know it looks like a memory leak, but in the TCP Stuck. the CancelIo() command is one of my tries to free up the memory from the TCP stuck, and it does not help, also I edited the registry for changing the TCP Params as follows:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]
"MaxUserPort"=dword:0000fffe
"TcpTimedWaitDelay"=dword:0000001e
"StrictTimeWaitSeqCheck"=dword:00000001
That also does not help.
The problem is the memory of the TCP Stuck, but I use it OK - I only do a connect() request and not any read or write, how can I free or check the TCP memory stuck?
|
|
|
|
|
can anyone help to write a progam by c++ to defragment disk!!! thank so much!!!
|
|
|
|
|
JkDefrag[^] is an amazing open source disk defragmentation program.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
I am doing a socket programming in c. The basic client server works fine. And i have hard coded the ip address and port numbers as shown below:
service.sin_addr.s_addr = inet_addr("127.0.0.1");
service.sin_port = htons(55555);
Now i want to put the ip address and the port number in a text file and try to initialise the ip add and port no from this file. Can anyone give me an idea about hows i should write the ip add and port no in a text file and what are the commands required for initialise the ip add from the file.
cheers
|
|
|
|
|
Hi,
You can use the INI file to read/write the information needed by application.
You can read IP address into a string, and port number into an integer variable and use these variable to call initialization functions.
An article here: How to read and write an INI File[^]
Thanks,
Suman
--
"Programming is an art that fights back!"
modified on Saturday, April 5, 2008 9:23 PM
|
|
|
|
|
hi!,
i tried INI file read and write but VS C++ does not support afxwin.h. SO is there another way to go about it. Anyways i am trying on this but if u have some other option maybe i can try tht out.
thanks
|
|
|
|
|
Hi,
Are you using Express version of vc++?
If its Express version, there will be no MFC.
afxwin.h is MFC's file.
Thanks,
Suman
--
"Programming is an art that fights back!"
|
|
|
|
|
HI,
yes i am using express version so now whats do you think i should do?
|
|
|
|
|
Hi,
Check are you able to use C's standard file handling something
like:
<br />
FILE *pFile;<br />
pFile = fopen("SETTINGS.TXT", "r");<br />
Take a look at here: Stream I/O[^]
Thanks,
Suman
--
"Programming is an art that fights back!"
modified on Saturday, April 5, 2008 11:14 PM
|
|
|
|
|
you don't need MFC to access a INI file, have a look at [^]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
ADTC# wrote: I am doing a socket programming in c. The basic client server works fine.
*Amaze*
Read_file----->string x--->inet_addr(x)
Read_file---->string x--->htons(atoi(x))
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
ADTC# wrote: The basic client server works fine
If you are able to do basic client server then I am pretty much sure that you would be able to do basic file and string IO. So following basic things you can do.
1. Have your IP address and port number in a standard text file
The format can be like this
IP ADDRESS : 127.0.0.1
PORT NUMBER : 1234
2. Read the file line by line using standard file IO and store them in two strings
3. Split the strings by ":" token. Now you have IP address and port number in two of the four strings.
Hope this helps.
"Give a man a fire and he's warm for a day, set a man on fire and he won't feel cold for the rest of his life."
|
|
|
|
|
i would like to create a windows form application which captures the keyboard inputs.
Can someone tell me the best and easiest method?
thanks...
|
|
|
|
|
Do you mean Windows Forms in .NET or a dialog form?
For forms in .NET, you'r on the wrong discussion board - use the Managed C++/CLI board[^] instead.
Otherwise, any window in a Windows app that has the keyboard focus will receive WM_KEYDOWN and WM_KEYUP
messages, and also WM_CHAR messages if TranslateMessage is caled in the app/thread's message loop.
If you want to catch keyboard input system-wide, you can use a hook. See SetWindowsHookEx[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
i got my answer
it is helpfull
thanx...
--we were great,and we will rise again--
--------Don't forget--------------------
--always comes daylight after night-----
|
|
|
|
|
Hi every body!
I used the following connectioin string to connect to a MS Access database:
<br />
"DRIVER={Microsoft Access Driver (*.mdb)};DBQ=FilePath;PWD=Password;"<br />
Every thing went fine unless I tried to close the app; The following error code appeared:
"The instruction at "0x000faf" referenced to memory at "0x00faafe". Memory could not be "read". Click OK to terminate the program."
Next I added the following expresion to connection string:
"MaxBufferSize=2048;
And my problem disappeared.
Why?
|
|
|
|
|
It's still up to you to find out what's going on.
You said it happens just opening and closing the database - in that case, there's not a whole
lot of code to step through
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|