Odd behavior - SWT Browser on Mac OS X - macos

This is a strange behavior, and hard to explain without a picture, so I will try my best.
My application has an embedded SWT browser widget, and the application is cross platform. It works perfect on Windows, but need to support Mac OS X 10.4 and above. The browser widget is within a composite on the right side, and a file tree within another composite is on the left side. The user clicks files from the tree, and they are in turn decrypted and displayed in the browser.
I am testing the app on Mac 10.4.11 currently and this strange behavior happens only when I resize the shell window. The composite and browser widget itself resize properly. I can see the bounds/border of the objects. The problem is the image that is supposed to be within the browser - shifts (almost as if the displayed image is not anchored to the top left corner of the browser). It is aligned top to bottom, and the image itself is the correct size, but the image moves after the resize is done. The app looks fine (meaning the image is aligned perfect) when it initially loads, looks fine when the file tree is hidden and the browser/composite take up the full shell, looks fine when the file tree is restored. It only during resize that this happens.
I hope that made some sense. Any ideas?

Ok i figured it out. Here is what I had at first (in pseudo-code):
webBrowser.setSize(shell.width, shell.height);
webComposite.getParent().layout();
Turns out i needed to pretty much restore the browser and its composite in the same way i did when i restored the file tree (cause i knew it was correctly sized after that action). The code above was replaced with:
webComposite.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true));
webComposite.setBounds(widthOfTreeComposite, 0, shell.width, shell.height);
webComposite.setSize(shell.width, shell.height);
webBrowser.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true));
webBrowser.setBounds(0, 0, shell.width, shell.height);

Related

PrintWindow and Microsoft Edge

we have a problem with the PrintWindow function on Windows 10 (build 10166). When we call PrintWindow (https://msdn.microsoft.com/ru-ru/library/windows/desktop/dd162869(v=vs.85).aspx) to capture a image of the Microsoft Edge (Project Spartan) browser window we get a black image.
Does anyone know the reason of this and how could it be fixed/avoided? Or maybe some other way to capture image of a window, that can be in background and hided behind another windows?
UPDATE: We've tried sending WM_PRINTCLIENT and WM_PRINT messages, and calling DefWindowProc with WM_PRINT, but results are the same - just a black image. We also tried to use BitBlt to copy window's DC to a memory surface, but it's not working too. Best solution that we have now is bringing browser window to foreground, capturing the entire screen and cropping screenshot to window's client size; but it can interrupt and annoy users because of switching application that's currently in use.
If you want to take a screenshot of the page on the browser. try this JavaScript library: http://html2canvas.hertzen.com/
The script traverses through the DOM of the page it is loaded on. It gathers information on all the elements there, which it then uses to build a representation of the page. In other words, it does not actually take a screenshot of the page, but builds a representation of it based on the properties it reads from the DOM.
I just tried on my machine on Microsoft Edge and Chrome and worked on both.Hope that does the job!
I had the same problem with IE
try this.
The most stable result was with double call
PrintWindow(hWnd, hdcScreen, 0);
PrintWindow(hWnd, hdcScreen, PW_CLIENTONLY);

Form shrink during start up

Some weeks ago a user reported that the GUI of my program was shrink.
Today I started my laptop in multi-monitor mode and could reproduce the problem: at windows start up, the size of the main form was 325x243 pixels instead of 648x700.
I have no single line of code that controls the width/height of the form. The position is set like this: MainForm.Position:= poDefault. The user cannot resize the form ( BorderStyle:= bsSingle ).
What could cause such weirdness?
It is the second time when I start my laptop with additional monitors attached. The first time everything was ok. Could it be related to this multi-monitor configuration?
If the compiler generates no code related to form's size then it is like some external program injected code into my program to change its size. It is plausible. There are programs that are doing so in order to control how windows are spread over multiple monitors. I have one of them installed but it is not running at Windows start up.
The position is set like this: MainForm.Position:= poDefault
And that is the answer.
http://docwiki.embarcadero.com/Libraries/XE4/en/Vcl.Forms.TForm.Position
The form appears in a position on the screen and with a height and width determined by the operating system.
However there are other options like
poDefaultPosOnly: The form displays with the size you created it at design time, but the operating system chooses its position on the screen
poScreenCenter: The form remains the size you left it at design time, but is positioned in the center of the screen.
And many others.
Additionally, you may avoid fixing the issue and add a workaround instead: just set the form size fixed using http://docwiki.embarcadero.com/Libraries/XE4/en/Vcl.Forms.TForm.Constraints

Mirroring a portion of the screen to an external display (in OSX)

I would like to write a program that can mirror a portion of the main display into a new window. Ideally this new window could then be displayed on an external monitor. I have seen this uiltity for a flightsim that does this on a pc (a multifunction display extractor).
CLick here for a screenshot of the program (MFD Extractor)
This would be a live window ie. constantaly updated video display not just a static graphic.
I have looked at screen magnifiers or vnc clients for ideas but I think I need to write something from scratch. I have tried to do some reading on osx programing but where do I start in terms of gaining access to the display? I somehow need to extract the graphics from a particular program. Is it best to go near the final output stage (the individual pixels sent to the display) or somewhere nearer the window management stage.
Any ideas or pointers would be much appreciated. I just need somewhere to start from.
Regards,
There are a few ways to do this:
Quartz Display Services will let you get access to the video memory for a screen.
Quartz Window Services (a.k.a. CGWindow) will let you create an image of everything that lies below a window. If you create a borderless, transparent, empty, high-level window whose frame occupies an entire screen, everything below it will be everything on that screen. (Of course, you could create a smaller window in order to copy a section of the screen.)
There's also a way to do it using OpenGL that I never fully understood. That technique is demonstrated by a couple of code samples, OpenGLScreenSnapshot and OpenGLCaptureToMovie. It's more or less obsoleted by CGWindow, though.
Each of those will get you an image that you can then show or write to a file or something.
To show an image, use NSImageView or IKImageView. If you want to magnify it, IKImageView has a zoomFactor property, but if you want nearest-neighbor scaling (like Pixie, DigitalColor Meter, or xScope), I think you'll need to write a custom view for that (but even that isn't all that hard).

What is a robust method for capturing screen of child window in Windows 7?

Pardon my frustration. I've asked about this in many places and I seriously don't think that there wouldn't be a way in Windows 7 SDK to accomplish this.
All I want, is to capture part of a 'child window' ( setParent() ) created by a parent. I used to do this with bitblt() but the catch is that the child window can be any type of application, and in my case has OpenGL running in a section of it. If I bitblt() that, then the OGL part comes blank, doesn't get written to the BMP.
DWM, particularly dwmRegisterThumbnail() doesn't allow thumbnail generation of child windows. So please give me a direction.
Thanks.
It's been a while since I did any of this, so my explanation might be a bit vague, but from what I remember, the Windows doesn't "see" the OpenGL rendered inside the window.
What Windows does is create the window at the specified size and then "hands it over" to OpenGL for rendering. This means that you can't get at the pixels as rendered from the Windows side of the code.
When we wanted to capture the 3D we had to re-render the screen to an off screen bitmap which was then saved (or printed).
Obviously a whole screen capture (Print Screen) works because it's reading the final pixels.
I suggest that you:
Forget the Thumbnail part of the task (in terms of capture).
Calculate where your window is.
Capture full screen.
Excise the area you are interested in (using data from step 2).
Rescale to the appropriate thumbnail size.
Sorry, its more work, but it should work, which is better than what you have right now.
This may help:
http://code.google.com/p/telekinesis/source/browse/trunk/Mac/Source/glgrab.c?r=140
http://www.codeproject.com/KB/dialog/screencap.aspx
Also Java's Robot class (http://java.sun.com/javase/6/docs/api/java/awt/Robot.html#createScreenCapture%28java.awt.Rectangle%29)
I don't have access to the source code of any child window that may be open including the one with OpenGL

Where are people getting that rotating loading image?

I keep running across this loading image
http://georgia.ubuntuforums.com/images/misc/lightbox_progress.gif
which seems to have entered into existence in the last 18 months. All of a sudden it is in every application and is on every web site. Not wanting to be left out is there somewhere I can get this logo, perhaps with a transparent background? Also where did it come from?
You can get many different AJAX loading animations in any colour you want here: ajaxload.info
I believe the animation came from the Mac OS X loading screen. Here's a similar one with a transparent background:
alt text http://homepage.mac.com/xraydoc/.Pictures/spinner.gif
I think it's just a general extension to the normal clock-face style loading icon. The Firefox throbber is the first example of that style that I remember coming across; the only real difference between that and the current trend of straight lines is that the constituent symbols have been stretched to give a crisper look, moving back to more of a many-handed clock emblem.

Resources