|
Firstly, download and play with PORTMON, free from www.sysinternals.com. Unfortunately, they don't make their source available for this util(they do with some of them). but they desribe how it was implemented:-
The Portmon GUI is responsible for identifying serial and parallel ports. It does so by enumerating the serial ports that are configured under HKEY_LOCAL_MACHINE\Hardware\DeviceMap\SerialComm and the parallel ports defined under HKEY_LOCAL_MACHINE\Hardware\DeviceMap\Parallel Ports. These keys contain the mappings between serial and parallel port device names and the Win32-accessible names.
When you select a port to monitor, Portmon sends a request to its device driver that includes the NT name (e.g. \device\serial0) that you are interested in. The driver uses standard filtering APIs to attach its own filter device object to the target device object. First, it uses ZwCreateFile to open the target device. Then it translates the handle it receives back from ZwCreateFile to a device object pointer. After creating its own filter device object that matches the characteristics of the target, the driver calls IoAttachDeviceByPointer to establish the filter. From that point on the Portmon driver will see all requests aimed at the target device. A complete source code example of filtering is demonstrated by our Filemon file system monitor.
Portmon has built-in knowledge of all standard serial and parallel port IOCTLs, which are the primary way that applications and drivers configure and read status information from ports. The IOCTLs are defined in the DDK file \ddk\src\comm\inc\ntddser.h and \ddk\src\comm\inc\ntddpar.h, and some are documented in the DDK.
Signature space for rent. Apply by email to....
|
|
|
|
|
Second, learn writing drivers
Portmon also uses a driver to capture the data. Its the only reliable way.
...if you're under 8 or younger. Chris Maunder, the Lounge
|
|
|
|
|
MSDN says:
BOOL CMyWnd::SomeLengthyProcess()
{
CWaitCursor wait;
MessageBox("Some result");
wait.Restore();
return TRUE;
why does MessageBox("Some result"); change the cursor? I dont want a messagebox in my app. It should change when the user presses a menu item. How would I do that if I dont put their MessageBox("Some result"); which makes the cursor change?
Thanks,
ns
|
|
|
|
|
MessageBox() sets the cursor because it is not aware of your needs. It just does what it is expected to do: give feedback to the user and allow clicking one of the buttons.
If you dont want a messagebox (I suppose you want another kind of feedback dialog) you will have to create a modeless dialog.
CMyProgressDialog dlg;
dlg.Create();
for(whatever)
dlg.UpdateStatus(currentstatus);
BTW: you dont need to call Restore() explicitly. CWaitCursor does it in the destructor. So when the variable wait goes out of scope the cursor is restored.
...if you're under 8 or younger. Chris Maunder, the Lounge
|
|
|
|
|
I'm not getting it> heres what I want:
The user presses a menu item
The cursor changes to an hourglass
A function doing a lengthy operation is called
function returns
Now the hourglass reverts to normal.
So I dont need any type of window.
Is there something like:
void OnMenuItem()
{
hrGlass.SetCursor = 'hourglass';
LengthyOperation();
hrGlass.SetCursor = 'normal'
}
Thanks,
ns
|
|
|
|
|
I'm confused. What are you talking then about the messagebox?
void OnMenuItem()
{
CWaitCursor wait;
LengthyOperation();
}
...if you're under 8 or younger. Chris Maunder, the Lounge
|
|
|
|
|
Thats what MSDN said - that the messagebox would create the cursor....that puzzled me. however I've outlined what I need so we can just dwell on that.
Sorry if I confused you. I was trying to understand the MSDN documentation so I could do it on my own. But from the docs I am gathering that I have to have a messagebox to make the cursor change. Hope I'm clearer now...
Appreciate your interest.
Thanks,
ns
|
|
|
|
|
void OnMenuItem()
{
AfxGetApp()->DoWaitCursor (1);
LengthyOperation();
AfxGetApp()->DoWaitCursor (-1);
}
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Ravi Bhavnani wrote:
AfxGetApp()->DoWaitCursor (1);
That is what the CWaitCursor constructor does. Try to avoid the AfxWhatever() functions when possible.
...if you're under 8 or younger. Chris Maunder, the Lounge
|
|
|
|
|
AfxGetApp()->DoWaitCursor() is more flexible. You can't use CWaitCursor to indicate disjoint chunks of execution (without paying the price of object construction and destruction).
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
???? Whats the deal? The constructor is simple, the var is created on the stack. Costs even less than calling AfxGetApp() every time.
...if you're under 8 or younger. Chris Maunder, the Lounge
|
|
|
|
|
Hi Andreas,
I was specifically referring to disjoint blocks of execution. Also, you wouldn't call AfxGetApp() each time. You'd call it once and use the cached value.
Btw, I'm not saying you can't use CWaitCursor - it's just that I prefer not to, because a simple function call is a less expensive than multiple object construction and destruction.
Cheers,
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I have a dialog based MFC app that uses AfxBeginThread to create five threads from the same class. I can communicate to the main program from each of the five threads with SendMessage. From each of the five threads I know the threadId of the other four threads. What I would like to know is how to have thread one send a message to thread two and so on until thread four sends a message back to thread one. I've used PostThreadMessage to do the above and the return code is OK, but no message shows up. Where are the messages?
Thanks,
Clay
|
|
|
|
|
Are your threads actually processing messages? Do you have a message pump somewhere? Calling PeekMessage/GetMessage?
...if you're under 8 or younger. Chris Maunder, the Lounge
|
|
|
|
|
The class has the following members:
CSupervisor::CSupervisor()
CSupervisor::~CSupervisor()
BOOL CSupervisor::InitInstance()
int CSupervisor::ExitInstance()
int CSupervisor::Run()
BOOL CSupervisor::PreTranslateMessage(MSG* pMsg)
void CSupervisor::OnReceivedCommand(WPARAM wParam, LPARAM lParam)
This is probably where I'm confused on the existance of a message pump?
Clay
|
|
|
|
|
Derived from? CWinThread? Worker thread or user interface thread? Look at the VC Help on CWinThread, this should bring you on the right track soon.
...if you're under 8 or younger. Chris Maunder, the Lounge
|
|
|
|
|
What kind of communication do you want to implement between the threads? For example, do you want to send a notice or data? Does one thread waits for one or more of the other threads between executing a procedure?
Kuphryn
|
|
|
|
|
The thread class is derived from CWinThread and is of user-interface type. Notice, to start with just as a proof of concept for the program. No, the threads do not have to wait, they could be processing other info.
Clay
|
|
|
|
|
As an aside using SendMessage() back to the main thread or another thread is a really bad idea, and could potentially result in a deadlock. Use PostMessage() and if you need synchronization use CEvent's and WaitForSingleObject().
Also read the articles by Mr. Newcomer here at CP about UI Threads etc.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
I have a dll, whose main class is derived from COleControlModule . When I try to build the dll, I get a link error:
error LNK2001: unresolved external symbol "public: virtual struct CRuntimeClass * __thiscall CMyDll::GetRuntimeClass(void)const " (?GetRuntimeClass@CMyDll@@UBEPAUCRuntimeClass@@XZ)
Do I need to override & implement the GetRuntimeClass() function? But the function is declared virtual in the CObject class, not virtual funcname() = 0; or something. So as far as I know, I don't need to implement it.
I didn't try to call this function from my own dll anywhere, so I am at a loss to determine why this is happening when in all the other dlls or other projects that I made, I got by without having to think about this function.
Any help or pointers would be appreciated.
Thanks very much.
Regards,
Rohit Sinha
|
|
|
|
|
Do the function signatures match? Implement a dummy that calls the base class implementation.
...if you're under 8 or younger. Chris Maunder, the Lounge
|
|
|
|
|
It turned out I had forgotten to include the IMPLEMENT_DYNAMIC macro in my implementation file. This was revealed when I tried to follow your suggestion to implement a dummy function. Actually I tried to reimplement the same function to see what happens, and was told that the function was already declared, and on double clicking the error, was taken to the DECALRE_DYNAMIC macro. This was all I needed to have my ears pulled.
Thanks very much.
Regards,
Rohit Sinha
|
|
|
|
|
I am currently working on a graphical interface for an application designed to recreate a physical model of a ventilation system.
I believe that the tree control in Visual C++ might be useful as a means of modelling a ventilation system, in that ventilation elements in the system could be included as items in the tree, with all the appropriate interconnections.
I am very new to Visual C++ and am fairly unfamiliar with the functionality of the tree control. Is it possible to use it to build your own tree in such a way or is it only used for displaying existing file systems etc. Also could each element in the tree be assigned a particular set of parameters via other interface dialogues? Could these parameters then be used to make mathematical calculations, based on the position of the element within the tree, relative to other elements?
Can anyone suggest other non-MS controls which may be useful?
|
|
|
|
|
the tree control is a general purpose control designed for displaying hierarchical data ... you can do whatever you want with it as far as what it shows is concerned ... detecting clicks on items and position within the tree is easy to do and i guess you could use the position to perform calcs
"... and so i said to him ... if it don't dance (or code) and you can't eat it either f**k it or throw it away" biz stuff about me
|
|
|
|
|
thank you, Lauren that's good news.
Do you know a good place to find information on the functions used by the tree control or tutorials on how to use it?
|
|
|
|