|
From the Start Menu ?
Override WM_COMMAND
OnCommand()
{
check ur menu ID, if it from start menu,
CChildDlg oDlg;
oDlg.DoModal();
}
4 Frames???? Sounds like u really need a splitter wnd...
hey refer MSDN , there is no other better source for MFC/SDK..
Ninety-eight percent of the thrill comes from knowing that the thing you designed works, and works almost the way you expected it would. If that happens, part of you is in that machine.
|
|
|
|
|
hi,
I would like to know if there is a way by which an application can hook into other applications and access their gui controls (like buttons, textboxes....).
I have done some research on this. I found out that a dll (with SetWindowsHookEx) can be used to hook into the message queue of an application so as to receive all the notifications that are sent to the application. Another method is WH_CBT and CBTProc. But I'm still not clear as to how this can be used to access the internal controls of a windows application.
Thanking you.
|
|
|
|
|
One way would be to send the other application the appropriate message. To "click" a button, try:
SendMessage(hwnd_of_other_app, WM_COMMAND, MAKEWPARAM(button_id, BN_CLICKED), hwnd_of_button);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thank you for replying. SendMessage could help in simulating button clicks. But my problem is how will i know about the button_id ?
The basic assumption is that my application will not know anything about the internal structure of the target application (except for the fact that it is a windows exe). In that case how can i query the control ids ? Is there some generic way that will help to query the ids of the controls ?
Or should i resort to extracting info from the exe file itself ?
Any help will be appreciated.
|
|
|
|
|
Use FindWindowEx() and/or EnumChildWindows() to find the window/control in question. From there you can use GetDlgCtrlID() to get the identifier of the control.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
How to convert a PLBYTE to integer array?
Thx!
|
|
|
|
|
int* makeIntArrayFromByteArrary(LPBYTE *pByte,size_t cbByte)
{
int* pInt = (int*)malloc(cbByte * sizeof(int));
if( pInt ) {
int i;
for( i=0; i<cbByte; ++i )
pInt[i] = pByte[i];
}
return pInt;
}
int* makeIntArrayFromByteArrary(LPBYTE *pByte,size_t cbByte)
{
int* pInt = new int[cbByte];
if( pInt ) {
for( int i=0; i<cbByte; ++i )
pInt[i] = int(pByte[i]);
}
return pInt;
} Do not forget, you are responsible for freeing memory after you are finished using the allocated arrary of intergers.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Maybe it is really a newbie problem, but how to obtain the size of *pByte? just use sizeof operator?
|
|
|
|
|
samhwang wrote:
...how to obtain the size of *pByte? just use sizeof operator?
Pointers have a constant size of 4 bytes. Perhaps you are wanting to know how many bytes the pointer is pointing to.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Sorry, I've been away!
1) "PLBYTE" is not a defined type it should be "LPBYTE" or "BYTE*".
2) I made a mistake: "LPBYTE *pByte" should be "LPBYTE pByte" or "BYTE* pByte".
sizeof examples:
BYTE b;
int i;
BYTE ba[10];
int ia[10];
BYTE* pba = ba;
int* pia = ia;
//sizeof(b) = sizeof(BYTE) = 1
//sizeof(i) = sizeof(int) = 4 (on 32-bit compilers)
//sizeof(ba) = 10*sizeof(ba[0] = 10*sizeof(BYTE) = 10
//sizeof(ia) = 10*sizeof(ia[0] = 10*sizeof(int) = 10*4 (on 32-bit compilers)
//sizeof(pba) = sizeof(BYTE*) = 4 (on 32-bit compilers)
//sizeof(pia) = sizeof(BYTE*) = 4 (on 32-bit compilers)
Notes:
1) sizeof(int) is the size of a machine word.
2) A machine word is the maximum number of bytes that can fit into one machine register.
3) Reality: What the size of an int is depends on the compiler you are using;
16-bit -> sizeof(int) = 2,
32-bit -> sizeof(int) = 4,
64-bit -> sizeof(int) = 8.
Well, I hope that answers all your questions.
Good Luck!
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Can someone upload amstream.h somewhere? Visual Studio 2005 doesn't have it...
|
|
|
|
|
*sigh* What do you expect to do with a single header file ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Why does this program crush?, what have i left?
<br />
#include "stdio.h"<br />
<br />
<br />
int main(int argc, char* argv[])<br />
{ <br />
FILE* fp;<br />
char fname[10];<br />
<br />
printf("Enter the file name: ",fname);<br />
scanf ("%s",fname);<br />
<br />
if( fp )<br />
fopen("&fname","wt");<br />
{ <br />
int i;<br />
for( i=0; i<10; ++i ) <br />
fprintf(fp,"Line %d\n",i); <br />
<br />
fclose(fp); <br />
} <br />
return 0;<br />
}
oam
|
|
|
|
|
|
mpapeo wrote:
if( fp )
fopen("&fname","wt");
{
int i;
for( i=0; i<10; ++i )
fprintf(fp,"Line %d\n",i);
fclose(fp);
}
it's should be :
fopen(&fname,"wt");
if( fp )
{
int i;
for( i=0; i<10; ++i )
fprintf(fp,"Line %d\n",i);
fclose(fp);
}
|
|
|
|
|
Actually, fp = fopen (...); , but you probably meant that.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
right
|
|
|
|
|
Still it crushes
oam
because i have made the changes you suggested.
<br />
#include "stdio.h"<br />
<br />
<br />
int main(int argc, char* argv[])<br />
{ <br />
FILE* fp;<br />
char fname[30];<br />
<br />
printf("Enter the file name: ",fname);<br />
scanf ("%s",fname);<br />
<br />
<br />
fopen(&fname,"wt");<br />
if( fp )<br />
{ <br />
int i;<br />
for( i=0; i<10; ++i ) <br />
fprintf(fp,"Line %d\n",i); <br />
<br />
fclose(fp); <br />
} <br />
return 0;<br />
}<br />
|
|
|
|
|
you still have yet to assign fp as was stated above
|
|
|
|
|
Well it works now.
Thanks
oam
|
|
|
|
|
mpapeo wrote:
if( fp )
fopen("&fname","wt");
{
Should be:
fp = fopen(fname, "wt");
if (NULL != fp)
{
...
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
|
Is there a way to determine if a socket that is connected to my CSocket has been closed (without overriding onClose function in class derived from CSocket)?
My function:
CString Connection::read()
{
CString out;
DWORD numRead;
do
{
::Sleep(100);
socket->IOCtl(FIONREAD, &numRead);
} while(numRead == 0);
int count = socket->Receive((void*)out.GetBuffer(numRead), numRead);
out.ReleaseBuffer(numRead);
out.TrimRight();
cout << "Connection->reading: index: " << index << ", count: " << count << ", msg: " << (LPCTSTR)out << endl;
return out;
}
I'm using this function in multithread server application. Threads are waiting for new messages and processing them sometimes requires writing to other threads' sockets.
|
|
|
|
|
Hi,
Here is useful link(especialy the examples):
http://tangentsoft.net/wskfaq/[^]
Are you using P2P or broadcast or multycast connection?
I'm not using CSocket , I'm using SOCKET with all WinSock function,
and if recv() return 0 so the client closed the connection,so i guess it's the same with CSocket.
Good luck,
Eli
|
|
|
|
|
Thanks for Your response.
socket->Receive returns 0 if socket is closed, but the problem is, that I'm using socket->IOCtl to check if I can read data from socket (and not to block socket with socket->Receive, because other thread may be trying to send something to the same socket).
socket->IOCtl returns 0 when there is nothing to read (so when socket is closed it also returns 0), and code with socket->Receive won't be executed.
I'm looking for simple method to check if socket was closed by client.
Lets say I'm lazy and I don't want to rewrite my code
|
|
|
|