Rev 35 | Rev 37 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 35 | Rev 36 | ||
---|---|---|---|
Line 238... | Line 238... | ||
238 | procedure CheatClick(Sender: TObject); |
238 | procedure CheatClick(Sender: TObject); |
239 | procedure FormClose(Sender: TObject; var Action: TCloseAction); |
239 | procedure FormClose(Sender: TObject; var Action: TCloseAction); |
240 | procedure FormDestroy(Sender: TObject); |
240 | procedure FormDestroy(Sender: TObject); |
241 | procedure CheckUpdatesClick(Sender: TObject); |
241 | procedure CheckUpdatesClick(Sender: TObject); |
242 | procedure MasterClick(Sender: TObject); |
242 | procedure MasterClick(Sender: TObject); |
- | 243 | procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); |
|
243 | private |
244 | private |
244 | ProgrammGestartet: boolean; |
245 | ProgrammGestartet: boolean; |
245 | FInterval: TGameInterval; |
246 | FInterval: TGameInterval; |
246 | FScene: TGameScene; |
247 | FScene: TGameScene; |
247 | FMusic: TSpaceMissionMusicTrack; |
248 | FMusic: TSpaceMissionMusicTrack; |
Line 2452... | Line 2453... | ||
2452 | FreeAndNil(dxmusic); |
2453 | FreeAndNil(dxmusic); |
2453 | DeleteCriticalSection(TimerCS); |
2454 | DeleteCriticalSection(TimerCS); |
2454 | FreeAndNil(LevelData); |
2455 | FreeAndNil(LevelData); |
2455 | end; |
2456 | end; |
2456 | 2457 | ||
- | 2458 | procedure PostKeyEx32(key: Word; const shift: TShiftState; specialkey: Boolean); |
|
- | 2459 | {************************************************************ |
|
- | 2460 | * Procedure PostKeyEx32 |
|
- | 2461 | * |
|
- | 2462 | * Parameters: |
|
- | 2463 | * key : virtual keycode of the key to send. For printable |
|
- | 2464 | * keys this is simply the ANSI code (Ord(character)). |
|
- | 2465 | * shift : state of the modifier keys. This is a set, so you |
|
- | 2466 | * can set several of these keys (shift, control, alt, |
|
- | 2467 | * mouse buttons) in tandem. The TShiftState type is |
|
- | 2468 | * declared in the Classes Unit. |
|
- | 2469 | * specialkey: normally this should be False. Set it to True to |
|
- | 2470 | * specify a key on the numeric keypad, for example. |
|
- | 2471 | * Description: |
|
- | 2472 | * Uses keybd_event to manufacture a series of key events matching |
|
- | 2473 | * the passed parameters. The events go to the control with focus. |
|
- | 2474 | * Note that for characters key is always the upper-case version of |
|
- | 2475 | * the character. Sending without any modifier keys will result in |
|
- | 2476 | * a lower-case character, sending it with [ssShift] will result |
|
- | 2477 | * in an upper-case character! |
|
- | 2478 | // Code by P. Below |
|
- | 2479 | ************************************************************} |
|
- | 2480 | type |
|
- | 2481 | TShiftKeyInfo = record |
|
- | 2482 | shift: Byte; |
|
- | 2483 | vkey: Byte; |
|
- | 2484 | end; |
|
- | 2485 | byteset = set of 0..7; |
|
- | 2486 | const |
|
- | 2487 | shiftkeys: array [1..3] of TShiftKeyInfo = |
|
- | 2488 | ((shift: Ord(ssCtrl); vkey: VK_CONTROL), |
|
- | 2489 | (shift: Ord(ssShift); vkey: VK_SHIFT), |
|
- | 2490 | (shift: Ord(ssAlt); vkey: VK_MENU)); |
|
- | 2491 | var |
|
- | 2492 | flag: DWORD; |
|
- | 2493 | bShift: ByteSet absolute shift; |
|
- | 2494 | i: Integer; |
|
- | 2495 | begin |
|
- | 2496 | for i := 1 to 3 do |
|
- | 2497 | begin |
|
- | 2498 | if shiftkeys[i].shift in bShift then |
|
- | 2499 | keybd_event(shiftkeys[i].vkey, MapVirtualKey(shiftkeys[i].vkey, 0), 0, 0); |
|
- | 2500 | end; { For } |
|
- | 2501 | if specialkey then |
|
- | 2502 | flag := KEYEVENTF_EXTENDEDKEY |
|
- | 2503 | else |
|
- | 2504 | flag := 0; |
|
- | 2505 | ||
- | 2506 | keybd_event(key, MapvirtualKey(key, 0), flag, 0); |
|
- | 2507 | flag := flag or KEYEVENTF_KEYUP; |
|
- | 2508 | keybd_event(key, MapvirtualKey(key, 0), flag, 0); |
|
- | 2509 | ||
- | 2510 | for i := 3 downto 1 do |
|
- | 2511 | begin |
|
- | 2512 | if shiftkeys[i].shift in bShift then |
|
- | 2513 | keybd_event(shiftkeys[i].vkey, MapVirtualKey(shiftkeys[i].vkey, 0), |
|
- | 2514 | KEYEVENTF_KEYUP, 0); |
|
- | 2515 | end; { For } |
|
- | 2516 | end; { PostKeyEx32 } |
|
- | 2517 | ||
- | 2518 | procedure TMainForm.FormKeyDown(Sender: TObject; var Key: Word; |
|
- | 2519 | Shift: TShiftState); |
|
- | 2520 | begin |
|
- | 2521 | if Key = VK_ESCAPE then |
|
- | 2522 | begin |
|
- | 2523 | // TODO: Unfortunately, you cannot see if it is already popup. It would be great if ESC closes the main menu... |
|
- | 2524 | Key := 0; |
|
- | 2525 | PostKeyEx32(Ord('S'), [ssAlt], False); |
|
- | 2526 | end; |
|
- | 2527 | end; |
|
- | 2528 | ||
2457 | end. |
2529 | end. |
2458 | 2530 |