|
It was a long shot, but I tried it anyway. It had no effect, as expected.
I am getting offline now, but tomorrow I am going to reverse the changes I made yesterday and proceed with the changes one step at a time using the VC 6 environment instead of VC .NET, so I can see precisely when the error first appears.
Thanks for trying.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
If you know anything at all about either of these two functions, it's that SuspendThread[^] can be dangerous (primarily because it creates application deadlocks if not properly used). Read, Jochen Kalmbach's WebLog [^]
However, if you want to use the StackWalk64[^]function from the dbghelp.dll, you must call SuspendThread to get relavant and useful results.
So, what is the PROPER way to use SuspendThread? How could you possibly know of all the mechanisms and objects that are currently activated by a thread?
|
|
|
|
|
Baltoro wrote: However, if you want to use the StackWalk64[^]function from the dbghelp.dll, you must call SuspendThread to get relavant and useful results.
Only if you want to walk the stack of a thread other than the current one.
This is fairly obvious, if you didn't suspend the other thread it's stack would likely change while you are walking it.
The only problem in suspending another thread is that, as mentioned, any other threads waiting on the the suspended thread are going to keep waiting. This isn't a problem unless their waits time-out, even this isn't a problem because it tests your codes response to a rare error condition.
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
...thanks, ...cmk
I was referring to a remote thread, even though it was unstated.
I asked this question over on the Microsoft Technical Forums and got approximately the same answer.
It isn't really a problem, I was just curious.
|
|
|
|
|
using a socket I'm connecting to an irc server, when i do i get:
NOTICE AUTH :*** Processing connection to efnet.demon.co.uk
NOTICE AUTH :*** Looking up your hostname...
NOTICE AUTH :*** Checking Ident
NOTICE AUTH :*** Found your hostname
NOTICE AUTH :*** Got Ident response
this is all i get no welcome message, no matter what i send through this socket i don't get any response.
then after a while i get:
ERROR :Closing Link: 127.0.0.1 (Connection timed out)
thanks
|
|
|
|
|
What do you mean, you "get" that from the server? How are you receiving that text?
Are you sending the appropriate messages to connect to the server, as per the IRC protocol?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
What do you mean, you "get" that from the server? How are you receiving that text?
yes that is what i get from the server when i connect, via recv (s, buffer,bufferSize, 0);
Are you sending the appropriate messages to connect to the server, as per the IRC protocol?
not sure, according to this all you have to do is send commands like NICK name etc, once you are connected, but it doesn't seem to be working.
http://www.irchelp.org/irchelp/rfc/rfc.html
|
|
|
|
|
It's impossible to say without seeing any code, but things to look at are:
1) Parsing messages from the server - the protocol doesn't include message length
parameters so it's up to you to recv() all bytes whenever there's an FD_READ event
and parse the bytes into messages. Remember, on one recv(), you may only get a partial message.
You have to deal with that.
2) Make sure you're forming your client-to-server messages correctly. ASCII only - no Unicode.
Use proper whitespace. Check for server replies.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
connect function experimenting with:
int Client::Connect(HWND hwnd)<br />
{<br />
char message[200];<br />
cUser user;
sprintf(user.nick,"myNic");<br />
sprintf(user.ident,"IDspoonMan");<br />
sprintf(user.email,"vertexar@yahoo.com");<br />
sprintf(message,"USER %s %s: %s %s \n\r", user.nick , user.email , user.ident , user.ident );<br />
<br />
Port = 6667;<br />
WSAStartup(MAKEWORD(1,1), &wsaData);<br />
LPHOSTENT hostEntry;<br />
hostEntry = gethostbyname("efnet.demon.co.uk");<br />
if(!hostEntry)<br />
{<br />
::MessageBox(NULL,"Failed gethostbyname()","Error",0);<br />
}<br />
<br />
s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);<br />
ServerAddr.sin_family = AF_INET;<br />
ServerAddr.sin_port = htons(Port); <br />
<br />
ServerAddr.sin_addr = *((LPIN_ADDR)*hostEntry->h_addr_list);<br />
<br />
if (WSAAsyncSelect(s, hwnd, customClientMessage,FD_READ | FD_WRITE | FD_CONNECT | FD_CLOSE) == SOCKET_ERROR) <br />
{<br />
::MessageBox(NULL,"TSWCCould not set to non-blocking! ", "ERROR..", MB_OK);<br />
return false;<br />
}<br />
int CON_ERROR = connect(s, (SOCKADDR *) &ServerAddr, sizeof(ServerAddr));<br />
Sleep(10);<br />
send(s,"NICK mynic \n\r",15,0);<br />
send(s,"USER mynic 0 * myname \n\r",27,0);<br />
int errorCode = WSAGetLastError();<br />
if(!CON_ERROR)<br />
return true;<br />
return false;<br />
}
using telnet i tried this and it works:
o efnet.demon.co.uk 6667
NICK mynic
USER mynic 0 * myname
i dont see why is not working when i send it through my socket.
|
|
|
|
|
You're not using asynchronous sockets correctly.
You should be checking if connect() is successful. If it's not, you need
to check the error code - if it's WSAEWOULDBLOCK, then you need to wait until the
socket is connected before writing data to it. You'll know this when you get the
FD_CONNECT notification, at which time you need to check for errors again, to make sure
the connection succeeded. THEN you can write data to the socket.
"Sleep(10)" is really bad design. It could take hundreds or thousands of milliseconds to
connect.
Maybe you'll get lucky and connect() will succeed instantly (unlikely when connecting to a
WAN address) - you don't check for that though.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Lamefif wrote: using telnet i tried this and it works:
o efnet.demon.co.uk 6667
NICK mynic
USER mynic 0 * myname
i dont see why is not working when i send it through my socket.
My suggestion, either stick with a blocking socket so you can connect+send+evaluate... or use an non-blocking socket (something like CAsyncSocket). In the later case you would register an event handler for OnConnect(): socket got connected and you can send login information, plus an event handler for OnReceive(): more data has been received. It probably helps to have a look at example code.
/M
|
|
|
|
|
How do I communicate between two windows forms in the same application? I have a main form that uses "showDialog()" to create the second form in which i type some information. Upon clicking on the "Ok" button of the second form, i need to pass the information i typed to the main form.
I'm new to Managed C++ and a bit noob which C++, so, please, be patient...
I've tried to put a "System::Windows::Forms::Form^ form" as an argument in the constructor of the second form and then, when it was initialized in the main form, I used a "this" to pass the argument.. but it didn't work.
Code in the 2nd form:
SecondForm(System::Windows::Forms::Form^ form) {
}
Code in the 1st form:
SecondForm form2 = gcnew SecondForm(this)
form2->showDialog();
(i intended to pass information by using something like form->function(args)).
I've read something about using delegates, but the article was oriented for c#..
Can anyone help me, plz? Thanks
|
|
|
|
|
|
Hello...I'm trying to save an image that I captured to the clipboard to a bitmap image. and i've been unable to do so....I can open MS Paint and paste to save my image (Therefore I can confirm that part of the code works), but i'm trying to do it from within my executable. I tried to use 'CImage' to attach and save, but did not have any success under VC 6.0(Undeclared identifier for CImage). Any help would be greatly apperciated, Thanks!
Using VC++ 6.0, MFC dialog based
//Code that I have to capture image to clipboard
BOOL FullWnd;<br />
FullWnd = TRUE;<br />
CWnd *wnd=GetActiveWindow(); <br />
HDC hdc;<br />
HBITMAP m_Bitmap,m_OldBitmap,hMainBmp ;<br />
<br />
CDC dc;<br />
if(FullWnd)<br />
{ <br />
hdc = ::GetWindowDC(wnd->m_hWnd);<br />
dc.Attach(hdc);<br />
} <br />
else<br />
{ <br />
hdc = ::GetDC(wnd->m_hWnd);<br />
dc.Attach(hdc);<br />
} <br />
<br />
CDC memDC;<br />
memDC.CreateCompatibleDC(&dc);<br />
<br />
CBitmap bm;<br />
CRect r;<br />
if(FullWnd)<br />
wnd->GetWindowRect(&r);<br />
else<br />
wnd->GetClientRect(&r);<br />
<br />
CString s;<br />
wnd->GetWindowText(s);<br />
CSize sz(r.Width(), r.Height());<br />
bm.CreateCompatibleBitmap(&dc, sz.cx, sz.cy);<br />
CBitmap * oldbm = memDC.SelectObject(&bm);<br />
memDC.BitBlt(0, 0, sz.cx, sz.cy, &dc, 0, 0, SRCCOPY);<br />
<br />
BitBlt(memDC, 0,0,sz.cx,sz.cy, hdc,0,0,SRCCOPY); <br />
hMainBmp =(HBITMAP) SelectObject(memDC, oldbm);<br />
<br />
wnd->GetParent()->OpenClipboard();<br />
::EmptyClipboard();<br />
::SetClipboardData(CF_BITMAP, bm.m_hObject);<br />
CloseClipboard();<br />
<br />
memDC.SelectObject(oldbm);<br />
bm.Detach(); <br />
<br />
<br />
<br />
<br />
|
|
|
|
|
pls try with this..if it is confusing pls let me know..
parameter Info...
name--> name of file .bmp file with path.
bmp --> address of Bitmap structure
data--> Pixel data.
void WriteBmp(char* name,BITMAP *bmp,int* data)
{
BITMAPINFO Bmi;
memset(&Bmi,0,sizeof(BITMAPINFO));
Bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
Bmi.bmiHeader.biWidth = (bmp->bmWidth);
Bmi.bmiHeader.biHeight = (bmp->bmHeight);
Bmi.bmiHeader.biPlanes = 1;
Bmi.bmiHeader.biBitCount = bmp->bmBitsPixel;
Bmi.bmiHeader.biCompression = BI_RGB;
Bmi.bmiHeader.biSizeImage = bmp->bmHeight*bmp->bmWidth*(bmp->bmBitsPixel/8);
// TRACE("\nBmi.bmiHeader.biSizeImage= %ld",Bmi.bmiHeader.biSizeImage);
// TRACE("\tBmi.bmiHeader.biHeight= %ld",bmp->bmHeight);
FILE* image = fopen (name,"wb");
if(image==0)
{
AfxMessageBox("Error in creating Image File");
return;
}
int h = abs(Bmi.bmiHeader.biHeight);
int w = abs(Bmi.bmiHeader.biWidth);
Bmi.bmiHeader.biHeight=h;
Bmi.bmiHeader.biWidth=w;
long sz = Bmi.bmiHeader.biSizeImage;
int ii,ch,ss;
// ss = sz/4;
ss = sz/4;
try
{
long s1=ss;
for( ii=0; ii< (ss/2)-1; ii++)
{
ch = data[s1];
data[s1--] = data[ii];
data[ii] = ch;
}
long i,j,pos;
s1 =0;
for(i=1; i<=h; i++)
{
s1 += w;
pos = s1-(w/2);
j=s1-1;
for( ii=s1-w ;ii<pos; ii++)
="" {
="" ch="data[ii];
" data[ii]="data[j];
" data[s1]="data[ii];
" data[j]="ch;
" j--;
=""
="" }
="" catch(...)
="" afxmessagebox("error="" in="" capture="" image");
="" return;
="" }
="" bitmapfileheader="" bfh;
="" bfh.bftype="('M'<<8)+('B');"
="" bfh.bfoffbits="sizeof(BITMAPFILEHEADER)+" sizeof(bitmapinfoheader);="" bfh.bfsize="sz+bfh.bfOffBits;" bfh.bfreserved1="0;" bfh.bfreserved2="0;" bmi.bmiheader.biheight="Bmi.bmiHeader.biHeight-21;
" fwrite(&bfh,sizeof(bfh),1,image);
="" fwrite(&bmi.bmiheader,sizeof(bitmapinfoheader),1,image);
="" fwrite(data,sz,1,image);
="" fclose(image);
=""
}=""
<div="" class="ForumSig">There Is Nothing Right & Wrong
|
|
|
|
|
I forgot but I think in VC 6.0 we have a class like CImage I remember that I used of that class in VC 6.0 and also I remember that it doesnt support on the VS2003.
|
|
|
|
|
I use CPictureEX in order to insert GIF.but the background of this GIF is white,though i intercalate GIF look like transparence (USE PhotoShop )
how can i do?
|
|
|
|
|
hello,
in my programm, i created a run-time control CEdit. It's appears, when user clicks on some place (row in a table). I can read, that user enters in that CEdit control, but.... i don't know - when does it lose a focus? How can i override functions in this control, like a 'OnEnChangeEdit1()' or 'OnEnKillFocusEdit1()', that provided to me by MFC, if i create static (compiling-time) control...
|
|
|
|
|
mr_Tuborg wrote: when does it lose a focus?
When it receives a EN_KILLFOCUS message.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Good solution, but it doesn't override an any MFC control function =)
|
|
|
|
|
Which scenario are you having trouble with - dynamically (runtime)
created controls or static (from resource) created controls?
Either way, to use the MFC message handlers, you derive a class
from CEdit and add your handlers, including entries in the message map.
Then you use objects of your derived class in place of CEdit objects in
the parent window class.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
i'm having trouble with runtime created controls.
Thanks for answer. It completly explains to me how to use an overriding in MFC controls.
|
|
|
|
|
Another option is to handle the EN_KILLFOCUS[^] message in the parent window.
Steve
|
|
|
|
|
Excellent
Thanks,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello,
I am wondering if there is a way to detect a right click on the header of each tab of a tab control?
Any help is appreciated.
Thanks..
|
|
|
|
|