From: Gary on
I'm using this code but GetObjectByHandle() Returns a NULL_OBJECT. Am
I missing the obvious?

METHOD BeforeDispatch(hWnd, uMsg, wParam, lParam) CLASS App
LOCAL oObj AS OBJECT

IF uMsg == WM_RBUTTONDOWN
IF wParam == 14
oObj := GetObjectByHandle( hWnd )
IF !( oObj == NULL_OBJECT )
GSW( oObj ):RollAndPaint()
ENDIF
ENDIF
ENDIF
RETURN TRUE

Thanks,
Gary
From: Geoff Schaller on
Gary,

This is almost impossible. I don't know what wParam of 14 implies but
how do you know the code does not enter the GSW function? I suspect it
is going in there but failing inside that for some reason. Plant some
debug messages to follow the flow.

Also, just a cosmetic issue, the following code is more syntactically
correct and involves one less function call... which is important in
something like a BeforeDispatch:

IF uMsg = WM_RBUTTONDOWN
IF wParam = 14
oObj := GetObjectByHandle( hWnd )
IF oObj <> NULL_OBJECT
GSW( oObj ):RollAndPaint()
ENDIF
ENDIF
ENDIF

In fact I would go so far as to say that oObj can NEVER be a null object
and so that function call is redundant. If I put the following code in
my BeforeDispatch it never crashes:

oObject := GetObjectByHandle(hWnd)
cOutput := "Window: " +
Left(Symbol2String(ClassName(oObject))+Space(30), 30)
cOutput += " Message: "+Left(MsgString(uMsg), 15)
cOutput += " wParam: "+StrZero(wParam,10)+" lParam:
"+StrZero(lParam,10)
DebugOutputNoTrace(cOutput)

Cheers,

Geoff

"Gary" <gary.miller(a)cox.net> wrote in message
news:b9631845-7b96-403f-bac5-9f5d31e559a2(a)b35g2000yqi.googlegroups.com:

> I'm using this code but GetObjectByHandle() Returns a NULL_OBJECT. Am
> I missing the obvious?
>
> METHOD BeforeDispatch(hWnd, uMsg, wParam, lParam) CLASS App
> LOCAL oObj AS OBJECT
>
> IF uMsg == WM_RBUTTONDOWN
> IF wParam == 14
> oObj := GetObjectByHandle( hWnd )
> IF !( oObj == NULL_OBJECT )
> GSW( oObj ):RollAndPaint()
> ENDIF
> ENDIF
> ENDIF
> RETURN TRUE
>
> Thanks,
> Gary

From: Gary on
Geoff
Here is what I did to "see" what the GetObjectByHandle() Returns.
Below you'll see that indeed it returns a null_object sometimes.

METHOD BeforeDispatch(hWnd, uMsg, wParam, lParam) CLASS App
LOCAL oObject as OBJECT
LOCAL cOutput as STRING
local hFile as ptr
local cFile as string

oObject := GetObjectByHandle(hWnd)
cOutput := "Window: " + Left(Symbol2String(ClassName(oObject))
+Space(30), 30)
cOutput += " wParam: "+StrZero(wParam,10)+"
lParam: "+StrZero(lParam,10) + CHR( 10 ) + CHR( 13 )
if !File( cFile := "c:\output_text.txt" )
hFile := FCreate( cFile )
else
hFile := FOpen( "c:\output_text.txt" )
endif
FWrite( hFile, cOutput, SLen( cOutput ) )
FClose( hFile )

return true

contents of c:\output_text.txt (I'm not sure why the GetAppObject()
sometimes returns a null_object.

Window: STANDARDSHELLWINDOW wParam: 0000000008 lParam:
0011797534

Window: STANDARDSHELLWINDOW wParam: 0000000008 lParam:
0011797534

Window: STANDARDSHELLWINDOW wParam: 0000000000 lParam:
0000000000

Window: wParam: 0000023031 lParam:
0007764700

Window: wParam: 0000000001 lParam:
0000000000

Window: wParam: 0000023031 lParam:
0007764700

Window: STANDARDSHELLWINDOW wParam: 0000061728 lParam:
0000000000

Window: STANDARDSHELLWINDOW wParam: 0000000000 lParam:
0000000000

Window: wParam: 0000000000 lParam:
0000000000

Window: STATUSBAR wParam: 0000000000 lParam:
0000000000

Window: TOOLBAR wParam: 0000000000 lParam:
0000000000

Window: wParam: 0000000001 lParam:
0000000000

Window: wParam: 0000023031 lParam:
0007764700

Window: wParam: 0000000001 lParam:
0000000000


By the way, wParam 14 is keyboard combination "ctrl - shift" (we use
it as a hotkey combination).
From: Stephen Quinn on
Gary

> By the way, wParam 14 is keyboard combination "ctrl - shift" (we use
> it as a hotkey combination).

Where are you in your app when using/invoking the 'Ctrl+Shift' to call the
window??
Are you passing in an OWNER (eg SELF)??

If no OWNER then you probably would get a NULL_OBJECT as hWnd would be
empty.

CYA
Steve


From: Mathias on
On 16 Juli, 03:17, "Stephen Quinn" <stevej...(a)bigpondSPAM.net.au>
wrote:
> Gary
>
> > By the way, wParam 14 is keyboard combination "ctrl - shift" (we use
> > it as a hotkey combination).
>
> Where are you in your app when using/invoking the 'Ctrl+Shift' to call the
> window??
> Are you passing in an OWNER (eg SELF)??
>
> If no OWNER then you probably would get a NULL_OBJECT as hWnd would be
> empty.
>
> CYA
> Steve

Maybe if you knew från where dispatch is called? App:Exex or
DoEvents()?

function ListStack() as string
local wActivation := 1 as dword
local functions as string
local pName as psz

functions := ""
while psz("") != ProcName(wActivation)
pName := ProcName(wActivation)
functions += ";" + Psz2String(pname) + "(" +
NTrim(ProcLine(wActivation)) + ")"
++wActivation
enddo

return functions

Mathias
 |  Next  |  Last
Pages: 1 2
Prev: Resource File
Next: Set Ansi or not