Guidance
指路人
g.yi.org
Guidance Forums / Rapid-Q Basic / Problems with API function CallWindowProc()

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Problems with API function CallWindowProc()
#1092
Posted by: 2003-09-12 15:22:00
Hi

in http://g.yi.org/_scripts/file.php?f=2186&r=2330 the
API fuction CallWindowProc() is used. I have some
problems with CallWindowProc() in my own source
code and do not know why. Who can help me?
Please have a look at the source code below.

Best Regards
Martin

' I have a problem with this program. If you close
' the form then two message windows are displayed.
' The first message displays the value 1, but the
' second the value 0. Why don't they display the
' same value? What's wrong with this program?

CONST GWL_WNDPROC = (-4)

DECLARE FUNCTION CallWindowProc LIB "user32" ALIAS _
"CallWindowProcA" (lpPrevWndFunc AS LONG, _
hwnd AS LONG, msg AS LONG, wParam AS LONG, _
lParam AS LONG) AS LONG
DECLARE FUNCTION SetWindowLong LIB "user32" ALIAS _
"SetWindowLongA" (ByVal hwnd AS LONG, _
ByVal nIndex AS LONG, ByVal dwNewLong AS LONG) AS LONG

DIM DefWndProc AS LONG
FUNCTION WndProc (hWnd AS LONG,uMsg AS LONG, _
wParam AS LONG,lParam AS LONG) AS LONG
result=CallWindowProc(DefWndProc,hWnd,uMsg,wParam,lParam)
END FUNCTION

FUNCTION Test AS INTEGER
  result=1
  ShowMessage(STR$(result))   ' <== returns 1 (that's OK)
  ShowMessage(STR$(result))   ' <== returns 0 (why ???)
END SUB

SUB FormClose (Action AS INTEGER)
  Test
END SUB

DIM form AS QFORM
DefWndProc= _
SetWindowLong(form.Handle,GWL_WNDPROC,CODEPTR(WndProc))
form.OnClose=FormClose
form.ShowModal
Message2. Re: Problems with API function CallWindowProc()
#1100
Posted by: 2003-10-02 20:06:54
Try putting Test as a SUB...END SUB.
If you really need a FUNCTION you
should exit the function with
Return etc as normal and then ShowMessage()
afterwards (outside the function). This
is because ShowMessage, which is
API MessageBox(), can/does omit a message.
Hence it could be dealing with the first message
ShowMessage() as normal but the return from
ShowMessage (internally) could be messing up
the second ShowMessage and/or the message
queue in general. This happens in C
for example when waiting for a Printer
object (message) to return and you do a MessageBox
from within the same routine. Hence. A windows
thing rather than a RapidQ thing.

Regards

John
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Sat 2024-4-20  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0