|
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]
|
|
|
|
|
Could do that, but:
1. They are still used in other programs too
2. Some of these programs have also already been built in Studio 2010 and they all work.....
William
|
|
|
|
|
Hi William,
Try linking your exe with Data Execution Prevention off: Project->Properties->Linker->Advanced->Data Execution Prevention (DEP)->No.
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
Hello everyone!
I am trying to alternate an SDI application which is used to operate a spectral camera as part of my diploma thesis. Since it's not my code entirely I tried to simulate a bit of the functionality I want add in a simpler example. So I created an MFC SDI application using Creation Wizard of Visual Studio 2005 (it's a bit old I know but what can you do...). The code I added implements a new class derived from CDialog which creates an invisible message-only, and posts/sends two user-defined messages. These two messages are supposed to be handled by an object of my class CInvisibleWnd. Everything seems to work fine (no errors and no warnings during building) and all my objects are successfully created but the code inside the event handlers is not reached! Do you have any suggestions?
Here's a code snippet of my added classes:
#define WM_MITSOS (WM_APP + 14)
#define WM_TAKIS (WM_APP + 15)
class CDialogMsg : public CDialog
{ DECLARE_DYNAMIC(CDialogMsg)
public:
CDialogMsg(CWnd* pParent = NULL);
virtual ~CDialogMsg();
enum { IDD = IDD_DIALOG_MSG };
CInvisibleWnd* pWnd;
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedOk();
afx_msg void OnBnClickedCancel();
afx_msg void OnBnClickedButtonCreate();
BEGIN_MESSAGE_MAP(CDialogMsg, CDialog)
ON_BN_CLICKED(IDOK, &CDialogMsg::OnBnClickedOk)
ON_BN_CLICKED(IDCANCEL, &CDialogMsg::OnBnClickedCancel)
ON_BN_CLICKED(IDC_BUTTON_CREATE, &CDialogMsg::OnBnClickedButtonCreate)
END_MESSAGE_MAP()
void CDialogMsg::OnBnClickedOk()
{
SendMessage(WM_MITSOS, (WPARAM)1, (LPARAM)3);
}
void CDialogMsg::OnBnClickedCancel()
{
SendMessage(WM_TAKIS, (WPARAM)2, (LPARAM)4);
}
void CDialogMsg::OnBnClickedButtonCreate()
{
pWnd = new CInvisibleWnd;
}
class CInvisibleWnd : public CWnd
{ DECLARE_DYNAMIC(CInvisibleWnd)
public:
CInvisibleWnd();
virtual ~CInvisibleWnd();
protected:
DECLARE_MESSAGE_MAP()
afx_msg LRESULT OnMitsos(WPARAM w, LPARAM l);
afx_msg LRESULT OnTakis(WPARAM w, LPARAM l);
};
IMPLEMENT_DYNAMIC(CInvisibleWnd, CWnd)
CInvisibleWnd::CInvisibleWnd()
{
CString wnd_class_name = ::AfxRegisterWndClass(NULL);
this->CreateEx(0,wnd_class_name,_T("CMyMessageOnlyWindowClass"),0 ,0 ,0 ,0 ,0 ,HWND_MESSAGE,0);
AfxMessageBox(_T("Invisible Window created!"));
}
BEGIN_MESSAGE_MAP(CInvisibleWnd, CWnd)
ON_MESSAGE(WM_MITSOS, &CInvisibleWnd::OnMitsos)
ON_MESSAGE(WM_TAKIS, &CInvisibleWnd::OnTakis)
END_MESSAGE_MAP()
LRESULT CInvisibleWnd::OnMitsos(WPARAM w, LPARAM l)
{
AfxMessageBox(_T("Hi Mitsos"));
return LRESULT(true);
}
LRESULT CInvisibleWnd::OnTakis(WPARAM w, LPARAM l)
{
AfxMessageBox(_T("Hi Takis"));
return LRESULT(true);
}
The CDialogMsg object is created by C"MyProjectName"Doc object...
I could not incorporate message-only CWnd to C"MyProjectName"Doc due to multiple inheritance which is, as I found out, very difficult to implement. The best source I found for message-only CWnd in MFC is here: How to make a Message Only Window
Any ideas?
Thank you very much!
Best Regards!
Ody -- Always look on the bright side of life --
modified on Thursday, June 23, 2011 11:40 AM
|
|
|
|
|
Possibly try something like, pWnd->SendMessage(...)?
|
|
|
|
|
Thank you very much! it worked and I just couldn't see that....
|
|
|
|
|
See my answer if you have some question as to why his code wasn't working.
|
|
|
|