{"id":643,"date":"2008-05-18T04:14:14","date_gmt":"2008-05-18T04:14:14","guid":{"rendered":"http:\/\/6teen.ru\/?p=682"},"modified":"2008-05-18T04:14:14","modified_gmt":"2008-05-18T04:14:14","slug":"1267","status":"publish","type":"post","link":"http:\/\/pblog.ru\/lab\/?p=643","title":{"rendered":"\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0433\u043e\u0440\u044f\u0447\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u043a\u043b\u0430\u0432\u0438\u0448"},"content":{"rendered":"<p>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0433\u043e\u0440\u044f\u0447\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u043a\u043b\u0430\u0432\u0438\u0448<br \/>\n<!--more--><\/p>\n<pre class=\"alt2\" style=\"margin:0px; padding:6px; border:1px inset; width:580px; height:320px; overflow:auto\"><div>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0433\u043e\u0440\u044f\u0447\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u043a\u043b\u0430\u0432\u0438\u0448\n\n{the following example demonstrates registering hotkeys with the\nsystem to globally trap keys}\n\nunit unit1;\n\ninterface\n\nuses\nwindows, messages, sysutils, classes, graphics, controls, forms,\ndialogs;\n\ntype\ntform1 = class(tform)\nprocedure formcreate(sender: tobject);\nprocedure formdestroy(sender: tobject);\nprivate\n{ private declarations }\nid1, id2, id3, id4: integer;\nprocedure wmhotkey(var msg: twmhotkey); message wm_hotkey;\npublic\n{ public declarations }\nend;\n\nvar\nform1: tform1;\n\nimplementation\n\n{$r *.dfm}\n\n\/\/ trap hotkey messages\nprocedure tform1.wmhotkey(var msg: twmhotkey);\nbegin\nif msg.hotkey = id1 then\nshowmessage('ctrl + a pressed !');\nif msg.hotkey = id2 then\nshowmessage('ctrl + alt + r pressed !');\nif msg.hotkey = id3 then\nshowmessage('win + f4 pressed !');\nif msg.hotkey = id4 then\nshowmessage('print screen pressed !');\nend;\n\nprocedure tform1.formcreate(sender: tobject);\n\/\/ different constants from windows.pas\nconst\nmod_alt = 1;\nmod_control = 2;\nmod_shift = 4;\nmod_win = 8;\nvk_a = $41;\nvk_r = $52;\nvk_f4 = $73;\nbegin\n\/\/ register hotkey ctrl + a\nid1 := globaladdatom('hotkey1');\nregisterhotkey(handle, id1, mod_control, vk_a);\n\n\/\/ register hotkey ctrl + alt + r\nid2 := globaladdatom('hotkey2');\nregisterhotkey(handle, id2, mod_control + mod_alt, vk_r);\n\n\/\/ register hotkey win + f4\nid3 := globaladdatom('hotkey3');\nregisterhotkey(handle, id3, mod_win, vk_f4);\n\n\/\/ globally trap the windows system key \"printscreen\"\nid4 := globaladdatom('hotkey4');\nregisterhotkey(handle, id4, 0, vk_snapshot);\nend;\n\n\/\/ unregister the hotkeys\nprocedure tform1.formdestroy(sender: tobject);\nbegin\nunregisterhotkey(handle, id1);\nglobaldeleteatom(id1);\nunregisterhotkey(handle, id2);\nglobaldeleteatom(id2);\nunregisterhotkey(handle, id3);\nglobaldeleteatom(id3);\nunregisterhotkey(handle, id4);\nglobaldeleteatom(id4);\nend;\n\nend.\n\n{\nregisterhotkey fails if the keystrokes specified for the hot key have\nalready been registered by another hot key.\n\nwindows nt4 and windows 2000\/xp: the f12 key is reserved for use by the\ndebugger at all times, so it should not be registered as a hot key. even\nwhen you are not debugging an application, f12 is reserved in case a\nkernel-mode debugger or a just-in-time debugger is resident.\n}\n<\/div><\/pre>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0433\u043e\u0440\u044f\u0447\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u043a\u043b\u0430\u0432\u0438\u0448<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[433,443],"tags":[1278,1363,1681,980],"_links":{"self":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts\/643"}],"collection":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=643"}],"version-history":[{"count":0,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts\/643\/revisions"}],"wp:attachment":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=643"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=643"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=643"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}