Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: onytoo
  Where is onytoo?
 Padang
 Indonesia
 onytoo
 To: Jijo Pappachan
  Where is Jijo Pappachan?
 Kerala
 India
 Jijo Pappachan
 Tags
Subject: RE: Close button Click API
Thread ID: 310802 Message ID: 310815 # Views: 56 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Win32API programming
Date: Saturday, June 25, 2011 10:27:42 AM         
   


> Hi Experts,
> I have a problem. I have opened one editor window using
>
> Modify command myfilename
> 

>
> for a specific purpose(not for creating prg files. but i want syntax coloring and beautify options and all
> So, memo field is not suitable here).
>
> When I click on close button (X) after making some changes, VFP will show "Save changes" confirmation messagebox.
> What I want to know, is there any way to bind Close button click event of a window and override it?
> I tried to bind WM_CLOSE, WM_QUIT events of that window. But nothing seems to work.
> I have handle of that specified window. Please advice me.
>
> PS: - I have one (dirty) workaround idea,
> 1. get CLOSE (X) button positions(left, top, width, height)
> 2. bind WM_MOUSEDOWN event of that window
> 3. Check whether mouse position is inside X button area.
> Is it good idea, if so, how I will get X button area?
>
> Jijo
> JUST THINK, THERE IS A WAY
> my blog:http://weblogs.foxite.com/jijo_pappachan/


Try this, maybe it work for you

DECLARE LONG GetClassName IN WIN32API LONG, STRING @, LONG
DECLARE LONG FindWindowEx IN WIN32API LONG, LONG, STRING, STRING
DECLARE LONG GetWindowLong IN WIN32API LONG, LONG
DECLARE LONG CallWindowProc IN WIN32API LONG, LONG, LONG, LONG, LONG

#define GWL_WNDPROC (-4)
#define WM_DESTROY  0x0002


lcFile = "test.prg"

MODIFY COMMAND (lcFile) NOWAIT

lcClass = SPACE(255)
lnLength = GetClassName(_VFP.hWnd, @lcClass, 255)
lcClass = LEFT(lcClass, lnLength) + CHR(0)
lhWnd = FindWindowEx(_SCREEN.hWnd, 0, lcClass, lcFile + CHR(0))

IF lhWnd != 0
  loHandler = CREATEOBJECT("CHandler", lhWnd)
  READ EVENTS
ENDIF


DEFINE CLASS CHandler AS Custom
  nOldWndProc = 0
  nHwnd = 0
  
  PROCEDURE Init(thWnd)
    this.nOldWndProc = GetWindowLong(thWnd, GWL_WNDPROC)
    BINDEVENT(thWnd, WM_DESTROY, this, "OnDestroy")
    this.nHwnd = thWnd
  ENDPROC

  PROCEDURE Destroy
    UNBINDEVENTS(this.nhWnd)
  ENDPROC

  PROCEDURE OnDestroy(thWnd, tnMsg, twParam, tlParam)
    LOCAL lnResult
    =MESSAGEBOX("Window destroyed!")
    lnResult = CallWindowProc(this.nOldWndProc, thWnd, tnMsg, twParam, tlParam)
    CLEAR EVENTS
    RETURN lnResult
  ENDPROC
ENDDEFINE


Regards,
Onytoo

ENTIRE THREAD

Close button Click API Posted by Jijo Pappachan @ 6/25/2011 8:27:05 AM
RE: Close button Click API Posted by onytoo @ 6/25/2011 10:27:42 AM
RE: Close button Click API Posted by Jijo Pappachan @ 6/25/2011 10:45:02 AM
RE: Close button Click API Posted by onytoo @ 6/26/2011 3:29:50 AM
RE: Close button Click API Posted by Jijo Pappachan @ 6/27/2011 6:23:18 AM
RE: Close button Click API Posted by onytoo @ 6/27/2011 11:13:28 AM
RE: Close button Click API Posted by Yousfi Benameur @ 6/27/2011 10:21:56 AM
RE: Close button Click API Posted by onytoo @ 6/27/2011 11:17:27 AM
RE: Close button Click API Posted by Yousfi Benameur @ 6/26/2011 1:05:05 AM
RE: Close button Click API Posted by Jijo Pappachan @ 6/27/2011 6:24:25 AM