My cadd application sends a WM_CHAR message to my DLL when a key on the keyboard is pressed. The WaitWindowEvent() does recognize when the WM_CHAR event occurs. I am having a problem capturing which key has been pressed using the wparam. Below is my attempt that does not work. What I would like to accomplish is if the ESC key is pressed (ascii 27) have the program go do something. Any suggestions?
Thanks
Ken
Code: Select all
GetState.w = 0
Toggle.w = 0
PrevWinFunction.l
hwnd.l
msg.l
wparam.l
lparam.l
Structure Point2D
x.double
y.double
EndStructure
Dim StartLine.Point2D(1)
Dim EndLine.Point2D(1)
Declare WmCharCallBack(hwnd, msg, wparam, lparam)
ProcedureDLL DrawLine()
OpenLibrary (0,"vcmain32.dll")
OpenLibrary (1,"vctool32.dll")
;Tells CADD application to send this DLL all Windows messages & capture mousedown and abort events
CallFunction (0,"VCSetAlertAppDll",@iError,"Test","DrawLine",ALERT_APP_ALL)
;User tool prompt
CallFunction (1,"VCSetUserTool",2,"DrawLine","Enter lower left corner")
CallFunction (1,"VCSetPrompt",1,"Enter lower right corner")
ToolState.w = 1
Repeat
Event=WaitWindowEvent()
;Getkeyboard input such as enter & escape keys
If Event = #WM_CHAR
WmCharCallBack(hwnd, msg, wparam, lparam)
;Get 1st mouse down point
ElseIf Event = #WM_LBUTTONDOWN And ToolState = 1
CallFunction (0,"VCGetUserToolLBDown",@iError,StartLine())
ToolState = ToolState + 1
;Get 2nd mouse button down point
ElseIf Event = #WM_LBUTTONDOWN And ToolState = 2
CallFunction (0,"VCGetUserToolLBDown",@iError,EndLine())
ToolState = ToolState + 1
EndIf
Until ToolState = 3
;Draw a line
CallFunction (0,"VCAddLineEntityBP",@iError,-1,StartLine(),Endline())
CallFunction (0,"VCLastEntity",@iError,@lH)
CallFunction (0,"VCSetCurrentEntity",@iError,lH)
CallFunction (0,"VCDrawCurrentEntity",@iError)
CallFunction (0,"VCClearAlertAppDll",@iError,"Test","DrawLine")
CloseLibrary(1)
CloseLibrary(0)
EndProcedure
ProcedureDLL WmCharCallBack(hwnd, msg, wparam, lparam)
result = CallWindowProc_(PrevWinFunction, hwnd, msg, wparam, lparam)
Select msg
Case #WM_CHAR
;wparam holds the character code
If wparam = 27
MessageRequester("Test", "Esc key(27) was pressed", 0)
ElseIf MessageRequester("Test", "Not working",0)
EndIf
EndSelect
ProcedureReturn result
EndProcedure
Return 
