|
I need to create accuracte subsections, including the subsections of a line that may not be entirely in the square I am creating.
Christian
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Can anyone recomend a good free WinHelp authoring tool?
Asim Hussain
e: asim@jawache.net
w: www.jawache.net
|
|
|
|
|
|
Hello there,
How can i get IDispatch from _Recordset ??
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Hi,
I have a ownerdraw listbox and need to use multiple fonts (normal, bold, underlined). At the moment I create the fonts each time in my DrawItem handler. Is this really necesarry? Or can I precreate them once and reuse the font objects?
My experience with windows controls is poor, so thanks for feedback.
|
|
|
|
|
You can have the fonts precreated as members of your class and use them in DrawItem as necessary. Just remember to deselect them from the drawing DC when exiting DrawItem .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
Just remember to deselect them from the drawing DC when exiting DrawItem.
I believe you can leave them selected (if fonts are precreated). The lifetime of DC used in WM_DRAWITEM is shorter than lifespan of the window.
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
Hi Tomasz! We seem to be disagreeing all the time tonight MSDN docs say (here[^]):
The application should restore all graphics device interface (GDI) objects selected for the display context supplied in lpDrawItemStruct before this member function terminates.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
We seem to be disagreeing all the time tonight
That's my favorite aspect of CP forums
Anyway, I was thinking along deselect-or-else-your-font-will-not-be-destroyed line. The MSDN guideline applies to locally created fonts as well.
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
Well, I happily admit that the selection/deselection stuff is one of those things I've been wanting to understand in detail since long ago but didn't have time to learn about. Usually I'm content with the most conservative approach of deselecting everything.
*** Si fractum non sit, noli id reficere. ***
I'd say it is better "Si fractum non est, noli id reficere".
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
I'd say it is better "Si fractum non est, noli id reficere".
Quick google reveals that it's actually 'non sit'. Maybe it's just kind of Latin urban legend
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
Joaquín M López Muñoz wrote:
. Just remember to deselect them from the drawing DC when exiting DrawItem.
Well, this is something I don't understand yet... why do I need to deselect them? Could you explain me a little more background or pointing me to a tutorial?
Once I forgot to deselect my bold font in DrawItem(), the listbox keept drawing in bold. I didn't got any error/problems.
Thanks!
|
|
|
|
|
Well, I don't undertand all the issues behind this policy, but apparently the DC could be used somewhere else and display strange things because of the garbage you left out. Also, resource leaks can occur, I think.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
okay i read some msdn and make it work (hopefully hehe). thanks for your help!
|
|
|
|
|
Anonymous wrote:
Or can I precreate them once and reuse the font objects?
You can do that.
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
Oh... I should have asked: if possible, where do I precreate the fonts (the current/default font must be available at this time)? How can I catch system changes (similar OnSysColorChange)?
|
|
|
|
|
I wrote:
Oh... I should have asked: if possible, where do I precreate the fonts (the current/default font must be available at this time)? How can I catch system changes (similar OnSysColorChange)?
If there is someone with help to this question, I would be happy too. I'll take a look in existing source, perhaps I find some answers...
|
|
|
|
|
I found one answer: CListBoxChat::PreSubclassWindow() is the place to create the fonts
|
|
|
|
|
I'm not very familair with C++, but I'm making a program that acts as a client and server.
I've based my code on one of the examples from this web site (http://www.codeproject.com/internet/winsockintro01.asp). Below is the important part of the code:
UINT MTServerThread(LPVOID pParam)
{
WSADATA wsaData;
sockaddr_in local;
int wsaret=WSAStartup(0x101,&wsaData);
if(wsaret!=0)
{
return 0;
}
local.sin_family=AF_INET;
local.sin_addr.s_addr=INADDR_ANY;
local.sin_port=htons(listenSendPort);
server=socket(AF_INET,SOCK_STREAM,0);
if(server==INVALID_SOCKET)
{
return 0;
}
if(bind(server,(sockaddr*)&local,sizeof(local))!=0)
{
return 0;
}
if(listen(server,10)!=0)
{
return 0;
}
SOCKET client;
sockaddr_in from;
int fromlen=sizeof(from);
while(true)
{
client=accept(server,(struct sockaddr*)&from,&fromlen);
if (client == INVALID_SOCKET)
{
return 0;
}
else
{
cout << "Connection from " << inet_ntoa(from.sin_addr) <<"\r\n";
AfxBeginThread(ClientThread,(LPVOID)client);
}
}
return 0;
}
UINT ClientThread(LPVOID pParam)
{
char buff[512];
int n;
SOCKET client=(SOCKET)pParam;
while(true)
{
n = recv(client,buff,512,0);
if(n==SOCKET_ERROR )
{
break;
}
buff[n]=0;
cout << " Received Message: " << buff << "\n";
break;
}
closesocket(client);
return 0;
}
My problem is at the end of MTServerThread(), it calls the accept method on the socket. If you notice, I echo out the IP of the connection immediately after.
However, I want my program to be able to have multiple connections going on, and output the message with the persons IP address. Because of this, I need to have access to the persons IP address when I output the received message.
I tried creating a struct containing the client socket and the ip address from MTServerThread, and passed it into ClientThread, but for some reason it wouldn't allow me to cast the struct as LPVOID (which I find odd because I thought SOCKET was just a struct).
I may be wrong, but it looks as if accepting the connection is important to the threading of the program since it only spawns a new thread when a new connection is found, so moving the accept method into the ClientThread, thus allowing me access to the IP there is a no-go.
Any ideas how I can have access to the IP matching the received message in a multi-socket program?
|
|
|
|
|
I tried creating a struct containing the client socket and the ip address from MTServerThread, and passed it into ClientThread, but for some reason it wouldn't allow me to cast the struct as LPVOID (which I find odd because I thought SOCKET was just a struct).
This can be done (though some precautions have to be made against memory leaks). Could you please post the code to see where the error is?
I may be wrong, but it looks as if accepting the connection is important to the threading of the program since it only spawns a new thread when a new connection is found...
This is not true; you can happily pass the SOCKET to a different thread and let it call accept on it.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I moved the accept method into the the ClientThread, and asside from some misc. cleanup problems with my error out messages, it's working fine, thanks.
On the struct problems... I took it out of my code when it didn't work. Basically, it said my struct was an improper cast to LPVOID, if I remember correctly.
|
|
|
|
|
at time of accept() is not the only time you can determine the endpoint of your connection. See getpeername().
Signature space for rent. Apply by email to....
|
|
|
|
|
So our build department moved the Source Safe server last night. No problem. To make a long story short, I clicked the "no" button when asked whether to attempt to reconnect to source safe in the future.
Now, for the life of me, I can't get my Visual C++ project to connect to Source Safe. When I right-click on a file in File View, I don't get the option to check in/out files, etc.
Does anyone know of a switch to turn source control integration for a project back on?
Thanks,
Jon Sagara
Help me out here, Spock. I don't speak stupid.
|
|
|
|
|
Can't you just get latest version from server?
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
I tried that. It didn't work. I'm looking for something that exists within VS itself, not within my project. Hopefully that something exists.
Jon Sagara
Help me out here, Spock. I don't speak stupid.
|
|
|
|