|
|
Have you tried to combine the loops with something like this:
int iMaxValue = array[0];
int iCount = 1;
for (int iLup = 0; iLup < 6; iLup++)
{
if (array[iLup] > iMaxValue)
{
iMaxValue = array[iLup];
iCount = 1;
}
else if (array[iLup] == iMaxValue)
{
iCount++;
}
}
onwards and upwards...
|
|
|
|
|
I'm using MSVC6 with SP4 (Yes I know 5 is out, but 4 is the corporate standard)
on XP Prof. with SP1 (again... corporate standard)
Anyway....
Whenever I try to open or manage macros, developer studio crashes. I tried to step into the debugger and it's coming up with an empty CString somewhere.
Has anyone seen and hopefully fixed such a problem?
Thanks
|
|
|
|
|
I just want to know how to use these functions in a dll . I want to create a dll through which i can find the subkeys ,by providing the key , but how to pass an string array pointer that can be used by other application is the problem .thx
Rahul Agarwal
|
|
|
|
|
I'm not sure what RegEnumKeyValue() is but here is an example using RegEnumKeyEx() .
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
|
hi, i want to know how to copy the contents of an array of strings into a listbox which can be displaied on screen?
Any help would be nice.
Thanks
|
|
|
|
|
MFC user ?
have a look at CListBox::AddString()
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
yeah im a MFC user (only been using c++ for about 2 weeks) Thanks for the help that should do what i want it to do
|
|
|
|
|
let consider you array if of type char*
char <code>str</code>[][]={"code","project","is","great"};
<font color=#008000>
CListBox *<code>m_lst</code>=(CListBox*)GetDlgItem(<code>IDC_LIST1</code>);
<font color=#008000>
if(m_lst)
{
<font color=#008000>
for(int i=0;i<4;i++)
{
<font color=#008000>
m_lst-><code>AddString</code>(str[i]);
}
}
"I Think this Will Help"
[Vote One Here,.....]
<h5
alok="" gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
Hi I have a raw image buffer (unsigned char *). I have all the information like width, height, pixel depth, etc. How do I display this buffer in window?
Thanks,
Ajay
|
|
|
|
|
how are the pixels formatted in that 'raw' buffer ?
Windows really only has built-in support for drawing DIBs (and DIB-like data), so you're probably going to have to massage your pixel data to get it into a form Windows likes - then you can use SetDIBits, StretchDIBits, etc.
Image Toolkits | Image Processing | Cleek
|
|
|
|
|
How do I program the following ?
//............................................................
String *names[] =new String*[50];
int x=0;
for (x=0; x<=10; x++)
{
textBox[x]->Text = names[x]; // <-- How can I do this ?
}
//............................................................
Thanks alot
Steve
|
|
|
|
|
This is just a guess, but what does this do:
textBox[x]->Text = *names[x];
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I have gone through all the CSockets articles here but cud not find what i want. Okay let me tell u what i have done till now. First i created CMySocket(inherited from CSocket) object and call the Listen. Now i want to be notified that the socket is ready to accept connection. I am also catching the message in OnAccept Function. But unfortunately it never enters into it. So now client can then communicate.Please help me on it ????
|
|
|
|
|
You need to use CAsyncSocket instead of CSocket for that.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
I have tried that as well but could not obtain what i want. I am getting an run-time error which says "No connection could be made because the target machine actively refused it." which is error 10061L. This means client is not finding to connect to server. I have not call accept at this stage. However, When i call accept my program stuck and i know why because accept is blocking call. I dont want to call in a thread as CSocket provides a high-level Socket Programming. SO i want to learn it you can say. But i am facing problems in it. Can please some one1 help in it ?
Please tell me a solution where i am able to find that server is ready to accept connection in OnAccept.
|
|
|
|
|
Nemanja, doesn't CSocket derive from CAsynSocket ? Methinks the problem may be that the client simply isn't connecting to the open socket.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Yeah the same problem persist. Please help me and kindly provide me with a solution
Regards,
Ibraheem
|
|
|
|
|
It's hard to do this without seeing your source code. Perhaps you could post the (brief) code fragments that show (a) how your server starts listening and (b) how your client attempts to connect?
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Thankx alot for the cooperation but i did manage to solve my problem. Now i m thinking for better design but hopefully i will manage it INSHALLAH. anywasy once agai thanx for the help
|
|
|
|
|
Glad you're up and running!
Coincidentally, I'm building a client server app (a free bug database) at this very minute. Check out this[^] preview screenshot.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hi friend,
I really faced a similar problem while i was trying to learn socket programming, and after a hard work with CAsyncSocket and lots of headache, i decided not to use it, i felt there is something wrong.
I can instead explain a simple portable method to connect a client socket to a server, you can read it, and its likely to be easier and more powerful than using MFC socket classes, here is my explanation which is some notes I took for myself when I was reading about winsock API:
-----------------------------------
* the sockaddr_in structure:
struct sockaddr_in{
short sin_family;
unsigned short sin_port;
struct in_addr sin_addr;
char sin_zero[8];
};
this structure is used to define:
1- Information about server (Computer IP, Port, address family) so client can connect to it
2- Information about types of clients the server can accept.
sin_family: Address family, should be AF_INET
sin_port: port number
sin_addr: IP Address
-------------------------------------------------------------------------------------------------------
Creating Basic Client/Server applications:
IMPORTANT NOTE: a valid SOCKET can receive and send data. a SOCKET is not necesserly specialized for sending only or for receiving only.
Basics for creating a Server application:
The server aaplication should be able to:
1- Detect an incoming connection from a client application
2- Accept this connection
3- Receive data from client.
Steps:
1- Define two SOCKETs for the server, one for listening for incoming connections, another one to handle a real connection.
SOCKET sListen,sConn;
2- Define and initialize a sockaddr_in object to hold information about the types of connections that can be accepted.
sockaddr_in saAddresses;
saAddresses.sin_addr.s_addr=htonl(INADDR_ANY); //any IP address can be accepted by the server
saAddresses.sin_family=AF_INET; //Internet (or network) address family
saAddresses.sin_port=htons(5000); //port number is 5000 (converted from host to network short)
3- Create the listening socket so we can detect incoming connections:
sListen=socket(AF_INET,SOCK_STREAM,0); //a stream of data is expected
4- Associate Information about (what can be accepted) to the Listen socket
bind(sListen,(sockaddr*)&saAddresses,sizeof(saAddresses));
5-Start listening:
listen(sListen,5); //5=max number of queued connections (pending)
6- Start a Thread loop to check for incoming connections
UINT thread(LPVOID lpvoid)
{
while(1)
{
char buff[100]; //100 bytes buffer to receive data from the client
CServ3Dlg *dlg=(CServ3Dlg*)AfxGetApp()->GetMainWnd(); //get dialog window pointer
int addlen=sizeof(dlg->m_saServ);
dlg->m_sMsg=accept(dlg->m_sListen,(sockaddr*)&(dlg->m_saServ),&(addlen)); //accept an incoming connection
if(dlg->m_sMsg!=INVALID_SOCKET) //if a connection was accepted handle it in a loop to receive data
{
AfxMessageBox("co");
while(1)
{
int s=recv(dlg->m_sMsg,buff,100,0); //receive data from client and put data in buff
if(s!=SOCKET_ERROR)
{
AfxMessageBox(buff); //acknowledge recption of data to user
}
}
}
}
return 0;
}
Basics for creating a Client application:
The Client Should be able to:
1- Request a connection from a server
2- Send data to the server
Steps for creating a client application:
1- Create a sockaddr_in structure to define the address of the server:
m_saServerAddress.sin_family=AF_INET; //Internet Address family
m_saServerAddress.sin_port=htons(5000); //port number
m_saServerAddress.sin_addr.s_addr=inet_addr("127.0.0.1"); //address of destination computer
2- Create a socket for the connection:
m_sClient=socket(AF_INET,SOCK_STREAM,0);
3- Connect to server application
connect(m_sClient,(sockaddr*)&m_saServerAddress,sizeof(m_saServerAddress));
4- Send Data to server application:
send(m_sClient,buf,100,0);
Closing a connection between client and server applications:
The client closes the connection by writing:
closesocket(ServerSocket); //close my connection with server
//ServerSocket is the socket defined in client and associated with the server.
----------------------------------------------------
I also recommend you to read the book :Network programming using micrososft windows, advanced, good, and new book explaining winsock2 for windows 98, 2000,NT. if you wish i can send you an electronic copy for FREE.
I hope this helped
Note: if you find this helpful, i can also send you the rest of notes i took about winsock. but they r far from your question
Regards,
Mohammad
|
|
|
|
|
Thank You so much but i have done this 1.5 year ago. So i this wanted to try different thing and i have noticed with CSocket or CAysncSocket things are very easy. You dont have to worry abt the blocking calls. Only have to simple override functions and ur job is almost done. Yeah u need lill better design while deriving from CSocket. I finally managed to solve the problem. Thanks anyway
|
|
|
|
|
Hi,
I'd like to know the real differences between the high level file functions (fopen, fread, fwrite) and the low level ones(_open, _read, _write).
I'm using MSDEV 6.0, manipulating binaries files. But the high level functions are not working well. I've just changed to low level, and it seems to work. I don't understand where is the problem, could it be anything in my input data that high level can't deal with?
Thanks,
Patricia
|
|
|
|