|
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.
|
|
|
|
|
Got it.
Jon Sagara
Help me out here, Spock. I don't speak stupid.
|
|
|
|
|
Well, I downloaded the sdk for MSN Messenger and Windows Messenger; I wanted to tweak the UI, among other things.
From what I can tell, they don't provide for that functionality, however.
Does anyone know if there is any method other than hacking Messenger to create a new UI for it?
(I guess this would be somewhat similar to skinning, but my UI wouldnt just be a different appearance, but also provide for additional functionality.)
Any help, or links to other web sites that might help me in my research, would be most appreciated.
James A Beggs
Microsoft MSN Mobile Component Test Team
|
|
|
|
|
Is there anyway to force a window created using this command to stay on top of its parent window at all times (kind of app modal)?
However, I have a problem with when other windows overlap the parent window of my message. This message sort of pops up in front of the new dialog as well..
Any solutions?
|
|
|
|
|
Did you try with setting pParentWnd parameter of CFrameWnd::Create to AfxGetMainWnd()?
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
Or did you try with setting pParentWnd parameter to NULL?
|
|
|
|
|
I have written a dll that acts as a central location for a specific data set. I've set the following declaration:
#ifdef __cplusplus
#define EXPORT extern "C" __declspec(dllexport)
#else
#define EXPORT __declspec(dllexport)
#endif
My problem is this. I have an array of data that is built and maintained within the DLL. I have a function that returns a pointer to that data set (array). Upon shutdown of the application, I get the following error:
"dbgheap.c line 1011 _CrtIsValidHeapPoint, or an error accessing the heap"
The trace in debug dumps this:
"Heap Block at c50038 modified at c572e0 past requested size of 72a0"
What I believe is happening is the application tries to clean up, but the memory for this data pointer I have is located in the DLL heap, i.e., not local to the app, causing this error.
I thought I could just free the point in the application and all would be fine, but this is not working at all.
Any suggestions? I have no idea on this one. I thought it might be how I'm declaring the function, or dll as stated above, but that doesn't fix the issue.
Any help is GREATLY Appreciated as I am really lost here. Thanks.
Dan
|
|
|
|
|
It seems that you're freeing blocks allocated on another heap. Are you using C runtime in static library?
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
If you want to allocate memory in a Dll and free this memory elsewhere you can use a GlobalAlloc / GlobalFree ( with the GMEM_FIXED flag you only have to change the alloc and the free lines ).
|
|
|
|
|
Hi
I issued this problem week ago but I still haven't solved it. Now I know a bit more about the nature of the problem. I created MFC program (dialog application) and I'm trying to execute such code:
CBitmap Bitmap;<br />
int a = 0;<br />
SetLastError(0);<br />
a = GetLastError();<br />
if( !Bitmap.LoadBitmap( IDB_BITMAP1 ) ) MessageBox("loadbitmap");<br />
a = GetLastError();<br />
SetLastError(0);<br />
if( !OpenClipboard() ) MessageBox("openclipboard");<br />
a = GetLastError();<br />
SetLastError(0);<br />
if( !EmptyClipboard() ) MessageBox("emptyclipboard");<br />
a = GetLastError();<br />
SetLastError(0); <br />
if( !SetClipboardData( CF_BITMAP, Bitmap ) ) MessageBox("setclipboarddata");<br />
a = GetLastError();<br />
SetLastError(0);<br />
if( !CloseClipboard() ) MessageBox("closeclipboard");<br />
a = GetLastError();<br />
SetLastError(0);<br />
Everything works perfect under Win2000, but under Win98 not, so I installed VC6.0 under Win98 to examine the problem. I don't get any runtime errors, program executes smoothly, but when I try to paste from clipboard (in Paint) nothing appears. When I execute my code for second time Paint shows message "Error in acquiring data from clipboard" (that's my translation from polish version of Windows, so it can be a bit different in english version). Someone advised me to empty clipboard before pasting but it doesn't help Anyone have any clue (this is quite urgent unfortunately). Thanks in advance.
Greetings
Mariusz Popiolek
|
|
|
|