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!

Problem Caption On Title Bar

Status
Not open for further replies.

ariswan2007

Programmer
Jul 26, 2019
9
ID
Dear Team,
I want to create a form using the windowstate=2 property. Please explain why the caption in the title bar disappears on the form when it is run. What is the solution to keep the caption active using mode widowstate=2. Thank you for your help.

The code as below :
PUBLIC oForm
oForm=CREATEOBJECT([MyForm])
oForm.Visible=.T.

DEFINE CLASS MyForm AS Form
BorderStyle=3
showWindow=2
TitleBar=1
Caption ="EMPLOYEE MASTER"
desktop=1
WINDOWSTATE=2
ENDDEFINE
RETURN

 
 
Mike Lewis said:
There is nothing in the code you posted to prevent the caption from appearing.

Mike, when I run the Code, a Form is opened "Full Screen Size" with no Caption. When I hit "Restore Down" Button the Screen reduces in size and the Caption is displayed.

Regards,

David.

Recreational user of VFP.
 
David,

I'm not seeing the same as you. I see the full-size (maximised) form, but with the title bar and caption ("EMPLOYEE MASTER") completely visible.

You mentioned the "Restore Down" button. If that is the button in the top-right of the form, between the Close and Minimise buttons, then that means that your title bar is visible (as expected). So you are seeing the title bar without any text in it. Is that correct?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike Lewis said:
You mentioned the "Restore Down" button. If that is the button in the top-right of the form, between the Close and Minimise buttons, then that means that your title bar is visible (as expected). So you are seeing the title bar without any text in it. Is that correct?

Yes Mike, the Maximised Screen does not display the Caption although the Title Bar is displayed. The Caption is displayed when the button in the top-right of the form, between the Close and Minimise buttons is pressed.

EDIT - If I click on my other (Second Monitor) the "Caption" is displayed on the VFP Screen.
Regards,

David.

Recreational user of VFP.
 
That's very strange. I can't see any reason for the title bar to appear but without the caption. I've never seen that before.

David and Ariswan, are you seeing this behaviour in any other VFP forms? What about forms in other applications? What happens if you set the WindowState to 0 or 1; does that makes any difference? Does the caption appear as a property of the form object if you run the form in the debugger?

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike Lewis said:
What happens if you set the WindowState to 0 or 1; does that makes any difference?

Caption is displayed in WindowState set to 0 or 1. Form is reduced in size.

Regards,

David.

Recreational user of VFP.
 
So it is only in top-level forms that the problem occurs. Sorry, I still can't suggest anything. I thought it might be something to do with the screen resolution, or perhaps with the positioning of the form in some way. That might have been plausible if the entire title bar was invisible, but it wouldn't explain the title bar appearing without the caption.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike and David
I am seeing the same issue as David sees. Windows 10 (1903) VFP9 SP2 (7423)
On a side note the same code works correctly with VFPA (VFP advanced 32 bit)


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



If you want to get the best response to a question, please check out FAQ184-2483 first.
 
I see the problem, too, on Windows 10.

It reminds me of the problems we had in VFP Forms with the way Vista Aero changed some rules. And Calvin Hsia's fix for that with the DoCreate property:

Arisswan2007,

unfortunately, the DoCreate hack won't fix your problem. I also checked whether the problem disappears when creating a visual form (SCX) and when compiling as an EXE, but it doesn't.
What also seems strange is that the titlebar doesn't get painted white as a usual top level form titlebar on Windows 10 is.

A straight forward way out seems to be to set the caption in the Paint event:
Code:
Public oForm
oForm=Createobject([MyForm])
oForm.Show()

Define Class MyForm As Form
   ShowWindow = 2
   Desktop = .T.
   WindowState =2

   Procedure Paint()
      This.Caption = "EMPLOYEE MASTER"
   Endproc
Enddefine

There are some other things I straightened:
a) no need to set properties to a value, that's their default anyway, BorderStyle=3 is default
b) Desktop isn't a property that switches between 0 and 1, it's .T. or .F., respectively.
Titlebar is the only property that is strange from the VFP perspective.
c) You call the form's Show(), you don't set Form.Visible = .T.

All this is no problem when you don't set the WindowState to maximized, so it seems to be related to that. A form starting as maximized isn't painted correctly.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Thank you for the response...
The code from Olaf answers this problem.
I have tried through the code screen (.prg) and form (scx), and the caption can be displayed in the title bar.

Regards

CODE :
Public oForm
oForm=Createobject([MyForm])
oForm.Show()

Define Class MyForm As Form
ShowWindow = 2
Desktop = .T.
WindowState =2

[highlight #FCE94F] Procedure Paint()
This.Caption = "EMPLOYEE MASTER"
Endproc

[/highlight]Enddefine
 
You might want to organize this differently when you plan to add info to the titlebar caption, eg the name of an employee picked from a list after the form has started. Because Paint() is an event that doesn't just run once at the initialization. I first tried Load() and Init(), but they don't work. Activate(), too, and it also runs more than once, if a user switches between forms.

Now, as you reposted the code with the marked change, I think you want to help future developers to find the solution fast. The feature used for that here on Tek-Tips is marking the answering post with a start ("Great post").

And, by the way, I see all the discussion about @CLASS in your first post to Tek-Tips drowned to welcome you.


While the @CLASS behavior was unfortunate, that was by design. This time you actually found a new bug, if only a minor one. So far I only had legacy Windows theme style within the IDE. After building and running an EXE, the current Windows-style applies. The difference is it involves the VFP9r.DLL and English resource DLL instead of the VFP9.exe. Maybe it's within my layout settings. But I guess that'll come up more often and should get a better workaround than that to cope with changing captions.

Bye, Olaf.


Olaf Doschke Software Engineering
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top