Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Samir H.
  Where is Samir H.?
 Yogyakarta
 Indonesia
 Samir H.
 To: onytoo
  Where is onytoo?
 Padang
 Indonesia
 onytoo
 Tags
Subject: RE: Form with showWindow 0 and 2?
Thread ID: 310856 Message ID: 310898 # Views: 33 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Forms
Date: Monday, June 27, 2011 5:59:20 AM         
   


> > Hi
> > I have a form (a scx run with DO FORM, not createobject()) that I run as a usual form in my app, with showWindow=0 (in Screen).
> >
> > Now, I must also run this form as a "separate app" for guests who do not have access rights to any other function of my application. They are only allowed to run this single form.
> > In this case the form must run as showWindow=2 because the screen, the menu and all other application facilities must not be accessible to the user.
> >
> > Since the "ShowWindow" property is readonly at runtime, I had to set it to 2 (top level) for both cases, but I would like to keep it 0 (InScreen) when the form is run from within my application, and have it set to TopLevel when a guest uses the form.
> >
> > Is there any trick to change ShowWindow at runtime?
> >
> >
> > Regards
> > Samir
>
>
> Basically, a top level form is have no parent or the parent is windows desktop.
> With a little trick, we can turn a child form into desktop form
> (tested with win7, in winxp should work well)
>
>
> *!* form init
> LPARAMETERS tlTopLevel
> this.AddProperty("lTopLevel", tlTopLevel)
> IF tlTopLevel
>   DECLARE LONG SetParent IN WIN32API AS API_SetParent LONG, LONG
>   DECLARE LONG ShowWindow IN WIN32API AS API_ShowWindow LONG, LONG
>   DECLARE LONG BringWindowToTop IN WIN32API AS API_BringWindowToTop LONG
>   *!* hide screen and remove from taskbar,
>   *!* do not use _SCREEN.Visible !!!
>   #define SW_HIDE 0
>   API_ShowWindow(_VFP.hWnd, SW_HIDE)
>   *!* set form parent to desktop
>   API_SetParent(this.HWnd, 0)
>   *!* activate form
>   API_BringWindowToTop(this.HWnd)
> ENDIF
> 
> *!* form.destroy
> IF this.lTopLevel
>   #define SW_SHOWNORMAL    1
>   #define SW_SHOWMINIMIZED 2
>   #define SW_SHOWMAXIMIZED 3
>   API_ShowWindow(_VFP.hWnd, SW_SHOWMAXIMIZED)
> ENDIF
> 

>
>
> Regards,
> Onytoo

Hello Ony
It almost works on usual forms, it seems the only problem is that the form is "AlwaysOnBottom", see picture.
In my case, I have a browser control on the form, and there I can only see some buttons (custom buttons made from image controls). Everything else is invisible, the browser, containers, commandbuttons and the form itself. Only the mentioned small png images are visible.
I guess that the problem with AlwaysOnBottom can be corrected, but please don't bother. I will most probably not use this solution because of the browser control in my form.
But thank you anyway.



Regards
Samir

ENTIRE THREAD

Form with showWindow 0 and 2? Posted by Samir H. @ 6/26/2011 6:18:42 AM
RE: Form with showWindow 0 and 2? Posted by Anil Sharma @ 6/26/2011 8:31:30 AM
RE: Form with showWindow 0 and 2? Posted by tushar @ 6/26/2011 9:25:22 AM
RE: Form with showWindow 0 and 2? Posted by Samir H. @ 6/26/2011 10:55:54 AM
RE: Form with showWindow 0 and 2? Posted by Yousfi Benameur @ 6/26/2011 12:50:14 PM
RE: Form with showWindow 0 and 2? Posted by Samir H. @ 6/26/2011 1:31:27 PM
RE: Form with showWindow 0 and 2? Posted by onytoo @ 6/26/2011 11:01:28 PM
RE: Form with showWindow 0 and 2? Posted by Samir H. @ 6/27/2011 5:59:20 AM