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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hiding, moving HWnd created window 2

Status
Not open for further replies.

Goofus828

Programmer
Nov 9, 2005
127
US
Hi all,

I found this code on the web:
Code:
DECLARE INTEGER FindWindow IN user32;
	STRING lpClassName, STRING lpWindowName

= WinExec("C:\Program Files\Microsoft Office\Office12\EXCEL.EXE b:\lora.xls", 1)

* find its hwnd
nHwnd = FindWindow(NULL, "Microsoft Excel")

Excel loads fine with that spreadsheet but...

I don't know how to Hide the window, UnHide the window or close the window.

Any help would be appreciated!

Thanks
 
Try this:

Code:
DECLARE INTEGER ShowWindow IN user32; 
    INTEGER hwnd,; 
    INTEGER nCmdShow

ShowWindow(nHwnd, 0)

To hide the window, pass 0 as the second param to ShowWindow. To make it visible again, pass 1.

To close the window, you could try this, but I'm not sure what the implications would be, for example if the application has unsaved edits:

Code:
DECLARE INTEGER DestroyWindow IN user32;
    INTEGER hWnd
DestroyWindow(nHwnd)

Personally, I wouldn't do any of this. I would use Automation if I wanted full control over Excel.

Mike





__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
That's what I was about to say too Mike, I think you would be better off using automation.
Create the Excel object, then you can do whatever you want:

LOCAL oExcel
oExcel = CREATEOBJECT("Excel.Application")
oExcel.VISIBLE = .T. &&... or .F.

... do whatever ...

oExcel.QUIT
oExcel = .NULL.



-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Thanks Guys, appreciate the solutions and the feedback.

The automation route is looking better and better.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top