C# :: Delegates / Events Are Just Not Sticking
Dec 28, 2014
In my week long quest to understand delegates/events, all the contrived examples have made my understanding worse. I've been trying to make this simple console project work, where you have a Person, Phone and Switchboard class. My thinking was, that the Phone object would broadcast to any SwitchBoard that's listening, the SwitchBoard would broadcast to the proper phone on the other end and the phone would do the same for any person that's listening.
This is what I have so far, and after adding the SwitchBoard.
class Phone {
public delegate void IncomingCallHandler();
public event IncomingCallHandler IncomingCallEvent;
public delegate void OutGoingCallHandler(Phone p);
public event OutGoingCallHandler OutGoingCallEvent;
[Code] ....
View 8 Replies
Feb 24, 2014
I have a program that has been broken into View/Model/Control plus another class to handle RS232 output.
When the View requests something to be sent via RS232, an event is sent to the control, which then raises an event for the serial class.
Is there a way of using only one event without the serial knowing anything about the view?
If there was, I'd imagine it would be something with Lamdas.
View 2 Replies
View Related
Mar 16, 2014
I want to build a library using c++ which will serve as an abstraction layer between applications and low-level process. The library will provide some APIs for the applications for some purposes.
For example the low-level process, may send an indication to the library i.e. raise an event, and the library in turns send it to all the applications, which have their registered callbacks to this library.
Any example for the previous scenario in c++ using boost library or the standard library will be perfect in Linux environment? The example that I want is: Generate event from a process and pass it to the library, then let an application register callback to the library.
Initially I know in Linux, I may use signal to send events, but my plan is to have a something more general not tighten to a specific OS.
View 1 Replies
View Related
Sep 28, 2013
class test {
private:
string name="";
public:
event void changedname();
void setname(string value)
[code]....
i get error about 'a' and 'b' not be a class. but using a template can i validate these code?
my problem is that i don't know how to use objects outside of functions / these is polymorphism, but not accepted by C++
View 12 Replies
View Related
May 23, 2012
How to use button with right click events in mfc?
View 1 Replies
View Related
Mar 28, 2012
I have looked on this website and stumbled across this link: [URL] .....
My question is can how do I use that code when im console programming?
When I try this code I get errors.
" line |14|error: initializer expression list treated as compound expression|"
" line |17|error: a function-definition is not allowed here before '{' token|"
"line |40|error: expected '}' at end of input|"
Code:
#include <iostream>
using namespace std;
int main() {
int MouseMove(100,100);
void MouseMove (int x, int y ) {
[Code] .....
View 4 Replies
View Related
Apr 19, 2014
I'am creating a 10x10 graph of nodes. Each node is a button object.
Instead of coding the click event procedure for each (As each button will do the same thing when clicked), how would I implement a single click event method for all of the buttons within a Button array.
Picture of the 10x10 grid
EDIT: Each button would return its location (x,y) to the node class.
I'm attempting to write a basic Dijkstra's algorithm using a 10x10 grid.
View 1 Replies
View Related
Apr 20, 2012
I have written ( using VS2008 c++ ) a windows service which sends information about PC usage to a central database, as part of a PC availability setup. I have been asked to add the following functionality to it:
1) What applications are most used, when and how long for, and
2) What web sites are being accessed, again to find the most popular etc.
My main question is, what functionality is there to trap application start / close events from within my service ( just need the application name ), and secondly I am already using sockets to send information to a PHP script on a server, the best way to see what web pages are being accessed is to build in a packet sniffer, and extract the information from that.
View 6 Replies
View Related
Jun 17, 2013
I have a main CWnd class called CMainWnd which is created like this:
Code:
DWORD dwStyle = WS_VISIBLE | WS_BORDER | WS_CLIPCHILDREN ;
...
CWnd::Create(AfxRegisterWndClass(CS_DBLCLKS), L"", dwStyle, rect, parent, NULL, NULL);
And I draw smaller windows on this main window with a CWnd-dervied class called CClientWnd, which is created like this:
Code:
DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_BORDER;
...
CWnd::Create(AfxRegisterWndClass(CS_DBLCLKS), L"", dwStyle, rect, parent, NULL, NULL);
In the main window I draw lots of background stuff using a memoryDC and BitBlt(). In the child window, I actually am not drawing anything, I just created it to have events like mouse over, etc. In the child window when the mouse is over the window I bring up a pop-up window. This works unless my mouse is over any parts where something is drawn in the main window, then the popup just flickers constantly. Why is the main window affecting my mouse over events if I am not handling any such events for it?
View 1 Replies
View Related
Feb 16, 2014
How do I detect left mouse button down and up events on the 'Close' option of the system menu that appears when the mouse is clicked on the top left corner of a form?
View 1 Replies
View Related