|
What's the point in using gettimeofday() under linux, which is a linux specific function, if you don't want to use the equivalent under Windows? The equivalent is the GetSystemTime() function, but since it is Windows specific, you probably don't want it. The only other way would be to use the standard C library time() function, but then why don't you just use that under linux as well?
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"
|
|
|
|
|
I am working in network programming. Its a multiclient server chat program. Each client works in saparate thread. I create thread when some client request the server to connect. I used _beginthread to create thread.
When i build the file, i get following error.
unresolved external symbol __beginthread
I have included ws2_32.lib but still it does not work.
Can you please help me?
Thanks
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
Aqueel wrote: I am working in network programming. Its a multiclient server chat program. Each client works in saparate thread. I create thread when some client request the server to connect. I used _beginthread to create thread.
When i build the file, i get following error.
unresolved external symbol __beginthread
I have included ws2_32.lib but still it does not work.
Can you please help me?
Thanks
You have to link to MSVCRT.lib or LIBCMT.lib library.
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
#if !defined(_MT)
#error _beginthread requires a multithreaded C run-time library.
#endif
Need to include the lines above in your file where you have used _beginthread and #include<process.h>
That should do the trick....
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Aqueel wrote: used _beginthread to create thread.
When i build the file, i get following error.
unresolved external symbol __beginthread
Its better if you use CreateThread Instead!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Help CRY
|
|
|
|
|
How i can clear the List box ?
How i can count the lines of a list box ?
List box
test.txt
tess.txt
test.mp3
test.doc
test.dll
now How i can say " in 3rd line is test.mp3"
|
|
|
|
|
Immunity18 wrote: How i can count the lines of a list box ?
GetCount();
Immunity18 wrote: How i can clear the List box ?
ResetContents();
Immunity18 wrote:
test.txt
tess.txt
test.mp3
test.doc
test.dll
now How i can say " in 3rd line is test.mp3"
From MSDN:
CString str, str2;
int n;
for (int i=0;i < pmyListBox-><code>GetCount()</code>;i++)
{
n = pmyListBox->GetTextLen( i );
pmyListBox-><code>GetText</code>( i, str.GetBuffer(n) );
str.ReleaseBuffer();
str2.Format(_T("item %d: %s\r\n"), i, str.GetBuffer(0));
MessageBox(str2);
}
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
thx you for the replies \o/
Hm the thing i want to do is.
When i'll doubleclick on an item then save me in a variable the number of the line
test.txt
tess.txt
test.mp3
test.doc
test.dll
if someone double click on test.mp3 it gonna say "you select 3 line"
|
|
|
|
|
Immunity18 wrote: When i'll doubleclick on an item then save me in a variable the number of the line
Inside the message handler for double click...
int nIndex = pmyListBox->GetCurSel(); nIndex now contains the index of the currently selected item.
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
I got an MFC application where i have a Playlist.
the MFC application plays the mp3 via Winamp.
When i add a mp3 on the Playlist ,at the same time it is added on the Winamp Playlist.
There is a command on Winamp (takes int 1,2,....) which is the position on playlist
So when I doubleclick on an item on 5rd line it gonna give the int value 5 at a variable.
The same variable will be in the command on Winamp for position on Playlist
|
|
|
|
|
Immunity18 wrote: So when I doubleclick on an item on 5rd line it gonna give the int value 5 at a variable.
The same variable will be in the command on Winamp for position on Playlist
That's great.
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
Yeah \o/ its great for a newbie like me (now i start learn C++)
I thought about adding a int counter++
m_ListCtrl("%d "+Filename ,counter);
so it would be
1 filename.txt
2 filename.mp3
3 dsffsfds...
And after with GetAt();, for the first character of each item , i could "read" the number of line
Just i wanted to ask if there was a way to avoid that .
|
|
|
|
|
1)Match the contents of the list box by iterating through the items. If you get what you want format the string . Add the name you want to and display the formatted string.
2)Use the listbox.GetCount() Method to get the number of items in the list box
3)For Clearing the list box use listbox.ResetContents()
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Immunity18 wrote: How i can clear the List box ?
Use CListBox::ResetContent Immunity18 wrote: How i can count the lines of a list box ?
Use
CListBox::GetCount<br />
<br /> Immunity18 wrote: test.txt
tess.txt
test.mp3
test.doc
test.dll
now How i can say " in 3rd line is test.mp3"
<br />
CString strList; <br />
for(int iCount=0;iCount<mylist.GetCount();iCount++)<br />
{<br />
<br />
myList.GetText(iCount,strList);<span style="font-weight: bold;"><br />
if(strList.CompareNoCase("</span>test.mp3<span style="font-weight: bold;">")==0)<br />
{<br />
strList(" The test.mp3 is at %d",iCount);<br />
MessageBox(strList);<br />
} <br />
</span> <br />
<br />
<br />
}
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Help CRY
|
|
|
|
|
Hi,
It takes 1 minute and 850 ms for my FTP client(only upload) app(VC6) to
upload 300 local files(size: 10kb) to a FTP server in our LAN.The FTP server
is a Micosoft FTP Server of IIS.
Now we need to improve the app performance to reduce the 1 minute and 850 ms
to 1 minute or less. My app uses WININET api and WININET.DLL.
I tried to call InternetSetOption() with INTERNET_OPTION_WRITE_BUFFER_SIZE
flag to set the write buffer size to 8092.
I want to know what the default write buffer size is and whether the app
performance is better while the size is more.
Thank you in advance.
Dave
|
|
|
|
|
Hi Ive posted a thread titled: (problem with reading serial port) if that could help you..Im doing a two threads program the main one is in charge of user interface and write toport operations and the second oen is in charge with reading the serial port...
this is the reading thread code
void __fastcall read_thrd::Execute()<br />
{ FreeOnTerminate = true;<br />
<br />
OVERLAPPED osRead = {0};<br />
DWORD dwCommEvent;<br />
DWORD iBytesRead;<br />
DWORD BytesToRead = 128;<br />
<br />
osRead.hEvent= CreateEvent(NULL,TRUE,NULL,NULL);<br />
if (!SetCommMask(Form1->m_hCom, EV_RXCHAR))<br />
{<br />
wsprintfA(Form1->sBuffer, "LastError = %d", GetLastError());<br />
MessageBoxA(0, Form1->sBuffer, "SetCommMask() Failed", MB_OK);<br />
<br />
}<br />
<br />
while(!Terminated)<br />
{ dwCommEvent = NULL;<br />
if (!WaitCommEvent(Form1->m_hCom, &dwCommEvent, 0))<br />
{<br />
wsprintfA(Form1->sBuffer, "LastError = %d", GetLastError());<br />
MessageBoxA(0, Form1->sBuffer, "WaitCommEvent() Failed", MB_OK);<br />
break; <br />
}<br />
<br />
if (dwCommEvent & EV_RXCHAR)<br />
{ ReadFile(Form1->m_hCom, &Form1->sBuffer, BytesToRead, &iBytesRead, &osRead);<br />
<br />
FlushFileBuffers(Form1->m_hCom);<br />
<br />
} <br />
}<br />
void __endthread(void);<br />
}
now lets say that in order to do an operation i need so send a series of commands to serial port and receive answer to each one of them..
how can i synchronize the writing and reading between threads to it doesnt start writing new command untill it gets the answer from the device??
and what do you think about the code above??
|
|
|
|
|
Nawar_nrr wrote: how can i synchronize the writing and reading between threads to it doesnt start writing new command untill it gets the answer from the device??
Its Better you use CriticalSection when syncronizing within the Thread. you can do lioke this way
PSEUDO CODE
enum TRISTATE { eNoState,eON,eOFF}
Global TRISTATE g_bIsReadDataFromPort=eNoState;
Thread Writing
While(!Command)
{
EnterCritcalSection
if((g_bIsReadDataFromPort==eOFF)||
(g_bIsReadDataFromPort==eNoState))
{
g_bIsReadDataFromPort=eON;
WriteDataToPort
}
LeaveCriticalSection
}
g_bIsReadDataFromPort=eNoState;
Thread Reading
While(!Command)
{
EnterCritcalSection
if(g_bIsReadDataFromPort==eON)
{
g_bIsReadDataFromPort=eOFF;
ReadDataFromPort
}
LeaveCriticalSection
}
g_bIsReadDataFromPort=eNoState;
CriticalSection and Boolean variable will work in tandum, syncronize your data transfer
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Help CRY
|
|
|
|
|
I dont know much about CriticalSection ..I will try to learn more about it..but as I pointed, Im not synchronizing within the thread ..the write operation and read operation are in different threads..I was thinking of using WaitForMultipleObjects or something like that..but from searching I saw few codes using OVERLAPPED osWrite ,osRead and osStatus(or osEvent) and Im confused about where to and how to use them??
|
|
|
|
|
Nawar_nrr wrote: I dont know much about CriticalSection ..I will try to learn more about it..but as I pointed,
http://www.codeproject.com/threads/sync.asp[^]
http://www.codeproject.com/threads/xylock.asp[^]
Nawar_nrr wrote: Im not synchronizing within the thread ..the write operation and read operation are in different threads
have a look pseudo code i provided to you! that is for syncronize Read and Write operation only!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Help CRY
|
|
|
|
|
char *p=new char[16];
delete p+8;
or any other way
|
|
|
|
|
followait wrote: char *p=new char[16];
delete p+8;
or any other way
Well this is trouble! Standard STL template classes should help you.
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
followait wrote: char *p=new char[16];
delete p+8;
or any other way
What exactly you want to achieve?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Help CRY
|
|
|
|
|
We would like to create an application that will display messages in different areas in defined areas of the monitors including large LCDs and keep the dialog size full size for each monitor. From the size of monitor, 17,27,30,42 and so on, change the font size and display areas to meet that size without much changing the overall look of the application output. Is is best to design multiple dialogs within the application to meet the sizes and have the user pick those or can we have one dialog and have the aspect and such change based on size? Any tools would be appreciated if you know of any.
Thank you
|
|
|
|
|
Designing multiple dialogs,is a bad idea. U can change the size of the dialog and the controls inside them dynamically. For example if u want ur dialog to be displayed in the size of the Desktop..Write the code in the OnInitDialog() as follows.
CRect WindowRect;
GetDesktopWindow()->GetWindowRect( &WindowRect );
MoveWindow( &WindowRect );
nave
|
|
|
|
|
Designing of multiple dialogs for different monitor size is not a good design. U can use GetSystemMetrics() function to get the screen size.
Eg :
int nWidth = GetSystemMetrics( SM_CXFULLSCREEN ) ;
int nHeight = GetSystemMetrics( SM_CYFULLSCREEN ) ;
MoveWindow(0,0,nWidth,nHeight);
|
|
|
|