|
Hello Kuphryn,
Sorry could not understand.. this is my first socket programming trying Have you got any suggestion for me?
thank you..
Burge
|
|
|
|
|
Check out MSDN.
I highly recommend Network Programming for Microsoft Windows, Second Edition by Anthony Jones and Jim Ohmund.
Kuphryn
|
|
|
|
|
The return from WaitForMultipleObjects() specifies the event that caused the function to return.
If it was one of the handles being signalled you can find out which one by:
DWORD dwIndex = (state - WAIT_OBJECT_0);
However if more than one object is signalled then it will be the lowest index that is returned.
See MSDN[^]
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Hello Antony,
If data is available at the socket part then handles[0] will return nonzero or if dta available at com1 handles[1] will return nonzero if both of them have data then handles[0] will.. did I understand correct the use of this function?
But again still I don´t know how to relate handles[0] with my process (converter function which changes the header of the datagram). I checked msdn but it was not enough clear for me to understand!
thank you for the answer..
Burge
|
|
|
|
|
If you look at CreateEvent() , SetEvent() this will help you out.
Basically you need to:
1) Create an event for handle[0] and handle[1]
2) set the appropriate event either handle[0] or handle[1] depending on what data you recieve.
The WaitForMultipleObjects() will then return with the signalled handle.
Any clearer?
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Sorry!! Still I can not understand..
for (i = 0; i < 2; i++)
{
hEvents[i] = CreateEvent( NULL, FALSE, FALSE, NULL);
if (hEvents[i] == NULL)
{
printf("CreateEvent error: %d\n", GetLastError() );
ExitProcess(0);
}
}
state = WaitForMultipleObjects( 2, hEvents, FALSE, INFINITE);
??? i think here i should inform which handler is belonging to which event
switch (state)
{
// hEvent[0] was signaled.
case WAIT_OBJECT_0 + 0:
break;
...
..
.
I do not know how to hEvent[0]=>relate to select event
Can you tell me where can I find a sample which explain how to do this?
Thank you Antony!
Burge
|
|
|
|
|
Do you have a seperate thread(s) that is reading the data from serial port or socket?
I am unclear on how you get the data. It is there that you do the signalling. i.e. you signal the appropriate event when data arrives.
Generally when waiting for events to occur you are waiting for another thread / process to signal that it has something you are waiting for. When a thread enters WaitForMultipleObjects it stops execution of that thread while it waits. Subsequent code in that thread only executes when WaitForMultipleObjects returns.
Does this help?
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
[edit] solved
Hi,
I have a List View Ctrl on a WTL dialog, with EDITLABELS style. However, as soon as I start editing the label, and press any key, applicaiton closes.
I had this behavior before, but I don't know what did fix it
we are here to help each other get through this thing, whatever it is Vonnegut jr.
sighist || Agile Programming | doxygen
|
|
|
|
|
Hi!
I have been having problems using this function, iI just can't seem to get it work. I have a CBitmap object, and I have to pass it to the function as a "Pointer to the file in memory from which to create the texture."
Can anybody help me, or even better, post some working code? I have tried many ways but none of them work
Thanks
Eugi Games
|
|
|
|
|
Hello!
It seems to me that setscrollinfo both updates the position of the thumb and scrolls the window. this annoys me very much because I want to scroll the window, and setscrollpos just ruins everything.. Is there a function that only sets the position of the thumb?
I'm using mfc.
|
|
|
|
|
You could try calling the API-version ::SetScrollInfo .
|
|
|
|
|
If i recall, position of the thumb is always relative to other information.
if Min is 0 and Max is 100, and pos is 50, then thumb position will be 50%. The scrollbar is probably attached to the document you're viewing so its normal that changing the pos or scrollinfo will move the view of the document.
Why are you trying to change only the thumb position ?
DarkByte
|
|
|
|
|
Because I'm writing an application that behaves like mspaint, and I use SetViewportOrg for scrolling.. Do you have a better suggestion?
|
|
|
|
|
How about you create the scrollbar yourself instead of relying on the scrollbars of the window. You could even subclass the scrollbar to add your behavior.
Other possibility is to control the repainting behavior so that you decide yourself when you try to repaint offsetted and when you dont.
There's probably many other different ways, but they all involve changing some default behavior somwhere.
DarkByte
|
|
|
|
|
Okay.. I just talked to a guy, who told me that I shouldn't be using CScrollView, because it behaves differently from other views. And true enough. When I switched to a standard CView, SetScrollPos didn't scroll my window anymore. I think that's werid.
|
|
|
|
|
i want to get the information and icon of shortcut of desktop by selecting with mouse. i get the list view of desktop shortcut and also i can get the selected index number of shortcut. i am using VC++6.0 and windows 2000 professional. "what i want is to get the icon image and icon name and shortcut link file name". the following code i am using. Mouse hooking is not needed.
HWND hWnd = ::FindWindow("Progman", NULL);
if (NULL != hWnd)
hWnd = FindWindowEx(hWnd, NULL, "SHELLDLL_DefView", NULL);
if (NULL != hWnd)
hWnd = FindWindowEx(hWnd, NULL, "SysListView32", NULL);
if (NULL != hWnd)
{
UINT count = ListView_GetSelectedCount(
hWnd
);
INT mark = ListView_GetSelectionMark(
hWnd
);
int nItem = ListView_GetItemCount(
hWnd
);
... ... ...
}
|
|
|
|
|
Ok, so is your code working? If not, what errors are you getting (e.g., compiler, linker, runtime)? Is the value of count , mark , and nItem correct?
Have you considered SHGetFolderPath() with either CSIDL_COMMON_DESKTOPDIRECTORY or CSIDL_DESKTOPDIRECTORY ? With the path, you can then use FindFirstFile() and FindNextFile() to "find" each file in the folder. Then you can use ExtractIcon() to get the icon used by the file.
I've not tried this specifically, so your mileage may vary.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
1-i want to notify to user when
a program try to access to internet do you think
is there any event in .net or in windows for this
purpose and if there is which events
2- i want to see all open ports in mycompuetr
somthing like netstat command in windows but iwant
do this programmatically
3-if i saw a port is open how can i close it
programmatically
koosha
|
|
|
|
|
Dear all,
I get a following linking error....I am working on VS.NET...can n e one tell why thi occurs and how can it be eliminated....
HanimCompute.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class std::basic_ostream > & __cdecl operator<<(class std::basic_ostream > &,class MString const &)" (__imp_??6@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@ABVMString@@@Z) referenced in function "public: virtual class MStatus __thiscall snMHanimator4Node::compute(class MPlug const &,class MDataBlock &)" (?compute@snMHanimator4Node@@UAE?AVMStatus@@ABVMPlug@@AAVMDataBlock@@@Z)
HanimNode.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) class std::basic_ostream > & __cdecl operator<<(class std::basic_ostream > &,class MString const &)" (__imp_??6@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@ABVMString@@@Z)
Thanks,
Raj
|
|
|
|
|
Which is currently the fastest method to read a text file into memory.
I am using ifstream and get and would like to know of anything better.
|
|
|
|
|
Are you doing ifstream::read()?
What is the length of the data block you are reading? Try increasing the size of the chunks you read if it's reading too slowly. Reading 1 byte at a time is incredibly slow but reading 1MB at a time will be really fast.
|
|
|
|
|
The length of the data block is the entire filesize (which varies)...in my case it is around 500K at the moment...the entire file is read w/ one get.
It is not that slow, I just thought there may be a faster way.
|
|
|
|
|
I have experimented with this now and again and always found that blocks of 2,4 and 8k ranges provide the best performance. I have always assumed that there must be variants across systems that might effect this. OS, File System, Disk Drive and probably more.
It is relatively simple to create a console app that allows you to test variations.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
What are you doing with the file? Memory mapped files deliver impressive performance and may be suitable for your task.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
Hmmmm!
1) Open file.
2) Get size of file.
3) Allocate enough memory to hold entire file.
4) Read file into buffer.
Of cource this only applies if file size if smaller than the maximum buffer size that you can allocate. Under Win32, you can allocate very very large buffers.
INTP
|
|
|
|