|
You cannot use SetTimer for your purpose.
You must use the CreateWaitableTimer and SetWaitableTimer functions.
You can then poll the timer using the WaitForSingleObject function by specifying a timeout value.
|
|
|
|
|
Thank you. I'll better research on how to implement that for my purpose.
|
|
|
|
|
Member 8012013 wrote: I happen to own a version of c++ 6
I would suggest you dump it as soon as possible, and get a copy of Visual C++ Express[^]. It's free and contains support for the latest levels of C++. You can also look at the other Express products (C#, WebDeveloper) which may be of interest.
The best things in life are not things.
|
|
|
|
|
I'm sure I would benefit greatly getting the latest free download version from Microsoft, but I'm also of the impression that with the whole .Net dependencies of the newer versions, that it would consume more computer resources than ver 6. Is this true? I started to go that path then backed out due to my limited machine that I'm working with.
|
|
|
|
|
You're probably correct, but I have no idea how 'limited' your system is. It's just that using such an old development system you may have problems that have been solved in later versions. Why not give the Express version a try, you can always uninstall it if it does not work well. And remember that C++ is not dependent on .NET.
The best things in life are not things.
|
|
|
|
|
Member 8012013 wrote: ...but I'm also of the impression that with the whole .Net dependencies of the newer versions...
At first glance, I do not see .NET as one of the requirements.
http://download.microsoft.com/download/9/a/e/9ae0f6cc-7032-408e-9ca7-989f9e4af4ec/VS2008ExpressReadme.htm#System Requirements
Upon further inspection, it appears that some version of .NET does get installed. Whether it does so automatically or prompts, I do not know.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
modified on Monday, June 27, 2011 11:01 AM
|
|
|
|
|
Wow! You're right DC. I don't see it listed there either. But I'm pretty sure that when installing the executable, at some point, it begins the installation of .net without user consent. Maybe I need to look at that again.
|
|
|
|
|
Member 8012013 wrote: I think I have figured out through trial and lots of error that when the time has expired a message enters the message queue and the code gets to process it when Windows says so. Initially, I was under the impression that SetTimer was giving me a "code interrupt" kind of service when the time expired.
Yup, that's basically the way that this kind of timer works.
I set up this WHILE(Time_Out_Flag == FALSE){} kinda thing in one particular scope and waited patiently for the OnTimer process to set the Time_Out_Flag to TRUE to escape from the WHILE loop--An event that ultimately would never happen (Ctl+Alt+Del got me control again).
Nooooo!
That's not the way to handle this kind of event at all. When you use the SetTimer function, it will cause windows to send your program a WM_TIMER message with wParam = the id you assigned the timer at creation time. Here's[^] a quick sample of use.
|
|
|
|
|
Surprisingly, I had working code using SetTimer before I even knew how SetTimer was getting treated in the background. It was for a different function than what I was seeking help here for, so I'm still using it. I did my research and figured out how to use CreateWaitableTimer and most all that goes with it (Thank you _Superman_) and now I can poll for a timer event. I'm still unclear about one thing. I don't see any method to "Kill" the waitable version like with SetTimer. Is this ok? Do I still have housekeeping to do? The code is functioning after all.
|
|
|
|
|
Just had a quick check on msdn, it seems that there are two ways for one of these waitable timers to be eliminated.
1) Call CloseHandle on the handle to it. It's destroyed when the last handle to it has been closed.
2) Windows will automatically issue CloseHandle when the process terminates.
So, to be quick'n'dirty - nope. Nothing further to be done(windows will do it for you). To be thorough - yes, you should. It's never nice leaving your mess for somebody else to clean up...
|
|
|
|
|
I am trying with tcp sockets. I have one confusion that suppose I open a port (localhost:9200) and if i use that port for reading and writing both then how the same port can be used for that. Will the data collide if I am trying to write on a port and somebody is sending data on that port?
|
|
|
|
|
rahul.kulshreshtha wrote: I<layer> am trying with tcp sockets. I have one confusion that suppose I open a port (localhost:9200) and if i use that port for reading and writing both then how the same port can be used for that.
What exactly do you mean by "how"?
rahul.kulshreshtha wrote: Will the data collide if I am trying to write on a port and somebody is sending data on that port?
No. Incoming and outgoing data is separated by other than the application layer (i guess it is either done by the hardware layer or maybe the protocol layer, would need to look deeper into that).
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
"How" means I want to know how data is handled when sender uses same port for sending and receiving data. I think you have explained it in your second part of the message. So that means when application uses same port for reading and writing at that time data goes from different layers and hence it does not collide.
Thanks for your explanation.
|
|
|
|
|
Yourwelcome.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
You may be surprised that 'different ports' are just a logical abstraction.
And you may find interesting this Wikipedia page[^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
when communication is established between a sender and receiver over TCP/IP, a unique socket handle is created to identify the communication channel. When you use that socket handle all sending and receiving is unique between you and the machine on the other side.
A socket handle is created (as far as I remember) as a combination of the callers IP address and their outgoing TCP/IP Port, and the receivers IP address and inbound Port. The TCP/IP stack ensures that outgoing addresses are not automatically reused (although you can programmatically force them to be reused, but that gets complicated)
Hope that helps,
David
|
|
|
|
|
I recommend the book "Internet Core Protocols" by Eric A. Hall pub: O'Reilly
|
|
|
|
|
thanks, I will read that
|
|
|
|
|
Hi
I am very new to C++/MFC, I have a background of C# and I'm having to get to grips with the basics of C++/MFC to work on an older piece of software.
I am trying to create an application that will display a list of customers taken from an Access database, with dialogs to add and edit customers.
So, step 1, I need to get the list of customers.
So far I have done the following:
1 - Using the app wizard (I'm working with VS 2010), I have created an SDI application with document/view and database support, and derived the view from CListView.
2 - During the wizard I have connected to my database and selected a table.
3 - When the solution is generated, member variables are correctly created for the fields in the table, and code is generated for the DoFieldExchange method in the recordset.
4 - I added code to the OnInitialUpdate method of the view to add columns to the list view control.
Now I'm stuck - I don't know how to connect my recordset to this so that I get a list of customers. Currently all I get is an empty list control with just column headers.
Any help appeciated!
modified on Friday, June 24, 2011 4:44 AM
|
|
|
|
|
Germghost wrote: Now I'm stuck - I don't know how to connect my recordset to this so that I get a list of customers. Currently all I get is an empty list control with just column headers.
Did you loop through the recordset and call InsertItem() to add the items to the list control?
Germghost wrote: Any help appeciated!
See if this is of any help.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
Hi
Thanks for your post. I have read that article (a couple of times). Unfortunately it does not cover what I am trying to acheive - it uses a dialog and databinds controls on that. I'm using a view derived from CListView. Whilst I can get at the list view control using GetListCtrl(), I can't bind my data in the same way it seems.
I can't actually find any examples of binding a recordset to a CListView view, which is very frustrating. I can't believe it's THAT difficult and I'm sure I'm missing something quite simple here
|
|
|
|
|
Hi all,
Years ago I wrote a datamapper in 16 bit C which is still in use. Later I added a debugger that is based on the same code with a user interface in front. When we changed to windows interfaces, I rewrote the interface in c++ (Visual Studio 6) still mixing it with the original C mapping code. Then I migrated to Studio 2005. Works fine. I however recently moved to studio 2010. Now, the system crashes on every "malloc" statement in my C code. It throws an exception at the HEAP_ALLOC (Can't really follow anymore, the last part is in assembly for which there is no source studio says).
Anyone any idea if there has been a change in memory alignment? Is there a compiler option that I should use?? Please help you wise men and women out there!!!!
Thanks in advance
William
|
|
|
|
|
Could you give more details about your project? Is it composed with your DLL s?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
The program is a Dialog based program that calls the datamapper's main loop (replaced the original "main" in the production datamapper by a routine called "StartMapping" in case of the debugger) from the "OnInitDialog". The dialog is c++, the datamapper is C and it does call some Studio6 built libraries that hold stuff like a standard error handling, license check etc. That has all been passed when at some point in the mapping, I use a malloc (or - after having removed the malloc for a test - a _fullpath with a NULL pointer for the target)
Point is that it all worked fine when compiled in Studio2005, and it no longer works now that I have it compiled by Studio2010. It crashes when calling HeapAlloc in ntdll.dll, which tends me to believe that something changed in memory alignment.
William
|
|
|
|
|
Couldn't you rebuild the 'Studio6 built libraries'?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|