Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Key Combination

Status
Not open for further replies.

gforrest

Programmer
Apr 26, 2000
39
CA
I want the following code to force users to press 'CTL' AND 'F10' <br>to display a Message Box and then carry on. Unfortunately, the way it works right now they only have to press 'CTL' to have the MessageBox displayed. In other words the MessageBox is diplayed before they press 'F10'. I've tried a number of things to correct this but to no avail. <br>Can someone help me out here? <br><br>Thanks. <br><br>procedure TCCUMenuFrm.FormKeyDown(Sender: TObject; var Key: Word; <br>Shift: TShiftState); <br>var <br>K: Integer; <br>val: Integer; <br>begin <br>K:=GetKeyState(VK_CONTROL); <br>if (K&lt;&gt;0 and VK_F10) then <br>begin <br>val := MessageDlg('Do You Wish to Halt the CCU?', mtConfirmation,[mbYes,mbNo],0); <br>if val=6 then <br>PostMessage(FindWindow(Nil,'c:\ccu\nts-srv.exe'),WM_CLOSE, 0,0) <br>else <br>end; <br>end; <br>
 
The GetKeyState(VK_CONTROL) gets the current state (not when the F10 was pressed).<br>Try this:<br><br>procedure TCCUMenuFrm.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); <br>var <br>&nbsp;&nbsp;val: Integer; <br>begin <br>K:=GetKeyState(VK_CONTROL); <br>if (Shiht=[ssCtrl])and (Key=VK_F10) then begin <br>&nbsp;&nbsp;val := MessageDlg('Do You Wish to Halt the CCU?', mtConfirmation,[mbYes,mbNo],0);<br>&nbsp;&nbsp;if val=6 then PostMessage(FindWindow(Nil,'c:\ccu\nts-srv.exe'),WM_CLOSE, 0,0);<br>end; <br><br>Bye, Otto.<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top