|
Why don't you use the MFC class CStdioFile it can read a file line by line.
Help your local Search & Rescue. Get lost!
|
|
|
|
|
Thanx for the reply Monty, but I'm not using MFC...
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Then you can parse the string and break at every '\r\n' , alternatively you can use strtok
You can't see me
|
|
|
|
|
Thank you Monty, I'll check out MSDN...
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
« Programm3r » wrote: The only programmers that are better than C programmers are those who code in 1's and 0's.....
You forgot the assembly guys
OK, so what's the speed of dark?
|
|
|
|
|
LOL ... My bad....
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Monty2 wrote: You forgot the assembly guys
...and the C# and HTML guys, from what they tell me.
|
|
|
|
|
|
|
Hi, I want to add ItemData as a string in my list box using win32 APIs. But when I try to get it back from list box I am getting blank string. Can I know what is wrong with my code?
Thanks in advance.
char setStr[20] = "test";<br />
char* getStr;<br />
<br />
::SendMessage(hLbox,LB_SETITEMDATA,listIndex,(LPARAM)setStr);<br />
testStr = (char*):: SendMessage (hLbox, LB_GETITEMDATA, listIndex, NULL);
|
|
|
|
|
priyank_ldce wrote: char setStr[20] = "test";
You are passing address of a local variable.
Create it on heap instead.
|
|
|
|
|
If you always pass constant strings like in your example, then try a different definition of setStr :
const char * setStr = "test";
::SendMessage(hLbox, LB_SETITEMDATA, listIndex, (LPARAM)setStr);
I hope this helps.
|
|
|
|
|
Hi, Thanks for the help. Actually I get that string in the form of char[]. Can I know how can I cast it to const char*. I tried strcpy() but it is not working.
|
|
|
|
|
In case of variable string values, I think you can try the following (old-fashioned) solution:
char setStr[20] = ...;
::SendMessage( hLbox, LB_SETITEMDATA, listIndex, (LPARAM)_strdup(setStr));
const char * str = (const char*)::SendMessage( hLbox, LB_GETITEMDATA, listIndex, NULL);
Note that these strings are allocated on the "heap" and therefore must be freed when the list control is destroyed, or new data are set. This can be done in OnDestroy handler of your dialog. You have to loop through list-box’s items and execute:
free((const char*)::SendMessage( hLbox, LB_GETITEMDATA, listIndex, NULL));
Modern solutions use functions other than strdup and free . I am not sure which is simpler.
I hope this helps.
|
|
|
|
|
from process code below
int i;
m_progress.SetRange(0,999);
m_progress.SetStep(1);
m_progress.SetPos(0);
for (i=0;i<1000;i++)
{
m_progress.StepIt();
}
During I process in "for loop".
I also want the dialog response my action such as minimize,move dialog etc.
How I write the code if I don't use thread function.
|
|
|
|
|
you MUST move this code into a worker thread if you want the GUI to respond...
|
|
|
|
|
Max++ wrote: During I process in "for loop".
I also want the dialog response my action such as minimize,move dialog etc.
How I write the code if I don't use thread function.
Hope this[^] article helps.
|
|
|
|
|
where you use this code ?
|
|
|
|
|
I would like to know how to detect the socket was blocked?
Also how to detect the network is disabled?
Please help!
|
|
|
|
|
LaHaHa wrote: I would like to know how to detect the socket was blocked?
When a socket is created it is in blocking mode until you change it. WSAAsyncSelct() and
WSAEventSelect() are two APIs that will change the socket to non-blocking mode. You can also
set the blocking mode with something like
// Set socket to non-blocking mode
DWORD dwNonBlockingMode = 1;
::ioctlsocket(hSocket, FIONBIO, &dwNonBlockingMode);
|
|
|
|
|
Thank you for your answering!
The blocking may be caused by the firewall, network cable disconnected or etc... So how to detect it? Please help!
|
|
|
|
|
LaHaHa wrote: The blocking may be caused by the firewall, network cable disconnected or etc...
Check error codes on ALL socket operations.
For example:
If recv() returns 0 the connection has been gracefully closed.
If recv() returns SOCKET_ERROR then call WSAGetLastError() to get an error code:
WSAENETDOWN
WSAENETRESET
WSAECONNABORTED
WSAETIMEDOUT
WSAECONNRESET
etc.
Same with connect()...
connect() will return 0 on success.
If connect() returns SOCKET_ERROR then call WSAGetLastError() to get an error code...
The error returned may vary by protocol and by service provider.
Try it out in the debugger. Put a breakpoint after a connect(), send(), and/or recv() call
and see what error code you get if you unplug the network cable. See what error code you
get when you try to connect() to an address behind a firewall.
The point is the error codes aren't that specific
|
|
|
|
|
Thanks a lot! I will try it!
|
|
|
|
|
when i am include <atlbase.h> in my code it is showing errors in the atlbase.h file. like
d:\program files\microsoft visual studio\vc98\atl\include\atlbase.h(5770) : error C2039: 'RegisterClassImplCategories' : is not a member of '_NoAddRefReleaseOnCComPtr<struct ICatRegister>'
i am getting 5 errors as such. How to solve this?
Thank you.
KIRAN PINJARLA
|
|
|
|
|
kiran.pinjarla wrote: when i am include in my code it is showing errors
what code ? can you show some code ?
I'm sure you are messing with CComPtr
|
|
|
|