|
Hi,
I have created an ATL dll which has a modeless dialog box containing a WebBrowser control. My problem is that whenever I'm pressing TAB key over the WebBrowser control, the focus is not shifting to other controls or links within the web page which is getting displayed within the control.
I have implemented a hook to trap WH_GETMESSAGE message, after that I'm able to get response from the 4 arrow keys and TAB key, but that too within the dialog box.
I have to make the TAB key acting normal within the WebBrowser control that is within that dialog box.
Can anyone of you help me out? Thanks in advance.
Regards,
Ashish
|
|
|
|
|
i fail to envoke shutdown function.
i m trying to write the data recd in the socket buffer to a fiel.
though i manage it but it happens only i stop the application and not before.
i tried many alternatives but feel i m still short of something.
Seeing the given code can i be suggested why????
// THe following is a client thread
<br />
UINT ClientThread(LPVOID pParam) <br />
{<br />
char *buff;<br />
CString cmd;<br />
CString params;<br />
int n;<br />
int flag=0;<br />
BOOL auth=false;<br />
buff=(char *)malloc(1);<br />
SOCKET client=(SOCKET)pParam;<br />
recv(server,buff,sizeof(buff),0);<br />
while(true) <br />
{ftxt=fopen("d:\\amit\\COMMAND.txt","a+t");<br />
while(n=recv(client,buff,sizeof(char),0))<br />
{<br />
flag=1;<br />
<br />
<br />
fwrite(buff,sizeof(char),1,ftxt);<br />
<br />
if(n==SOCKET_ERROR ) <br />
break;<br />
buff[n]=0;<br />
cout<<buff;<br />
}<br />
shutdown(server,2); <br />
<br />
fclose(ftxt);<br />
<br />
}<br />
<br />
flag=0;<br />
closesocket(client);<br />
return 0;<br />
}<br />
amit mishra
|
|
|
|
|
I do not know about your actual problem, but you have other problems.
char *buff;
buff=(char *)malloc(1);
recv(server,buff,sizeof(buff),0);
recv(client,buff,sizeof(char),0);
buff[n]=0;
1) Allocating a 1 character buffer makes no since and you never free the memory allocated. Just declare a single character variable or a small buffer: char buff; or char buff[1];
2) These two statements are not the same thing:
recv(server,buff,sizeof(buff),0);
recv(client,buff,sizeof(char),0);
sizeof(buff) == sizeof(char*) NOT sizeof(char);
If you had declared the buff variable as buff[1] or buff then
sizeof(buff) would equal sizeof(char).
3) buff[n]=0;
if n is anything other than 0, then your thread may (should) crash.
buff[1] = 0; // ERROR
4) Unless you have a good reason, constantly opening and closing the file in the outer loop is probably a bad idea too!
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Taking char * buff has a strong reason behind as i m trying to recv a string eg. SYNTAX like <green>Operator play file abc.wav
yeah a typing err n i apologize fr recv(server,....) it was n shud be recv(client,....).
Constantly opening and closing file is reqd as the client may keep sending data.
eg. 1.
open channel ch_id,play file filename,record fiel fielrec , etc...
i want to envoke shutdown in the outer loop
n yes i ddnt free memory was my mistake..for once the data is written to the fiel the memory shud have been freed n file closed.
amit mishra
|
|
|
|
|
You still do not need to allocate a buffer, since all you need is a pointer to a single character.
Hmmm! I should have noted that recv(server,...) was a typo, since that was a typo, then shutdown(server...) is also a typo.
I looked up the functions used and here is what your code will do once the typos are fix:
FIRST TIME TRU LOOP:
1) Read 1 byte from the socket and then ignore it.
2) START INFINITE LOOP {
3) Open a file.
4) While( there is a byte received OR a SOCKET_ERROR ) {
5) copy byte to file. // before checking if error occured
6) if( error )
break;
}
7) Shut down socket so you can no longer send or receive and data.
(This means recv(...) will now always return SOCKET_ERROR)
8) Close file.
9) } // END OF INFINITE LOOP
AFTER FIRST LOOP:
1) START INFINITE LOOP {
2) Open file.
3) While( SOCKET_ERROR ) { // because of shutdown above
4) Write the last character received (during first loop).
5) Break out of loop (since it was a SOCKER_ERROR).
}
6) Try to shut down again (cann't because it was already done).
7) Close file.
8) } // END OF INFINITE LOOP
I do not think that was what you were trying to do, but that is what should be happening. There is also the fact that the INFINITE LOOP cann't be stoped properly (any other way if bad).
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Hi Everybody,
I need some help. I would like to program a small tool like the Win.Task Manager which is able to show all running Threads and also the Virtual Memory which is in use... There should be an funktion for getting al the nessecary Informations but i can't find it. Hope some of guys can help me with some Ideas or maybe someone has already that kinda tool. Would be very nice of you.
|
|
|
|
|
|
I am trying to find Sourcecode for getting data from ListView Control using Win32 api.please provide me a working source code ,i know the api's ,but i am unable to use them.
any help is greatly apreciated.
Thanks
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
To work with the list view control in win32 you just SendMessage any of the LVM_* list view messages to the control. The info will either be the return value, or contained in the structures you pass in as the message parameter.
For example to get the number of items in the control:
int NumItems = SendMessage(HWNDListView, LVM_GETITEMCOUNT, 0, 0);
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
Thanks,
actually My Problem was solved yesterday only.i am trying to get List View data from a different Application through my program.May be that program hooked WM_GETTEXT ,that why every time it returning NULL.
Using DLL injection,i SOrted Out My Problem.Thanks For aBove.
PJ Arends wrote:
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Trust Me!! you are Definitely a Real SuperStar of CP
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Hi,
I am having a problem with updateResource API with strings.
I want to delete all the strings in a string Table and rewrite them in another language.
This creates 2 sting tables
1. the new destination string table with the new strings.
2. the older string table (All the strings are however deleted here)
on selecting the older sting table in the resource editor(VC.NET), the editor throws an error and shut down throws
I want to get rid of the older String table
PS NOTE: the application works properly in some computers but in some computers, the above mentioned problem occurs...
Could i know the reason for the same, and the process of getting rid of this problem..
thanks in advance..
Vinod
|
|
|
|
|
Hi,
I need to generate a lot of Excel files. I don't want to use Excel Automation (Excel version dependant, perf, etc. ). So, I'm looking for a good C++ library to create spreadsheets dynamically...
No C#, No .net. ActiveX would be ok. (actually, I'm using STL/ATL)
Nota:
CSV files do not match my requirements cause I have to customize cells, borders, colors and so on...
Can you help me ?
|
|
|
|
|
You distant past may still haunt you...
magicbassfr wrote: I need to generate a lot of Excel files. I don't want to use Excel Automation (Excel version dependant, perf, etc. ). So, I'm looking for a good C++ library to create spreadsheets dynamically...
I know you posted this quite some tome ago... therefore I am hoping you have found a solution as I have the same requirement... what did you end up using?
Thanks for any help...
|
|
|
|
|
i want the Imgocxd.hlp file im working on image scanning and saving it to hard disk if any one have it then pls giv me
Shahbaz kiani
|
|
|
|
|
Hi Everyboday,
While installing global message hook (WH_GETMESSAGE) on WinXP limited
user account i am getting "Access Denied" error.
The same code is working fine on Win2k machines (in any user mode)
I have written a dll in which all my global hook stuff resides, which
has some export function to install/uninstall the global hook.
Can any body please guide me what i am doing wrong here ?
Thank you,
Vishal
VM
|
|
|
|
|
Yup problem solved
Vishal
|
|
|
|
|
every body....
my code is following.
my problem is only photo2 is show.
i want to show both photo1 and photo2.plz help me...
//MyView.h
CStatic m_photo1;
CStatic m_photo2;
HBITMAP m_hBmpOld;
HBITMAP m_hBmpNew;
BITMAP m_bmInfo;
//MyView.cpp
void CMyView::OnOK()
{
Load_Photo_1("image/1.bmp");
Load_Photo_2("image/2.bmp");
}
void CMyView::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CPaintDC dc(this);
dc.BitBlt(offsetx,offsety,m_size.cx,m_size.cy,
&m_dcMem, sourcex, sourcey,SRCCOPY);
CFormView::OnPaint();
}
}
void CMyView::OnInitialUpdate()
{
CClientDC dc(this);
m_dcMem.CreateCompatibleDC( &dc );
}
void CMyView::Load_Photo_1(CString p_filepath)
{
m_hBmpNew = (HBITMAP) LoadImage(
AfxGetInstanceHandle(),
p_filepath,
IMAGE_BITMAP,
0,
0,
LR_LOADFROMFILE);
if( m_hBmpNew == NULL )
{
AfxMessageBox("Load Image Failed");
}
else
{
m_photo1.GetClientRect( &rectStaticClient );
rectStaticClient.NormalizeRect();
m_size.cx=rectStaticClient.Size().cx;
m_size.cy=rectStaticClient.Size().cy;
m_size.cx = rectStaticClient.Width(); // zero based
m_size.cy = rectStaticClient.Height(); // zero based
m_photo1.ClientToScreen( &rectStaticClient );
ScreenToClient( &rectStaticClient);
m_pt.x = rectStaticClient.left;
m_pt.y = rectStaticClient.top;
GetObject( m_hBmpNew , sizeof(BITMAP), &m_bmInfo );
VERIFY(m_hBmpOld = (HBITMAP)SelectObject(m_dcMem, m_hBmpNew));
offsetx= m_pt.x;
offsety=m_pt.y;
InvalidateRect(&rectStaticClient);
}
}
void CMyView::Load_Photo_2(CString p_filepath)
{
m_hBmpNew = (HBITMAP) LoadImage(
AfxGetInstanceHandle(),
p_filepath,
IMAGE_BITMAP,
0,
0,
LR_LOADFROMFILE);
if( m_hBmpNew == NULL )
{
AfxMessageBox("Load Image Failed");
}
else
{
m_photo2.GetClientRect( &rectStaticClient );
rectStaticClient.NormalizeRect();
m_size.cx=rectStaticClient.Size().cx;
m_size.cy=rectStaticClient.Size().cy;
m_size.cx = rectStaticClient.Width(); // zero based
m_size.cy = rectStaticClient.Height(); // zero based
m_photo2.ClientToScreen( &rectStaticClient );
ScreenToClient( &rectStaticClient);
m_pt.x = rectStaticClient.left;
m_pt.y = rectStaticClient.top;
GetObject( m_hBmpNew , sizeof(BITMAP), &m_bmInfo );
VERIFY(m_hBmpOld = (HBITMAP)SelectObject(m_dcMem, m_hBmpNew));
offsetx= m_pt.x;
offsety=m_pt.y;
InvalidateRect(&rectStaticClient);
}
}
|
|
|
|
|
definitely.....only the photo2 will get loaded.....
u have defined only one dcmemory variable.....
and u have assigned both the photoz to that same dcmemory variable.....
since the first gets assigned to the "m_dcMem".....what happens is u assign even the second photo to the same variable "m_dcMem" so the first getz overwritten.....
use two seperate variables :m_dcMem1 and m_dcMem2
that should sove the prob.....
happy programmin.....
cheerz.....
|
|
|
|
|
and oh.....i forgot,therz one more thing.....
in ur paint function.....make sure u give two BitBlts.....
that iz....
dc.BitBlt(offsetx1,offsety1,m_size1.cx,m_size1.cy,&m_dcMem1, sourcex1, sourcey1,SRCCOPY);
dc.BitBlt(offsetx2,offsety2,m_size2.cx,m_size2.cy,&m_dcMem2, sourcex2, sourcey2,SRCCOPY);
i hope u got that as well.....
happy programmin.....
cheerz.....
|
|
|
|
|
i understand ...
thank you...
|
|
|
|
|
I have a socket server application that uses async sockets and a completeion port.
We have installed it at a new client site in Sydney and they have some users in London, Sydney and New York. The London users only are reporting that the client application gets disconnected from time to time. This is not reproducible using the UAT environment at the client site.
Sometimes when we call ::send() in the server SOCKET_ERROR is returned and WSAGetLastError() returns WSAEWOULDBLOCK. I believe this is because windows is still performing the last send operation on this socket.
In this case we call ::select() with the socket in the writefds param and a timeout. This code has always worked successfully in the past. What I find now is that for these London users ::select()is returning a value other than 1. Unfortunately the exact value returned is not logged by the sever. I have had the customer increase the timeout value that is passed to the ::select() call but it is still failing. Anyone got any bright ideas?
|
|
|
|
|
FWIW different socket implementations support different subsets of the select options. You might want to check if the winsock on the problem machine is the same as the others. Just a thought.
|
|
|
|
|
If i use WriteFile to write over a file with null bytes, will it actually write over the existing bytes on the drive or will it just write them to a new location on the drive.
|
|
|
|
|
It will write over the bytes
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
|