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

How to remove vfp main window? i ha

Status
Not open for further replies.

Mandy_crw

Programmer
Jul 23, 2020
585
PH
How to remove vfp main window? i have used _screen and configured config file, but still vfp main window is still showing. Thanks and God Bless.
 
From within your program, you can do: [tt]_SCREEN.visible = .F.[/tt]

If you are working in the development environment, be sure to do [tt]_SCREEN.visible = .T.[/tt] at the appropriate time to restore the screen.

Using the above method, the window will still appear for a very short time, between the program loading and the execution of the above command. If you wan't to avoid that, put SCREEN = OFF in your config.fpw file.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
thanks so much mike... it is still showing the main window of the vfp even if i put the _screen.visible = .f.

PROCEDURE Init

SET TALK OFF
SET BELL OFF
SET CENTURY ON
SET CONFIRM OFF
SET SAFETY OFF
SET ECHO off

_screen.VISIBLE = .F.

SELECT 3
USE smsrec exclusive ALIAS rek

SELECT 2
USE payments exclusive ALIAS pay
INDEX on idnum TO pidnumx

SELECT 1
USE sms exclusive ALIAS tsulat
INDEX on idnum TO idnumx

SET relation TO idnum INTO pay

 
This is the code mike.... thanks...

LOCAL oForm as Form

oForm = CREATEOBJECT("FormSMS")
oForm.Show(1)

RETURN

DEFINE CLASS FormSMS AS form
DataSession = 2
Height = 440
Width =526
BorderStyle=2
maxbutton =.f.
AutoCenter = .t.
alwaysontop = .t.
Caption = "Waver"

ADD OBJECT sms as mysms WITH Visible = .f.

ADD OBJECT pageframe1 as mypageframe1

ADD OBJECT label6 AS myLabel WITH ;
FontBold = .T., ;
FontSize = 16, ;
Caption = "Please tap you RF-id!", ;
Height = 22, ;
Left = 260, ;
fontname = "BRITANNIC BOLD",;
Top = 138, ;
Visible = .F., ;
Width = 518, ;
ForeColor = RGB(0,128,128)

ADD OBJECT image1 AS image WITH ;
Picture = "C:\Program Files\Wave\Img\online.jpg", ;
Stretch = 2, ;
Height = 30, ;
Left = 10, ;
Top = 407, ;
borderstyle = 0,;
Width = 60, ;
visible = .f.
Name = "Image1"

ADD OBJECT image2 AS image WITH ;
Picture = "C:\Program Files\Wave\Img\RFID_2.png", ;
Stretch = 2, ;
Height = 60, ;
Left = 22, ;
Top = 310, ;
borderstyle = 0,;
Width = 80, ;
visible = .f.
Name = "Image2"

ADD OBJECT label7 AS myLabel WITH ;
FontBold = .T., ;
Caption = " ", ;
Height = 17, ;
Left = 150, ;
Top = 99, ;
Width = 454, ;
ForeColor = RGB(0,128,128)

ADD OBJECT edit1 AS editbox WITH ;
FontSize = 7, ;
Height = 1, ;
Left = 3, ;
ReadOnly = .T., ;
Top = 110, ;
Width = 521

ADD OBJECT edit2 AS editbox WITH ;
FontSize = 7, ;
Height = 58, ;
Left = 220, ;
ReadOnly = .T., ;
Top = 119, ;
Width = 300,;
caption = "cahrot"

ADD OBJECT command1 AS commandbutton WITH ;
Top = 125, ;
Left = 40, ;
Height = 30, ;
fontSIZE = 12,;
fontname = "elephant",;
Width = 150, ;
forecolor = RGB(0,128,128),;
Caption = "Connect"

ADD OBJECT text1 AS textbox WITH ;
Height = 23, ;
InputMask = "#", ;
Left = 133, ;
Top = 124, ;
Width = 30,;
visible = .f.,;
readonly = .t.

ADD OBJECT text2 AS textbox WITH ;
Height = 23, ;
Left = 133, ;
Top = 150, ;
Width = 87,;
visible = .f.,;
readonly = .t.

* --------------------------------------------------------------------------

PROCEDURE Init

SET TALK OFF
SET BELL OFF
SET CENTURY ON
SET CONFIRM OFF
SET SAFETY OFF
SET ECHO off

_screen.VISIBLE = .F.

SELECT 3
USE smsrec exclusive ALIAS rek

SELECT 2
USE payments exclusive ALIAS pay
INDEX on idnum TO pidnumx

SELECT 1
USE sms exclusive ALIAS tsulat
INDEX on idnum TO idnumx

SET relation TO idnum INTO pay

ENDPROC
 
Mandy,

For your code to work, the form needs to be a top-level form, that is, you need to set its ShowWindow property to 2.

[tt]_SCREEN.visible = .F.[/tt] won't work in a normal form (where ShowWindow = 0) because that would also hide the form itself, which is presumably not what you want.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I seem not to understand well mike.... is this the one?

(excerpt)
LOCAL oForm as Form

oForm = CREATEOBJECT("FormSMS")
oForm.Show(1)

RETURN

DEFINE CLASS FormSMS AS form
DataSession = 2

showwindow = 2

Height = 440
Width =526
BorderStyle=2
maxbutton =.f.
AutoCenter = .t.
alwaysontop = .t.
Caption = "Waver"

PROCEDURE Init

_screen.VISIBLE = .F.

this how i have done it... but it did not work....

Thanks in advance mike....
 
Dear Tom, Mike & everyone,
I still dont get it on how to hide the main vfp window, i've tried what you have told me and tried to research also, but i still didnt get it... please help me.... thanks in advance... God bless!


EXCERPTS...

LOCAL oForm as Form

oForm = CREATEOBJECT("FormSMS")
oForm.Show(1)

RETURN

DEFINE CLASS FormSMS AS form
DataSession = 2
Height = 440
Width =526
BorderStyle=2
Maxbutton =.f.
Autocenter = .t.
Alwaysontop = .t.
Caption = "SCMS Total Waver"

ADD OBJECT sms as mysms WITH Visible = .f.

ADD OBJECT pageframe1 as mypageframe1

ADD OBJECT label5 AS myLabel WITH ;
FontBold = .T., ;
FontSize = 8, ;
Caption = "Click CONNECT button to activate!", ;
Height = 22, ;
Left = 25, ;
Top = 157, ;
Visible = .t., ;
Width = 518, ;
forecolor = RGB(0,128,128)

ADD OBJECT label6 AS myLabel WITH ;
FontBold = .T., ;
FontSize = 16, ;
Caption = "Please tap you RF-id!", ;
Height = 22, ;
Left = 260, ;
fontname = "BRITANNIC BOLD",;
Top = 138, ;
Visible = .F., ;
Width = 518, ;
ForeColor = RGB(0,128,128)

* --------------------------------------------------------------------------

PROCEDURE Init

_screen.height = 445
_screen.width = 532

_screen.borderstyle = 2

_screen.left = (sysmetric(1) - _screen.width) /2
_screen.top = (sysmetric(2) - _screen.height) /2

_screen.backcolor = rgb(0,0,0) && black

thisform.edit2.Value = "This application is design to run in any operating system."+;
"You may use it for attendance sender,or send Group "+;
"Messages with limited number of characters to 160. "+;
"Please contact Mr. Oscar V. Fontelera Jr. for details. 0918-930-4976"+CHR(013)+CHR(013)+;
"God speed!"

THISFORM.text1.VALUE = THISFORM.sms.CommPort
THISFORM.text2.VALUE = THISFORM.sms.settings

ENDPROC
 
Mandy, can you please post the minimum code that will enable us to reproduce the problem. When I say "minimum", you should leave out anything that is irrelevant, such as the height and width of the form, the presence of textboxes and labels, and so on.

With the latest code you posted, it is not possible to reproduce the problem, as it contains references to classes that are not defined in the code. Also there is nothing in the code you posted that will hide the window. I can see that it will resize the window, move it to the centre of the screen, and turn it black, but after doing that, it will still be visible.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mandy,

Here is some very simple code that will launch a form and make the VFP window invisible. This is just to show you the basic idea and to prove that it works. You can use it a model for your own form.

Code:
LOCAL loForm

loForm = CREATEOBJECT("FormSMS")

loForm.Show()   && modeless (top-level form can't be modal)
READ EVENTS
 _screen.visible = .T. 
 
DEFINE CLASS FormSMS AS Form
  ShowWindow = 2    && top-level form
  PROCEDURE Init
     _screen.visible = .f.
  ENDPROC 
  
  ADD OBJECT cmdClose AS CloseButton
    
ENDDEFINE  

DEFINE CLASS CloseButton as CommandButton 
PROCEDURE Click
  CLEAR EVENTS

ENDDEFINE

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi Mandy,

this is some minimalistic sample code about how your startup prg should look like:
Code:
* // should be placed in config.fpw. that way NO _screen flashing will happen
* // however, within this demo and in designmode its enough to place it at the
* // beginning of you startup programm
_screen.Visible = .F.

* // now, we instantiate a class based form that is already prepared to live
* // without _screen and can exist as TopLevelForm
SET CLASSLIB TO clbForms
oMasterForm = CREATEOBJECT( [frmMasterform] )
oMasterForm.Visible = .T.
READ EVENTS

* // in case we are in designmode, it is good to make the _screen visible again. 
* // otherwise you will have to end the VFP process via taskmanager!!!!
IF _VFP.StartMode = 0
	_Screen.Visible = .T.
ENDIF

Now we need a form that can hold other subforms and live outside/without _screen.
Therefore you set the following form props as listed:
Code:
Desktop: .T.
ShowWindow: 2-AsTopLevelForm
WindowType: 0-Modeless  (As we have a READ EVENTS in the starting prg)

In the forms RELEASE method you place
Code:
CLEAR EVENTS

and that's it.

Don't...really DON'T do a CLEAR EVENTS in some ButtonClick event. The CLEAR EVENTS can be placed in .RELEASE or .UNLOAD or maybe .DESTROY but not into button.click.
You might ask, why you shouldn't do something like that. Thats really easy. VFP will stop any kind of code execution within your form and jump back to the start prgs READ EVENTS. Therefore, your form never gets the chance to close itself properly. So Mike did this for demo purposes only!!!
A better way instead of doing a CLEAR EVENTS within a button.blick is something like this:
Code:
* // Code in Form.INIT
BINDEVENT( Thisform.cmdClose , [Click] , Thisform , [Release] )

* // Code in Form.RELEASE
UNBINDEVENTS( Thisform.cmdClose , [Click] , Thisform , [Release] )
CLEAR EVENTS

A zipped version of the project, the starting prg and the form class is attached ;)

HTH

-Tom
 
Tom, you are correct re CLEAR EVENTS. It occurred to me just after I posted my code that the command button wasn't needed and the CLEAR EVENTS could have gone in the form's Destroy event. That has the advantage that it will fire whatever method is used to close the form.

But I'm not sure about putting it in the Release (because Release is a method, not an event). Let me experiment.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mandy,

There is a lot to say about your procedure file (8th nov 20:01) as posted here. I wonder, you are using VFP9SP2 (Visual FoPro SP2) and you donot use the visual aspects of this fine program.
The fact that one can also produce a procedure file to make a VFP application does not mean that you should do that to do that, it is easy to show others what your code is for an object but absolutely not advisible to use to construct an application.
My first comment on your procedure file:
the enddefine is missing, thus it will error when you run this: NESTING ERROR
ADD OBJECT sms as mysms WITH Visible = .f. line will error since the mySMS is not defined
ADD OBJECT pageframe1 as mypageframe1 will error since myPageframe1 is not defined
ADD OBJECT label6 AS myLabel WITH ; will error since myLabel is not found
a.s.o.
Please study the concepts of Visual FoxPro first and when you are able to produce a form with some objects, labels a.s.o. the next step will be change the forma to a toplevel form as Mike showed you in the code above.

Stay healthy,
Koen
 
Dear Tom, Mike and Koen....

thank you so much, i'll study all given samples and tips... sorry for i lack knowledge about vfp 9, still i am stucked with foxbase programming, and im trying to adapt to vfp 9. Im glad you are all here to help me... keep helping guys... God bless!
 
Mandy,
My advise for newbie's which switch from FoxBase to VFP9SP2:
A very good book to study, it also comes, which is extremely handy, with source code. The book by Andy Kramek c.s. published by Henzewerke, unfortunately they don't offer hardcopy anymore, but you can buy the elctronic version: Look for "1001 Things you wanted to know about Visual FoxPro" The book is written for Version VFP7 but still very handy also for the latest VFP9SP2
Stay healthy,
Koen
 
Mike and Tom & e everyone i really appreciate your help... i got rid of the main vfp window now... its no longer showing and my project is working according to what i want and what i needed. Thank you so much....God bless!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top