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!

Commanding the Command window

Status
Not open for further replies.

vfp4ever

Programmer
Oct 18, 2013
71
East Java
G'day everyone,


in an attempt to automate my VFP IDE start, so that I may find it neat and tidy at all times no matter the video resolution or Windows theme currently in use, I am trying to take some control over the Command window as it opens up in the process.

After dealing with the Program Manager, whose window is a child of the main VFP frame, I have successfully been able to locate the other two 'rebel' windows (Command and Document View), get ther handles, size and position them accordingly at startup (they are actually made of 5 or 6 different windows all layered in parent-child and even sibling levels).

As video resolution and themes are closely related to font names and size, now I am challenged with setting these properties. While most of them are located in the Windows Registry and can be easily read and written, those of the 'rebels' are tucked away in the foxuser.dbf table as binary data (under Type PREFW and Id WINDOWCMD). I am not sure whether it could be possible to mess with that binary data and have the font changed programmatically, so I took a different approach and insisted with Windows API calls. To cut the story short, I managed to send a WM_SETFONT message to the Command window (I can see it through BINDEVENT), the font has been set to my desire (as the function GetTextFace reports) but I still see the old font displayed in the window even after calling UpdateWindow or sending WM_PAINT messages.

Please feel free to make any suggestion on this matter, thank you.


Dario
 
Mike, the Command window is not a problem any more since _EdSetVal works smoothly. Setting the focus on the Project Manager window, switching to a different tab, highlighting the fourth file down the list... it could work for a while, not too long though.

Olaf, I am only looking at Document View and Project Manager windows, as they are what I use most (actually the Document View not too often). You say foxuser.dbf is only read at the start of the IDE and written when you exit, while I see a different behaviour. It's updated every time you close the Document View window from within the IDE.
OK, I understand your suggestion to replace the whole record, yet I do not see why I can't update just two fields if I replace their values with exactly the same stuff, unless there is more involved. And why SYS( 2007 ) does not return what code examples on literature show gets me more and more curious. It's still too early to give it up.

Anyway, thank you both for being so patient and (as always) extremely helpful, your ideas and suggestions are fuel for my weird experiments (not necessarily aimed at something, as when programming is just a hobby).

Regards,
Dario
 
Dario, I get the impression that you are enjoying trying to find a solution to this problem. I can understand that. You can get a lot of satisfaction out of experimenting and evenutally solving a problem. It's good to see you have made progress with this.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
OK, that'Äs all fine, but when you say you want to influence the project manager window, there's nothing better than the interface via the Project object and a project hook class.

So instead of this
Dario said:
Setting the focus on the Project Manager window, switching to a different tab, highlighting the fourth file down the list...

Well, find out what it is via iterating _vfp.activeproject.Files like in:
Code:
For each oFile in _vfp.ActiveProject.Files 
    ? oFile.Name
EndFor

Also, write o=Sys(1270) into the command window, hover with the mouse pointer over a project manager window, and then press ENTER. The o object will be the project of the project manager under the mouse at the moment Sys(1270) was executed. And you can iterate the _vfp.projects to find the one you're interested in via its name, which is the full path of the PJX file.

Bye, Olaf.

Olaf Doschke Software Engineering
 
That is absolutely true, Mike.

Olaf, I do use a ProjectHook to intercept the moment the Editor windows close, so that I can add a timestamp to the file headings. There is only one file in my projects for which I need to temporarily disable the hook (and that's where I defined the ProjectHook subclass, of course).

Now I see why you said VFP updates foxuser.dbf only before starting the IDE and after closing, I can experience that, too, now. So far I was opening and browsing it from the Command window, where it always show updates as I change font during the same IDE session. As I perform the same instructions in code, nothing changes.
 
Well, regarding foxuser.dbf changes, I see both of us right. If I manually change the font of the command window, the records Id="WINDCMD" don't change. Also not, when closing the command window like you close the document view to save its font change.

It doesn't matter much, as you have the command window under control, but it puts up the question which changes cause what when and you now bring up it also can depend whether you change something manually or by code.

The idea to prepare foxuser.dbf before the start in a launcher EXE still would work anyway. You just miss a "Reset Windows" or "Organiue Windowa" option, that goes beyond the "Arrange All" option, which affects window position and sizes and nothing more, besides only works for undockable windows.

So a launcher would only help with the initial situation. It would be enough for me because I can always close and reopen VFP9, even where I maintain projects that start a framework with VFPs IDE start or with every single project. I don't need a restart often.

Bye, Olaf.

Olaf Doschke Software Engineering
 
I'm surprised that nobody has asked why your Windows resolution would change often enough for your to want to do this. When I get a new machine, I play with resolution for a while until I'm comfortable and then I never change it again. Why are you changing yours?

Tamar
 
Tamar, I do not change video resolution or Windows theme as often as you think. If I do at times is because I want to test how my application looks under different "conditions". I might change a form's size, move its controls around or change colours (within the available system palette), and I need to know if everything still looks alright, or instead goes beyond the edge or has poor contrast with the background.

After closing the Control Panel, I launch VFP again and may find those windows moved to the left or partly off the screen, or their fonts being too small, while I would like to find them in my preferred position and aspect.

Regards,
Dario
 
I also see a simple reason to want an extended "Arrange All" that includes more than just arranging windows without overlap. Also the case of corrupt foxuser, command window moved off screen(s), etc.

And indeed, many things could be covered by just storing one good foxuser.dbf as backup of a situation. But then you may also want to keep some other records in it. Mike and I already gave the idea to keep foxuser or records of it for restauration and using a launcher. I already said for me a reset by restart would be sufficient. And Dario has good arguments about some things working from within with the help of foxtools. So why not design such a tool and go as far as you get with it.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top