[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.6

C++ .net (CLR) use Hotkey for Show/Hide Form

Asked by seek1338 in Microsoft Visual C++.Net, C++ Programming Language, .NET Framework 3.x versions

Tags: Hooks, Hotkey

Hello!

I am very new c++ Programmer i have read a book and now try to writte my first Program using Mysql Connection.

My Problem is i want to make a Timer or new Thread that search after F4 pressed and then call a Function to Hide or Show the Main Form.

Since 4 Days i am searching for a function that can do that. In .net i found the System::Windows::Input namespace for WPF i use that in c++ by including the dll and the WindowsBase, but i dont found a solution.

Second thing i found are the Hooks now i am trying to implement this WINAPI in my c++ .net use a Thread with a while(true) for check every 5 ms the state.

I need a sample code how i can use this HOOKS in my .net projekt. Look at Code i Post the Thread. But i dont know how i can use the Dllimport.

That have to be a possibiltiy to make a easy if check like this:
while(true) {
  Thread::Sleep(5);   // wait 5ms to dont overload the prozessor
   if(checkKeyState(F4))
     //to this...
  }

I hope anyone can give me a code sample or a link to a code sample where this is explain because i dont found for c++ clr anything like this.

Thanks for your Help.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
// Call Thread Code:
#include "keyEventThread.h"
 
Thread^ keyThread = gcnew Thread( gcnew ThreadStart( &keyEventThread::waitOnKey ) );
keyThread->SetApartmentState(ApartmentState::STA);
keyThread->Start();
 
 
// THREAD FILE "keyEventThread.h":
#pragma once
using namespace System;
using namespace System::Windows;
using namespace System::Threading;
using namespace System::Runtime::InteropServices;
 
[DllImport("User32.dll", EntryPoint = "SetWindowsHookEx")]
extern "C" long SetWindowsHookEx(long HookID, HookProc^ lpfn, IntPtr hInstance, long ThreadID);
 
[DllImport("User32.dll", EntryPoint = "CallNextHookEx")]
extern "C" long CallNextHookEx(long HookID, long iCode, IntPtr wParam, IntPtr lParam);
 
[DllImport("User32.dll", EntryPoint = "UnhookWindowsHookEx")]
extern "C" bool UnhookWindowsHookEx(long HookID);
 
//CLASS Managed
ref class keyEventThread  
{
public:
 static void waitOnKey() {
 while(true) {
    Thread::Sleep(5);
    /* Check here for F4 if pressed */
    // SetWindowsHookEx(WH_KEYBOARD_LL,0, // I dont know how to use The WinApi
    }
 }
};
[+][-]08/03/09 03:49 AM, ID: 25003208Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/03/09 05:13 AM, ID: 25003612Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/03/09 05:43 AM, ID: 25003798Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/03/09 10:38 AM, ID: 25006576Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/03/09 05:02 PM, ID: 25009538Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/03/09 10:55 PM, ID: 25010936Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/04/09 01:24 AM, ID: 25011504Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/04/09 02:20 AM, ID: 25011726Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/04/09 02:44 AM, ID: 25011842Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/04/09 03:56 AM, ID: 25012221Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/04/09 04:30 AM, ID: 25012418Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/04/09 05:22 AM, ID: 25012785Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/04/09 05:35 AM, ID: 25012903Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Microsoft Visual C++.Net, C++ Programming Language, .NET Framework 3.x versions
Tags: Hooks, Hotkey
Sign Up Now!
Solution Provided By: Laindow
Participating Experts: 2
Solution Grade: A
 
 
Loading Advertisement...
20091021-EE-VQP-81 - Hierarchy / EE_QW_3_20080625