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

How to keep minbutton and close button on my form ?

Status
Not open for further replies.

Johnweida

MIS
Apr 29, 2003
91
CN
experts,

I set the "controlbox" property to .F. but I want to keep the MinButton and close button on the right-up corner of the form. How can I do it ? Thank you for your help.

John Satellite

 
Hi

Set the
myForm.ControlBox = .t.
myForm.MinButton = .t.
myForm.MaxButton = .f.
myForm.Closable = .t.

:)

____________________________________________
ramani - (Subramanian.G) :)
When you ask VFP questions, please add VFP version.
 
ramani,

Thanks for your help.But the problem is that I must set the "Controlbox" property to .F. and the MinButton property to .T.
How can I do that ?

John Satellite
 
John

Thanks for your help.But the problem is that I must set the "Controlbox" property to .F. and the MinButton property to .T.

Since the Controlbox = .f. seems to remove the min and max and "X". No to answer no.
Why do you need the Controlbox to .f. ?


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
John,

This code below should give you some idea of what you are butting up against here. Windows just doesn't work that way, even natively using API calls. You ultimately will need to draw your own MIN and CLOSE buttons if you want to do this...getting rid of the MAX button from between them is not a trivial thing...now if you just wanted to disable the max button and have the controlbox = .f. that may in fact be possible...maybe i say.

DECLARE INTEGER SetWindowLong IN user32;
INTEGER HWND,;
INTEGER nIndex,;
INTEGER dwNewLong

DECLARE INTEGER GetSystemMenu IN user32;
INTEGER hWnd,;
INTEGER bRevert


#DEFINE GWL_STYLE -16
#DEFINE WS_MINIMIZEBOX 0x20000
#DEFINE WS_MAXIMIZEBOX 0x10000

lnhwnd = thisform.hwnd
CurrentStyle = GetWindowLong(lnhwnd, GWL_STYLE)

*!* Both min and max must be removed before they actually disappear
*!* otherwise buttons are just disabled individually but still shown
CurrentStyle = BITAND(CurrentStyle, BITNOT(WS_MINIMIZEBOX))
CurrentStyle = BITAND(CurrentStyle, BITNOT(WS_MAXIMIZEBOX))

*!* code similar to this commented out stuff is used to turn on the buttons
*!* CurrentStyle = BITOR(CurrentStyle, WS_MINIMIZEBOX)
*!* CurrentStyle = BITOR(CurrentStyle, WS_MINIMIZEBOX)

X = SetWindowLong(THISFORM.HWND, GWL_STYLE, CurrentStyle)

*!* just a quick hack to refresh controlbox
thisform.controlbox = .f.
thisform.controlbox = .t.


Slighthaze = NULL
craig1442@mchsi.com
"Whom computers would destroy, they must first drive mad." - Anon​
 
HI

Probably, you can provide an alternate way..

Let us say... by Double Click on the form, minimize that, and double click on the titlebar of the minimized form, it restores the position. If this is OK to you, then
Put in the Forms DoubleClick event
ThisForm.WindowState = 1

:)



____________________________________________
ramani - (Subramanian.G) :)
When you ask VFP questions, please add VFP version.
 
Mike,

This is the reason I have to need the controlbox = .F.

Public oform1
oform1=createobject("form1")
oform1.Show
Return
******************************************************
Define Class form1 As Form
DoCreate = .T.
Caption = "My Form"
****** cannot define icon in a class("syspath" is a public variable define in my main prg)
Icon = "&syspath\ico\abc.ico"
************************************
Name = "Form1"
AutoCenter = .T.
ShowWindow = 2
WindowState = 2
enddefine

RE:slighthaze

Error message:
"File GetWindowLong.prg does not exist"

Re:ramani

Thank you. I'll try it.

John Satellite

 
John,

The error in my code is because i inadvertantly removed the DECLARE statement for the GetWindowLong API function call before posting it (was trying some other stuff and then at the last minute tried to put it back the way it was). Place the following right below the other 2 declares and it will work. Sorry about that.

DECLARE INTEGER GetWindowLong IN user32;
INTEGER hWnd, INTEGER nIndex


As for your reason to Mike for needing the controlbox = .F., I am not sure I understand. I have looked at your code and still cannot figure out the reason. Am I missing something?

Slighthaze = NULL
craig1442@mchsi.com
"Whom computers would destroy, they must first drive mad." - Anon​
 
Dear slighthaze,

Actually I built a About me form, I wanted to remove the controlbox. But now I understand that is probably impossible for VFP users. Thanks for the help all of you give to me.

John Satellite
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top