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

Window position

Status
Not open for further replies.

foxmuldr2

Programmer
May 22, 2012
91
US
1) Go into VFP9, in a temp directory, create a new proj1 project
2) Add a main.prg that simply has "DO FORM frmMain" and "READ EVENTS"
3) Create a form frmMain which is set to auto-center, ShowWindow = 2 (As Top Level Form). You can add labels or input boxes if you like, not required.
4) Add init code to frmMain which is "_vfp.visible = .f."
5) Add unload code to frmMain which is "_vfp.visible = .t." and "CLEAR EVENTS"

Build the project and type "DO PROJ1" from the command window.

You'll note that the form goes to the very back of every other window that's open, and that the window itself does not have keyboard focus.

-----
Does anybody know why this is? Or how to programmatically make it come to the top/front of z-order and have keyboard focus?

Best regards,
Rick C. Hodgin
 
Rick,

This is a very commom problem.

My solution is as follows:

Code:
* Put this in the form's Init
DECLARE INTEGER SetForegroundWindow IN WIN32API INTEGER
SetForegroundWindow(thisform.HWnd)
CLEAR DLLS "SetForegroundWindow"

There might be a better way, but this is the way I've always handled it.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
In my previous post, I didn't intend the code to be double-spaced. In fact, the whole post seemes to have acquired some extra spacing between the paragraphs. Are other people seeing this, or is it something in my browser? Is there anything I should do to avoid it?

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
That did it. I've run into this issue for years and have never taken the time to track it down. Thanks!

Best regards,
Rick C. Hodgin
 
Mike, looks single-spaced to me. However, when I copied and pasted it, I had to manually add line breaks.

One trick I've learned to help fix that is to take the content from the original source, paste it into Notepad or some non-formatting / non-syntax-highlighting form, and then re-copy-to-clipboard again, and then paste into the destination.

Horrible that it's required, but I've noticed it fixes a lot of stuff. Be careful though because some notepad-like apps will add hard carriage returns at margins.

Best regards,
Rick C. Hodgin
317-879-6374
 
I didn't mean to post my phone number. It's habit. :)

Best regards,
Rick C. Hodgin
 
Actually, looking at all the recent threads, I've been seeing double-spacing in the code, and extra spaces between paragraphs.

But it seems to be browser-specific. I usually use Firefox, but when I switch to IE, it looks fine.

I wonder why it's suddenly started to happen.

Oh, well. Never mind. There are more important things to worry about.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Keep in mind that the Tek-Tips forum developers are continuing to work on modifications to the forum and how it works.

As they do 'things' crop up from time to time.
Most are reported quickly and are addressed as soon as they can get to it.

Good Luck,
JRB-Bldr
 
One other suggestion. Rather than using _VFP.Visible = .F., use a Config.FPW file with the line:

SCREEN=OFF

That way, you don't even get a flash of the main VFP window.

Tamar
 
@Rick, yes, I can confirm this.

And with Tamars way of hiding the screen via the SCREEN=OFF option in a config.fpw it works without using the SetForegroundWindow API. So of course I second that. I've never had the problem, perhaps just I did it like that from the start. I wrote a FAQ (my only one, my bad), which is creating a top level form in a very similar way, but using that config.fpw option.

faq184-6512

I had problems getting out the code with firefox, IE and chrome even shows the code area without any linebreaks. Therefore you might instead try my code paste at pastebin: [link pastebin.com/raw.php?i=Pge8hKdg][/url]

Specify the directory, in which the project is generated in the first line and the rest will create the pjx, prg, form and compile the exe.

@Mike: In regard to the forum quirks: Yes, this is really getting worse, since Tek-Tips has changed it's forum editor. And copying out code has been a problem even longer, but at least it worked in some browsers. This time I only got code without any line breaks in each browser I tried. I finally took it from my pc.

Bye, Olaf.
 
Tamars, Olaf,

Thanks for the config.fpw suggestion. :)

Best regards,
Rick C. Hodgin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top