|
Does anyone have some sample code for monitoring all keyboard presses? My program needs to watch ALL keyboard input while it is minimized regardless of what application is currently active.
Even if you don't have code, any ideas on how to do it?
Thanks for your help.....
Don Grout
|
|
|
|
|
you can either use a global Keyboard hook, or you can use DirectInput from DirectX to hook into the keyboard presses.
Here is an article that has the hook mehtod shown, and there is some discussion in the comments about the DirectX method:
http://www.codeproject.com/dll/trackuseridle.asp#xx321060xx[^]
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Thanks for the link. It led me to the article on KeyBoard Hooks which is more useful.
http://www.codeproject.com/dll/keyboardhook.asp
Don
|
|
|
|
|
How can I activate the default(or first, doesn't matter) dial-up connection?
|
|
|
|
|
|
Thank you!
I strangely keep forgetting that there is a search function on this page :p
Maybe because I mostly deal with programming at late night... hmm
|
|
|
|
|
I have an animation control on a dialog along with a progress control, similar to the Windows Explorer progress dialog during a copy operation.
In my WM_INITDIALOG handler, I load an AVI from the resource and start playing it immediately. I also set a timer for 20 ms and call a USB communications routine every 20 ms thereafter. The problem is, the AVI sometimes doesn't display right away. I tried calling SendDlgItemMessage with WM_PAINT to the Animation control in my WM_TIMER event handler, and that helped a little bit. Anyone have any suggestions?
Brigg Thorp
Software Engineer
Timex Corporation
|
|
|
|
|
You shouldnt send WM_PAINT messages because they are not generally handled in the message queue like a regular message.
A better method would be to call a function like UpdateWindow or RedrawWindow with the RDW_UPDATENOW flag set. These will force a repaint and implicitly send a WM_PAINT message to your animation control.
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
OK. I changed the code to call UpdateWindow after I load the animation control, after I start playing the animation (both handled in WM_INITDIALOG) and also every entrance into my WM_TIMER handler (every 20 ms). This seems to help, however there are still some rare occasions when the dialog starts communicating with the USB device, the progress control is drawn correctly, but the AVI is not loaded. Can you offer any suggestions on how I can gaurantee that the AVI file is loaded and frame 1 is drawn before I begin processing?
Regards,
Brigg Thorp
Software Engineer
Timex Corporation
|
|
|
|
|
try the ::Animate_Open function inside of your OnInitDialog handler. It will open the avi file and display the first frame. This function is synchronous so that your application will block until the first frame is displayed.
If you do it this way, I beleive that the call to UpdateWindow will be unecessary.
Good Luck.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
in my WM_INITDIALOG handler, I call this function:
<br />
HWND CreateAnimationCtrl(HWND hwndDlg, int nIDCtl) <br />
{ <br />
HWND hwndAnim = NULL; <br />
RECT rc; <br />
POINT pt; <br />
<br />
hwndAnim = Animate_Create(hwndDlg, IDC_ANIMATE, WS_CHILD | ACS_TRANSPARENT, ghInst); <br />
<br />
GetWindowRect(GetDlgItem(hwndDlg, nIDCtl), &rc); <br />
<br />
pt.x = rc.left; <br />
pt.y = rc.top;<br />
ScreenToClient(hwndDlg, &pt); <br />
<br />
SetWindowPos(hwndAnim, 0, pt.x, pt.y, <br />
149, 25, <br />
SWP_NOZORDER | SWP_DRAWFRAME); <br />
<br />
Animate_Open(hwndAnim, MAKEINTRESOURCE(IDR_AVI)); <br />
ShowWindow(hwndAnim, SW_SHOW); <br />
RedrawWindow(hwndAnim, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN);<br />
<br />
return hwndAnim; <br />
} <br />
If the call is synchronous, then I would expect that this would be completed before my timer event fires. So it must be something with the control itself.
Brigg Thorp
Software Engineer
Timex Corporation
|
|
|
|
|
I am looking for some insight. I have received the message:
"Visual C++ Runtime Error C:\WinNT\explorer.exe
R6017 Unexpected Multi-Thread Lock"
on several occasions from the Windows Explorer in Win2K SP3.
I have not found any information on the R6017 message.
Are there Visual C++ libraries installed on my system that are causing the problem? Or does this message refer to libraries that were linked in my build on Windows Explorer?
My explorer.exe file is dated 7/22/2002, size of 238 KB, and Product Version number is listed as: 5.00.3502.5321.
Any suggestions for what I should be chasing?
Thanks,
Kim
|
|
|
|
|
From MSDN[^]:
<quote>
C Run-Time Error R6017
unexpected multithread lock error
The process received an unexpected error while trying to access a C run-time multithread lock on a system resource.
This error usually occurs if the process inadvertently alters the run-time heap data. However, it can also be caused by an internal error in the run-time or operating-system code.
</quote>
Maybe this helps?
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
Thanks for the additional information. What would you suggest in terms of trying to fix or avoid the problem?
Kim
|
|
|
|
|
The only thing I can think of, if this becomes a major problem, is to re-install windows. Not an ideal solution I know, but sometimes that is what it takes.
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
I have a class that I call from various functions, and I want to have the iterator not return to the beginning each time it starts. For example, function 1 reads in the first two vector strings. The instance of the class is then passed to another function. When it reads the next function, I want it to read the third vector string. The following does not do that. The iterator starts at the beginning of the vector in each function. Is there a way to do this?
class InputFile
{
private:
vector <std::string> theVector;
vector<std::string>::iterator pr;
public :
// InputFile();
// InputFile(std::vector<std::string> & trs);
// string getNextLine();
InputFile( std::vector<std::string> & trs )
{
theVector.resize(trs.size());
copy(trs.begin(), trs.end(), theVector.begin());
pr = theVector.begin();
}
int size( void)
{
return theVector.size();
}
string getCurrentLine( void )
{
string s;
s = *pr;
return s;
}
string getNextLine( void )
{
string s;
pr++;
s = *pr;
return s;
}
};
Thanks.
|
|
|
|
|
Is there anyone who has a sample to use the MSXML DOM
parser in a MFC application for eVC++ 3.0 on PocketPC 2002?
I have tried the last 3 days to create a sample
application ... but nothing ... so please ... I would
need a sample!
(If possible I want to use SMART POINTERS and the _bstr_t
and _variant_t classes, but I welcome all other samples I
can learn from.)
PS: Sorry for my bad english!
Thanks!
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
Hello,
I was wondering if there is anyway to create some type of timer inside a CWinThread? I would like to spawn a thread and if the timer reaches a high enough number it would tell the thread to quit..
I played around with OnIdle but it seems to only get called once..
Any ideas?
Rob
|
|
|
|
|
OnIdle() gets called until the return value tells the framework not to call it anymore.
Anyway, you can create a timer using the API function SetTimer(), passing the HWND parameter as NULL so that the timer message is then sent to the thread instead of a window. You can then pick up the WM_TIMER message in the PreTranslateMessage() method of the CWinThread derived class.
e.g.
BOOL CThread::InitInstance()
{
// Every second
m_nID = ::SetTimer( NULL, 0, 1000, NULL );
ASSERT( m_nID != 0 );
return TRUE;
}
BOOL CThread::PreTranslateMessage(MSG* pMsg)
{
if ( WM_TIMER == pMsg->message && m_nID == pMsg->wParam )
{
::KillTimer( m_nID );
PostQuitMessage( 0 ); // Kill the thread
return TRUE; // We have finished processing this message
}
return CWinThread::PreTranslateMessage( pMsg );
}
Dave
|
|
|
|
|
|
Ok, I'm going to show my ignorance here so please forgive me.
Here's the problem I'm trying to solve. I've got a Dialog based application which contains a listbox and a button. I've also got some legacy C code which contains a function that I must call after the user hits the button.
So, after the user hits the button we're in a function within the C legacy code. In this function, I need to update the ListBox with information contained in a character array.
As I understand it, the only method available to me is to use a call back function. I understand the basic concept but not the syntax. I'd really appreciate it if someone could help me with the syntax required. I'm adding some basic code below to further illustrate the problem.
Thanks SOOOO much for any help you can provide!!!!
--------------------------------
//Clegacycode.c
#include mydialogapp.h
void somefunction();
void somefunction(){
//need to update the list box with "HOWDY"
}
------------------------------
//mydialogapp.cpp
.
.
.
void CMyDialogAppDlg::OnCallTheLegacyStuff()
{
somefunction();
}
|
|
|
|
|
Try something like:
typedef void (*FN_MyCallback)(void* pParam1, void* pParam2);
void somefunction(FN_MyCallback pfnCallback, void* pParam1)
{
// Do stuff...
// Callback
(*pfnCallback)(pParam1, pParam2);
// Do more stuff...
}
Dialog
void CMyDialogAppDlg::OnCallTheLegacyStuff()
{
somefunction( &CMyDialogAppDlg::LegacyCallbackStatic, (void*)this );
}
void CMyDialogAppDlg::LegacyCallbackStatic(void* pParam1, void* pParam2) // Must be static member
{
((CMyDialogAppDlg*)pParam1)->LegacyCallback( pParam2 );
}
void CMyDialogAppDlg::LegacyCallback(void* pParam)
{
// Update the display...
}
Dave
|
|
|
|
|
|
I am using a CTabCtrl, and two CListCtrl's underneath. I used the dailog editor to add them to a dialog (the tab order has the CTabCtrl as being the first item). When the dialog is initialized, I use ShowWindow() to show the appropriate list control, and hide the other. The same is done when you click on the tab control.
Everything works fine until you do one of a few things:
1. Simply re-size one of the list control's columns until a scroll bar is required.
2. Minimize, and restore the window.
Either one of these will create a redrawing problem that looks really bad. If I click on the tab control, it will clear up.
Is there something I can do to clear this up? Has anyone seen this before? I saw an article posted on another web site that describes a similar problem, but the answers were numerous and not very helpful.
Thanks,
David
|
|
|
|
|
Can't be sure, but here's a couple of things to try:
1) check the z-order of the controls on your dialog. Both list controls should be higher (later in the tab order) than the tab control.
2) if #1 fails to resolve your problem, you can set the WS_CLIPSIBLINGS style on the tab control (using ModifyStyle() for instance).
---
Shog9
This is my December
These are my snow covered dreams
This is me pretending
This is all I need...
|
|
|
|