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!

Move Form 1

Status
Not open for further replies.

Scott24x7

Programmer
Jul 12, 2001
2,826
JP
So in an effort to make the forms I'm working with look more like "Windows 10 style" I removed the topline menu and built one in the form itself to look and feel more like a Windows 10 Experience. But I just noticed that I can't "click and drag" the window now, even though its "moveable" property is set on. Apparently this is somehow tied to the title bar. Is there a way to mimic that? (I'm fine if it goes into some method in the form, but looking at the "MOVE WINDOW" command that seems to be by programmatic activity only.

I set OLEDragMode at the form level to Automatic, but that didn't seem to do it.
Is there a workaround here? Or am I just missing something simple?


Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Scott, you can't do this natively in VFP. You might think you could do it using the form's MouseMove event (when a mouse button is pressed, as revealed by the first parameter), but the Help warns against trying to move the form from within the MouseMove, as it can "cause cascading events and generate run-time errors, such as a stack overflow".

Nor can you do it via drag and drop, as there would be nowhere to trigger the OLEDragDrop event.

However, you can do it with API calls. Sergey Berezniker can explain that sort of thing much better than I can, so see this article:
Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike,
That was a brilliant solution! So glad I asked, because I was trying all kinds of things with the OLE methods and events, and as you mention, none of them worked. This was so elegantly simple... Drop a couple lines in the LOAD event of the form class:

Code:
DECLARE Long ReleaseCapture IN WIN32API
DECLARE Long SendMessage IN WIN32API ;
	Long HWND, Long wMsg, Long wParam, Long Lparam

And then a few others in the MouseDown event
Code:
LPARAMETERS nButton, nShift, nXCoord, nYCoord
#DEFINE WM_SYSCOMMAND 0x112
#DEFINE WM_LBUTTONUP 0x202
#DEFINE MOUSE_MOVE 0xf012
 
IF nButton = 1 		&& LMB
	= ReleaseCapture()
	* Complete left click by sending 'left button up' message
	= SendMessage(Thisform.HWnd, WM_LBUTTONUP, 0x0, 0x0)
	* Initiate Window Move
	= SendMessage(Thisform.HWnd, WM_SYSCOMMAND, MOUSE_MOVE, 0x0)
ENDIF

And since I do have a big text object at the top of the form (which won't trigger the event) I added this to the MouseDown of the label object's MouseDown:
ThisForm.MouseDown(nButton, nShift, nXCoord, nYCoord)

So that provides the entire solution, all applied at the form's base class (even the label object is included at the form), and all the forms work now. Great stuff!

Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Mike, as they say "Knowing is half the battle". So I still give you the star. :)

Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
In the end the credit goes to MS to provide the API. Sergey points to a KB article and I know it from
Also see thread184-1692547

I rather wonder about the whole idea, as VFP form titlebars and controls always were and are drawn in Windows themes styling (unless you turn that off), I see no need to emulate anything, even though as mentioned in that thread, you're not the only one, even MS Zune UI is non standard. And the gdiplusx project has given us lots of possibilities and improvements.

Notice: Looking back. the aero style borders of Vista weren't drawn when you started or designed forms within the VFP9 IDE, but in the final EXE they appeared with the glass style borders, that may now be the case with Windows 10 flat styles, too. Compile and run a standard form and then see what you need or want to modify from there, you might develop something you don't really need.

Bye, Olaf.

Edit: The news2news sample once was free and used the same Windows messages to move a form in the titlebar section of the canvas.
 
Well, the interface has changed a lot. Yes, you could allow a general "Windows 10" default title bar, but that doesn't really resemble modern applications. Take Office for example. Have a look at Office 2013 or 2016 top line.

Here is an example of the topline I've built this week, and why I needed the "move" work around:

TitleBarExample_ciyxnh.jpg


Note that I put the mouse on the far right corner to show the Close Button change. All of the top line buttons have similar highlighting, though the color is different, in line with Win10.
The main thing is, the upper left. You have 0 control over icons and their availability in the upper left of a title bar. The "Hamburger Icon" in this case opens from left-to-right "animation" is is popular (see Windows Calculator for example) and has different features. Today I added a small 10 pixel wide bar that runs the entire left length of the form which when clicked, brings out a small "Instruction" Window (animated in the same form as the hamburger menu). This allows the users to always know where some explanation of how the screen overall functions, without the need to build extensive help systems that are external to the form. They of course can have their text linked to a "Help" database, which I haven't built yet, but probably will, then easy to dynamically link & filter to form names... I could even create a "notes" section in that case to allow users to enter their own "reminders" on forms instead of having little post-it's stuck everywhere. Because granted, we like to make functionality as simple and useable as possible, but sometimes things are complicated, and different users have different skill sets. So I think this would be an interesting addition to user interface. But I'll have to work that out later this week.


Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Such feature don't depend on being located in the title bar, but here we talk about taste. The Icon of the titlebar is simply set with Form.Icon, and the solution app comes with samples drawing on the title bar, too. Anyway, replacing it with something in the form canvas and turning the normal titlebar off is giving you full control.

I don't find applications good style, that bring newest OS looks back to earlier OS versions. And in 5-10 years, if your app is still used, it might look outdated because of still being Win10 style. That's the downsides I see in such skinning.

Bye, Olaf.
 
Olaf,
Yeah, there are trade-offs. But I'm not just replacing the window Icon, what you see under the left hamburger icon are none of the "old windows" items (It basically has move, resize, minimize, maximize, restore, to be honest functions I never ever ever use from there). Modernizing this part I think is not going to revert back to that old-school thinking, especially as touch becomes more prevalent, and one thing I'm wanting to ensure is that this application is very touch-friendly. It will be utilized almost every day in a data collection environment where the touch aspects will speed the work considerably. So having those functions on the upper left of the menu is not going to be of any use.

And... even if I have to do a redesign to look and feel in 5 - 10 years time, I'm ok with that too... I would rather show we have an active application that evolves with the times. And those kinds of changes do not typically take months, rather days to revise. I accept that "risk". I know these trends do change, and cycle back and the like, but the idea of the outdated title bar, I don't ever see coming back...

Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Well, I'm mostly only concerend about the look and I'm conservative.

In rehard to touch interface Windows 10 has its ways to react to device type or mode changes, especially when a device is convertable, so I'd rather count on that evolving on its own by MS and only consider touch friendly interfaces within my area of concern, the inner form canvas. For example consider full screen mode. Your form in Full screen mode would have a title bar, though it should not be draggable in that mode, and it's even the typical mobile mode.

You can put such a hamburger menu inside the form, it's only a difference of a few pixels lower, you don't need your own titlebar for it. Then it's clearly part of the form and not the titlebar, yes, but the concept of a header area inside the form is well known from any browsers. The title bar is OS related, not application related.

Also some thoughts against the Hamburger menu:
Bye, Olaf.
 
Have a look at the MS product suite... Word, Excel, Access, PowerPoint... are all using the style I'm applying here.
And yes, things like Calculator have the hamburger menu under the title bar... and Office doesn't use that menu style at all.
I still think it looks "Fresher" (for lack of a better term) than the standard look & feel of VFP and OS Title bars...

But yes, all of these things have their merits and their draw backs. From a development style, this "clean" style is actually a lot easier to apply (I find). And I'm happy to trade "characters and glyphs" for picture icons... Makes dealing with transparent image backs obsolete.

Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Oh, that article was quite interesting, but it applied entirely to hand-held mobile devices (and not larger screens like iPad or Surface). Even in my case, I have wanted to implement the more modern style as an ADDITION not a replacement for the other UI components I have, which adds to usability in touch devices. I've been holding out for months now for MS to release the Surface Pro 4. The expected announcement is days away. It was about a month ago I shifted the development philosophy on my UI in anticipation of moving to the Surface (as will our staff). It was at that point I decided to break away from the 1024x768 screen size as well in favor of a more modern canvas, and moved the development to 1600x1200 as the base screen size. I hope to never have to go back to cramped little screens again for anything that I need to spend more than 15 minutes with. (I don't write long messages on mobile phones, nor watch streaming video on them either). Maybe I'm not a typical user in that regard, but I rather think "Use the right tool for the job". Just because I can hammer a screw in doesn't mean I should do that... just like sure, I can write a 300 page novel on a BlackBerry (reference intended) but it doesn't mean I SHOULD or that I will be as efficient in writing it vs. even paper and pen. I find it surprising how many people are ready to throw out all the old tools just because a new one comes along, that may not be as suited to every job.


Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Well, for the third time: You can do all your things inside the form, anything you want. Why insist on bringing this to your own custom title bar?
You can do whatever you like to do in the head region of your form, too.

Title bars of any form are - somewhat boring - part of a window, that is maintained by the OS and allows you to handle the outset, eg putting two, three or four applications side by side, maximising them or whatever. Taking control of it may add further features and enrich the user experience, but you can do it in your own part of the window(s).

I'll just point that out once more, so it doesn't get buried in the discussion about modern menu styles or not.

Bye, Olaf.
 
Your points are well taken Olaf.
The great variation limited only by our imagination is what makes this all so interesting.

Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top