zibo3
Messages postés57Date d'inscriptionmercredi 18 juin 2003StatutMembreDernière intervention 7 octobre 2009
-
25 mars 2004 à 13:03
hilairenicolas
Messages postés398Date d'inscriptionjeudi 30 octobre 2003StatutMembreDernière intervention15 juin 2007
-
25 mars 2004 à 14:56
J'aimerai créer un événement appuyer sur une touche de type F3 mais cet événement doit se réaliser à chaque fois que j'appuie sur cette touche quelque soit le widget qui a le focus et je ne veux pas à avoir à recopier ce traitement pour chaque objet, voici mon code où je crée une fenêtre avec une zone de texte et un bouton je traite l'action appuyer sur la touche F3 qui fonctionnne au lancement de la fenetre mais dès que j'utilise je suis sur un deux widget, la touche F3 ne réponds plus.
Aidez moi
#include <windows.h>
//#include <windowsx.h>
#include <Shellapi.h> // Pour l'icone
// Fill in the window class structure with parameters
// that describe the main window.
wcx.cbSize = sizeof(wcx); // size of structure
wcx.style = CS_HREDRAW |
CS_VREDRAW; // redraw if size changes
wcx.lpfnWndProc = WndProc; // points to window procedure
wcx.cbClsExtra = 0; // no extra class memory
wcx.cbWndExtra = 0; // no extra window memory
wcx.hInstance = g_hInst; // handle to instance
//wcx.hIcon = LoadIcon(NULL,IDI_APPLICATION); // predefined app. icon
wcx.hIcon = ExtractIcon(g_hInst,"peanuts.ico",0); // file icon
wcx.hCursor = LoadCursor(NULL, IDC_ARROW); // predefined arrow
wcx.hbrBackground = (HBRUSH)GetStockObject(
WHITE_BRUSH); // white background brush
wcx.lpszMenuName = "MainMenu"; // name of menu resource
wcx.lpszClassName = "Test"; // name of window class
wcx.hIconSm = (HICON)LoadImage(g_hInst, // small class icon
MAKEINTRESOURCE(5),
IMAGE_ICON,
GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON),
LR_DEFAULTCOLOR);
// Register the window class.
return RegisterClassEx(&wcx);
}
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd )
{
MSG msg;
HWND g_hWnd;
g_hInst = hInstance;
if( !InitApplication(g_hInst) )
{
return 0;
}
g_hWnd = CreateWindow(
"Test", // name of window class
"Essaie", // title-bar string
WS_OVERLAPPEDWINDOW, // top-level window
CW_USEDEFAULT, // default horizontal position
CW_USEDEFAULT, // default vertical position
800, // default width
600, // default height
(HWND) NULL, // no owner window
(HMENU) NULL, // use class menu
g_hInst, // handle to application instance
(LPVOID) NULL); // no window-creation data
zibo3
Messages postés57Date d'inscriptionmercredi 18 juin 2003StatutMembreDernière intervention 7 octobre 2009 25 mars 2004 à 14:38
J'ai changé la pompe à message par celle que tu me recommande mais la touche Fx ne répond pas quand je suis dans le champ Edit.
Je n'arrive pas à trapper les événement non prévu par l'objet Edit.
Vous n’avez pas trouvé la réponse que vous recherchez ?
BruNews
Messages postés21040Date d'inscriptionjeudi 23 janvier 2003StatutModérateurDernière intervention21 août 2019 25 mars 2004 à 14:52
Soit tu mets un hook, soit tu charges une table accelerator, soit le plus simple tu verif dans la pompe a messages si est F3 et alors tu le PostMessage sur GetFocus().
hilairenicolas
Messages postés398Date d'inscriptionjeudi 30 octobre 2003StatutMembreDernière intervention15 juin 20072 25 mars 2004 à 14:56
Tu fais un hook sur le clavier dans une dll (voir SetWindowsHookEx dans msdn avec message WH_KEYBOARD)
puis tu fais en sorte qu'il ne hook que la touche F3 sur ton application