dll中注册热键,求救.....在线等待.......

chensjmail 2008-03-18 04:58:47
我是做java的,但现在要通过动态库注册热键,
注意:是在dll调用注册热键,所以不能像mfc一样写。
如果有时间的话麻烦改一下我发在下面的代码来完成,
因为我不知道怎么样
添加WM_HOTKEY响应原型,
添加映射

这些我都不知道怎么用,所以只虽然很感谢谢之前有在老帖给我回复的同学,谢谢
但我还是没能完成我想要的效果,
希望大家能来帮帮忙!

文件名:HotKey.cpp

#include <stdlib.h>

#include "stdafx.h"
#include "org_csj_hotkey_Hotkey.h"
LRESULT CALLBACK WndProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved){
return TRUE;
}
JNIEXPORT void JNICALL Java_org_csj_hotkey_Hotkey_registerHotKey(JNIEnv *, jobject){
printf("进入\n");
RegisterHotKey(NULL,GlobalAddAtom("Ctrl+Alt+w"),MOD_CONTROL ¦MOD_ALT,'w');
}
JNIEXPORT void JNICALL Java_org_csj_hotkey_Hotkey_unregisterHotKey(JNIEnv *, jobject){
printf("退出\n");
UnregisterHotKey(NULL,GlobalAddAtom("Ctrl+Alt+w"));
}
LRESULT CALLBACK WndProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message
parameter
LPARAM lParam) // second message parameter
{
printf("调用\n");
switch (uMsg){
case WM_CREATE:
// Initialize the window.
printf("dll输出:WM_CREATE\n");
return 0;

case WM_PAINT:
printf("dll输出:WM_PAINT\n");
// Paint the window's client area.
return 0;
case WM_SIZE:
// Set the size and position of the window.
printf("dll输出:WM_SIZE\n");
return 0;
case WM_HOTKEY: //处理WM_HOTKEY消息
printf("dll输出:d按了?\n");
return 0;
case WM_DESTROY:
printf("dll输出:WM_DESTROY\n");
// Clean up window-specific data objects.
return 0;
default:
// Process other messages.
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
return 0;
}
...全文
361 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
chensjmail 2008-04-01
  • 打赏
  • 举报
回复
self up
wgm001 2008-03-31
  • 打赏
  • 举报
回复
UP
wangwei8888 2008-03-31
  • 打赏
  • 举报
回复
mark!
chensjmail 2008-03-30
  • 打赏
  • 举报
回复
呵呵兄系弟谢谢,可惜这还是解决不了我的问题,呵呵
scq2099yt 2008-03-28
  • 打赏
  • 举报
回复
up
  • 打赏
  • 举报
回复
RegisterHotKey(hWnd, 1001,MOD_CONTROL |MOD_ALT,'w');
Mr-Chen 2008-03-26
  • 打赏
  • 举报
回复

JNIEXPORT void JNICALL Java_org_csj_hotkey_Hotkey_registerHotKey(HWND hWnd,JNIEnv *, jobject)
{
printf("进入\n");
RegisterHotKey(hWnd,GlobalAddAtom("Ctrl+Alt+w"),MOD_CONTROL |MOD_ALT,'w');
}
JNIEXPORT void JNICALL Java_org_csj_hotkey_Hotkey_unregisterHotKey(HWND hWnd,JNIEnv *, jobject)
{
printf("退出\n");
UnregisterHotKey(hWnd,GlobalAddAtom("Ctrl+Alt+w"));
}
Mr-Chen 2008-03-26
  • 打赏
  • 举报
回复

// dllHotKey.cpp : Defines the entry point for the DLL application.
//
#include <stdlib.h>

#include "stdafx.h"
#include "org_csj_hotkey_Hotkey.h"

LRESULT CALLBACK WndProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam);

BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}

JNIEXPORT void JNICALL Java_org_csj_hotkey_Hotkey_registerHotKey(JNIEnv *, jobject)
{
printf("进入\n");
RegisterHotKey(NULL,GlobalAddAtom("Ctrl+Alt+w"),MOD_CONTROL |MOD_ALT,'w');
}
JNIEXPORT void JNICALL Java_org_csj_hotkey_Hotkey_unregisterHotKey(JNIEnv *, jobject)
{
printf("退出\n");
UnregisterHotKey(NULL,GlobalAddAtom("Ctrl+Alt+w"));
}
LRESULT CALLBACK WndProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message
parameter
LPARAM lParam) // second message parameter
{
printf("调用\n");
switch (uMsg){
case WM_CREATE:
// Initialize the window.
printf("dll输出:WM_CREATE\n");
return 0;

case WM_PAINT:
printf("dll输出:WM_PAINT\n");
// Paint the window's client area.
return 0;
case WM_SIZE:
// Set the size and position of the window.
printf("dll输出:WM_SIZE\n");
return 0;
case WM_HOTKEY: //处理WM_HOTKEY消息
printf("dll输出:d按了?\n");
return 0;
case WM_DESTROY:
printf("dll输出:WM_DESTROY\n");
// Clean up window-specific data objects.
return 0;
case WM_HOTKEY:
if ( wParam == GlobalAddAtom("Ctrl+Alt+w") )
{
//...热键执行动作
}
default:
// Process other messages.
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
return 0;
}
Mr-Chen 2008-03-26
  • 打赏
  • 举报
回复
"jni.h" ?
chensjmail 2008-03-19
  • 打赏
  • 举报
回复
靠,专家那么多分怎么没人来回答的我问题呀,
专家们都那去了.....
appley 2008-03-19
  • 打赏
  • 举报
回复
顶一下
chensjmail 2008-03-19
  • 打赏
  • 举报
回复
唉,
难道是,道不同不相为谋吗,
怎么没人能帮忙把代码完整一点的帖出来!
唉,我还在等待......
  • 打赏
  • 举报
回复
没看到RegisterHotKey第一个参数么?
系统会将热键消息发送到你注册的那个窗口。
所以你得创建一个隐藏的窗口来接收热键消息
chensjmail 2008-03-18
  • 打赏
  • 举报
回复
help me.....help me.....help me.....help me.....help me.....help me.....help me.....help me.....help me.....help me.....help me.....
chensjmail 2008-03-18
  • 打赏
  • 举报
回复
文件名:org_csj_hotkey_Hotkey.h

/* DO NOT EDIT THIS FILE - it is machine generated */
#include "jni.h"
/* Header for class org_csj_hotkey_Hotkey */

#ifndef _Included_org_csj_hotkey_Hotkey
#define _Included_org_csj_hotkey_Hotkey
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_csj_hotkey_Hotkey
* Method: registerHotKey
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_csj_hotkey_Hotkey_registerHotKey
(JNIEnv *, jobject);

/*
* Class: org_csj_hotkey_Hotkey
* Method: unregisterHotKey
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_csj_hotkey_Hotkey_unregisterHotKey
(JNIEnv *, jobject);

#ifdef __cplusplus
}
#endif
#endif

64,654

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧