|
yup i'm using a vector
but is the form "Formview" suitable for drawing or should i select another type?
i'm new on drawing :s
"The Ultimate Limit Is Only Your Imagination."
|
|
|
|
|
Ok I'tested on a FormView and it works i had a white circle it was a stupid querstion
"The Ultimate Limit Is Only Your Imagination."
|
|
|
|
|
You can draw on any window.
A CFormView is useful when you have controls you need to layout on the window like a dialog window.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
You don't necessarily have to write the code three times.
However you write the code, it must call Ellipse() three times.
These are two equivalent examples:
void CMyWnd::OnPaint()
{
CPaintDC dc(this);
dc.Ellipse(10, 10, 50, 50);
dc.Ellipse(30, 30, 70, 70);
dc.Ellipse(50, 50, 90, 90);
}
void CMyWnd::OnPaint()
{
CPaintDC dc(this);
CRect CircleRect(10, 10, 50, 50);
for (int i = 0; i < 3; i++)
{
dc.Ellipse(&CircleRect);
CircleRect.OffsetRect(20, 20);
}
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
when i click on the butoon nothing is drawin !!!
is it a prob of reference to the dc .?
<br />
void CSecondForm::OnButton1() <br />
{<br />
<br />
CPaintDC dc(this);<br />
dc.Ellipse(20, 20, 100, 100);<br />
}<br />
"The Ultimate Limit Is Only Your Imagination."
|
|
|
|
|
You can only use a CPaintDC when responding to a WM_PAINT message (in OnPaint()).
Use a CClientDC in your button click handler instead...
void CSecondForm::OnButton1() <br />
{<br />
<br />
CClientDC dc(this);<br />
dc.Ellipse(20, 20, 100, 100);<br />
}
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thank you It works now.
but a last question ? how could i write a text into the cercle like "Cercle1" etc..
ANd thank you for your help.
"The Ultimate Limit Is Only Your Imagination."
|
|
|
|
|
You'll need to select a font into the DC (unless you want to use the default font), then you can use any of the
GDI text rendering functions (CDC::DrawText[Ex](), CDC::TextOut(), CDC::ExtTextOut(), etc.) to draw the text.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
<br />
void CSecondForm::OnButton1() <br />
{<br />
<br />
CClientDC dc(this); <br />
dc.Ellipse(10, 10, 70, 70);<br />
dc.Ellipse(20, 20, 70, 70);<br />
dc.Ellipse(30, 30, 70, 70);<br />
dc.Ellipse(40, 40, 70, 70);<br />
CString str;<br />
str="Cercle";<br />
CDC::TextOut(100,100,str);<br />
}<br />
CDC::TextOutA' : illegal call of non-static member function
i atried even with CDC::TextOut(100,100,"Cercle");
Same prob
"The Ultimate Limit Is Only Your Imagination."
|
|
|
|
|
I found it, srry for the multipost.
void CSecondForm::OnButton1()
{
// TODO: Add your control notification handler code here
CClientDC dc(this);
dc.Ellipse(10, 10, 70, 70);
dc.Ellipse(20, 20, 70, 70);
dc.Ellipse(30, 30, 70, 70);
dc.Ellipse(40, 40, 70, 70);
CString str;
str="Cercle";
dc.TextOut(100,100,str);
}
"The Ultimate Limit Is Only Your Imagination."
|
|
|
|
|
You got it
I notated it that way ("CDC::") to show what class the methods were in - the CDC class.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
yup ou are all reason
Thank you ppl.
"The Ultimate Limit Is Only Your Imagination."
|
|
|
|
|
|
Here is what I am supposed to do:
Write a program that inputs and holds up to 100 novels. Be sure that the program holds at least the title, author (last name first), category, whether its an enjoyable book (rate 1-10), and the number of pages. Experiment and find a way to sort the completed list by one of the following choices (at the users’ discretion): by title (be CAREFUL – think about library listings), by author, by category, or by number of pages. Have the program display the sorted list in a table. The user should be able to save their list to a file with their choice of name. The program should be able to read back from said file. Be sure the user can save the list after it has been sorted, and they can add books when the list has been read in from the file.
Here is my PROBLEM: http://mycodewarriorcode.weebly.com/[^]
|
|
|
|
|
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
|
|
|
|
|