|
Image list neede to be a pointer because it will destruct itself otherwise.
|
|
|
|
|
|
You welcome, I had the same issue and I struggled with it for half a day
|
|
|
|
|
Folks,
Does anyone know who to disable the accelerator keys temporarily in a MFC application? I would like to disable the functionality of the entire menu bar when doing lengthy operation. Currently, I call the following function to disable the menu bar.
CMainFrame::EnableWindow ( FALSE );
Apparently, it works ok. The menu bar is grayed out and does not response to mouse clicks. However, when as user press "Alt", the menu bar turn ON again and start to operate. It seems like the "Alt" button enable the menu bar.
Anyway, to disable accelerator keys feature temporarily?
Thank you.
bluntagain
|
|
|
|
|
Folks,
Does anyone know who to disable the accelerator keys temporarily in a MFC application? I would like to disable the functionality of the entire menu bar when doing lengthy operation. Currently, I call the following function to disable the menu bar.
CMainFrame::EnableWindow ( FALSE );
Apparently, it works ok. The menu bar is grayed out and does not response to mouse clicks. However, when as user press "Alt", the menu bar turn ON again and start to operate. It seems like the "Alt" button enable the menu bar.
Anyway, to disable accelerator keys feature temporarily?
Thank you.
igloobear
|
|
|
|
|
is there any easy way to intercept serial port so that the data can be duplicated, with 1 copy sending out and 1 copy displaying in such an application??
thx so much
|
|
|
|
|
I fear you will need to dig into driver development to do that.
...if you're under 8 or younger. Chris Maunder, the Lounge
|
|
|
|
|
didnt try it but u can try something similar to this:
http://www.codeproject.com/dll/apihijack.asp
or else u gotta work with the DDK!
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
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
|
|
|
|