This question is related to: Which API Microsoft Word (Office 2013) is using the paint the screen, which was left unanswered.
I have an Office plug-in (native C++) which is fairly involving with Office. Using hooks I'm modifying the client area of Office application.
Things were working great for me up to Office 2010, hooking WM_NCPAINT, and using GDI method on the Office Window.
But Office 2013 uses Direct2D, DXGI, and DirectWrite. On Windows 7, if I draw something on the screen - it gets erased the next time the cursor blink. On Windows 8 - I don't even have access to the screen.
Currently, my thinking is to hook ID2D1DeviceContext::BeginDraw, ID2D1DeviceContext::EndDraw - and on last function, just before delegating to the real function, I will add my stuff. Another idea is the hook IDXGISwapChain1::Present1. Problem with both these methods that I've hard time identifying what is going on above.
I'm even thinking even a different process (or GDI based window - if possible) on top of the client area I want to decorate, with the majority of the real eastate being 100% transparent. Problem with this solution are issues like keyboard focus and mouse click.
Any tip or suggestion will be appreciated. Any tool (the Spy++ for DirectX) will be appreciated. Does DirectX (specifically Direct2D) has documented extensible or plug-able story, I'm not aware of and could use? Is there anything in Kernel Mode I'm missing?
Hm dont know exactly how that works on Direct Draw, but i hooked once the EndScene function for Direct3D and added some stuff to the scene before the real EndScene could be executed.
I made a little video that shows that:
http://www.youtube.com/watch?v=ZFshqIEaLBc
Here's my advice: don't do that. Any of it. If you find yourself having to hook and hack into the host that deeply, it's a clear sign that you just shouldn't be doing that. Find another way to draw what you need, or change your UI design so that it fits in with what Office already accomodates. Even if you assume it's possible to get this working, every time Office is updated (patch, service pack, new version) you will be at high risk of all your stuff breaking, with no guarantee that you'll be able to get it working again.
Related
I have a technical doubt on an ePub3 job and thought of checking with you all and get your understanding and advise on it.
For one of my German client, I have created a ePub 3.0 re-flow with interactivity, we have used all the interactivities to work on pop-ups (Non-linear content) and it works well on iPad iBooks 3.2, as the initial request from client is to work only for iPad.
I understand that a latest Apple spec (iBooksAssetGuide 5.1 Rev 2) now says that “Develop scripts that perform well on both Mac OS and iOS devices: Interactivity on desktop computers requires input from a mouse while interactivity on iOS devices require touch input”. I’m not sure whether there would be any problem while this job goes into the Apple iBooksstore, due to the latest spec.
It would be of great help, if you all please share your idea’s / view to this problem.
Regards,
John.A
Great question. With the latest version of OSX (Mavericks) running iBooks as well, there are a few things that need to be considered when using touch interactivity in ePub3 books. The most important (and relevant here) of these is making sure you are firing mouse events as well as touch events: because they behave differently.
The most robust solution that I have found to date is using JQuery or Quo's "tap" event: as it will fire with both touch and mouse events! However, if your code digs deeper (IE if you you use events like "touchstart", "touchmove", etc.) you will need to use the corresponding mouse events to insure functionality on the desktop.
Tap.js is a great little library for stuff like this: http://alxgbsn.co.uk/2012/03/12/tap-js-a-lightweight-tap-event-javascript-plugin/.
You should also be aware that iBooks for OSX behaves differently for many features (especially when it comes to external media content and dynamic loading of content), so you should never rely on OSX only when testing...
Good luck!
I have an Office plug-in (native C++) which is fairly involving with Office. One of the thing I'm doing is finding the HWND of the main window, and subclass that window. On various occasions I also GetDC that window, and paint my own stuff on top of the Office document.
I'm also using IAT hooking (fairly standard) of various Windows API.
I've a 'Decorate' function that draw on the HDC directly. Until Office 2010, I called my method immediately after Office handled WM_PAINT, and also after WM_KEYUP. That was working fine.
Starting with Office 2013, WinWord pains the client area in times I failed to track. Moreover, I cannot even find any GDI API that Office is using when repainting it's client area. I'm putting a hook on DrawText (gdi), or DrawString (gdi+).
As far as I can tell, WinWord will repaint the client area (and hence - delete my decoration) even without calling GetDC, BeginPaint, or ReleaseDC!
I'm almost out of ideas. I'll appreciate any idea that Office could use to touch the screen? I'm setup to hook any function, and/or Windows message - just can't find what has to be hooked. Any other idea (no need for complete solution - just an direction will be fine). Any tool that can be used (e.g. is there anything similar to FileMon for GDI methods?) will be appreciated.
Office 2013 is using DirectWrite, Direct2D and DXGI for putting ink on the screen. As they do that, they almost entirely avoid using GDI, hence GetDC/BeginPaint/etc. never been called.
See this blog:
http://blogs.msdn.com/b/murrays/archive/2012/07/29/office-adopts-new-windows-display-technology.aspx
How (i.e. using which API) is the virtual keyboard opened on Symbian S60 5th edition? The documentation seems to lack information about this.
You are right, this should obviously be a published API and it should be highlighted in the documentation. No such luck.
If you are using one of the platform native controls, the virtual keyboard will automatically popup when the user accesses a text-editing control.
If you are making a custom control, you need to deal with its selection by adding your own version of the virtual keyboard: make a new text-editing, window-owning virtual keyboard look-alike custom control with the right buttons. Reuse it accross all your applications. One day, Nokia will realize they have made an obvious mistake and make the API publicly available.
If you are using direct screen access, well, you wouldn't exactly expect the very s60-looking virtual keyboard to popup out of nowwhere. Again, draw a nice image on the screen to let the user know where the virtual keys are and react to pointer events. This is going to be less reusable unless you build a good amount of customization (background, button edges...) into it.
EDIT: Nokia may be relying on Qt to fix this issue. I would expect the control to be part of the current 4.7 version of Qt.
Tinkering with focus on a QLineEdit inside custom coded kinetic scroll area, I've had a simmilar problem (how to open virtual keyboard manually). Then, I found it, this obviously works in Qt 4.6.3 on a C7 Symbian^3 phone:
// lineEdit is an instance of QLineEdit
QApplication::postEvent(lineEdit, new QEvent(QEvent::RequestSoftwareInputPanel));
Before that, I also had to post a QEvent::FocusIn event to that same lineedit, otherwise the QLineEdit did not update the content from virtual keyboard.
Hope this is helpful. I lost hours.
Thank you tihi, very useful tip! There's also the "close virtual keyboard" event that can be triggered:
QApplication::postEvent(lineEdit, new QEvent(QEvent::CloseSoftwareInputPanel));
I'm currently getting my feet wet with Win CE 5.0 to update some code on an existing platform. We're interested in deploying a custom shell/home screen/application launcher as well and I had a couple questions:
1) We're running the standard CE shell and I'm assuming it can be customized because the source code is made available with Platform Builder. I was wondering how "painful" it would be to completely replace it with something like a status bar at the top of the screen (think iPhone). I was thinking task switching could then be handled by shortcut keys exclusively. I have my doubts about this.
2) If it can't be removed, can the taskbar be resized and moved to the top of the screen? We're basically trying to find a way to reserve the first 20 or so pixel rows at the top of the screen for our own status bar and prevent maximized application windows from drawing over top of it.
Thanks very much for the help.
-ksudeadeye
I was happy and angry when I found the solution because it's more easy than I expect.
For 2) reserve space you need to do this:
RECT rc;
SetRect(&rc, 0, 25, GetSystemMetrics(SM_CXSCREEN),GetSystemMetrics(SM_CYSCREEN));
SystemParametersInfoW(SPI_SETWORKAREA, 0, (void*) &rc, SPIF_SENDCHANGE);
With this code you reserve 25 pixels in the top of the screen.
:D
If you have doubts maybe this can help you or this.
Good luck.
To hide the task bar is a simple registry change:
; Hide the windows tasbar by default.
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shell\AutoHide]
""=dword:1
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shell\OnTop]
""=dword:0
As far as customizing, your own, that is a little more work, and not something I've attempted.
I have some experience with modifying the taskbar in CE 5.0. It is not an easy task, but the results can really add that personal touch to the device. I was tasked with adding a user mode second taskbar with a password dialog and a second type of shell notification to add icons to the user bar.
In the end, it is just standard Windows CE programming - the taskbar, notification tray, start button, etc. are just like any other windows in the CE environment.
You should start exploring here:
C:\WINCE500\PUBLIC\SHELL\OAK\HPC\EXPLORER\TASKBAR\taskbar.cpp
Be careful, clone your code, and be prepared for lots of debug cycles. This is more than 5000 lines of serious spaghetti code.
We've got some in-house applications built in MFC, with OpenGL drawing routines. They all use the same code to draw on the screen and either print the screen or save it to a JPEG file. Everything's been working fine in Windows XP, and I need to find a way to make them work on Vista.
In three of our applications, everything works. In the remaining one, I can get the window border, title bar, menus, and task bar, but the interior never shows up. As I said, these applications use the exact same code to write to the screen and capture the window image, and the only difference I see that looks like it might be relevant is that the problem application uses the MFC multiple document interface, while the ones that work use the single document interface.
Either the answer isn't on the net, or I'm worse at Googling than I thought. I asked on the MSDN forums, and the only practical suggestion I got was to use GDI+ rather than GDI, and that did nothing different. I have tried different things with every part of the code that captures and prints or save, given a pointer to the window, so apparently it's a matter of the window itself. I haven't rebuilt the offending application using SDI yet, and I really don't have any other ideas.
Has anybody seen anything like this?
What I've got is four applications. They use a lot of common code, and share the actual .h and .cpp files, so I know the drawing and screen capture code is identical.
There is a WindowtoDIB() routine that takes a *pWnd, and a source rectangle and destination size. It looks like very slightly adapted Microsoft code, and I've found other functions in this file on the Microsoft website. Of my four applications, three handle this just fine, but one doesn't. The most obvious difference is that the problem one is MDI.
It looks to me like the *pWnd is the problem. I'm not a MFC guru by a long shot, and it seems to me that the problem may be that we've got one window setup in the SDIs, and more than one in the MDI. I may be passing the wrong *pWnd to the function.
In the meantime, it has started working properly on the 64-bit Vista test machine, although it still doesn't work on the 32-bit Vista machine. I have no idea why. I haven't changed anything since the last tests, and I didn't think anybody else had. (On the 32-bit version, the Print Screen key works as expected, but it does not save the screen as a JPEG.)
Your question title mentions screen capture but your actual question doesn't. Please elaborate more clearly. Is the problem that you can do screen capture of three of your applications, but not the fourth one? You can use different screen capture software that can capture OpenGL/DirectX windows. Those surfaces are handled directly by the Window Manager and won't show up with a simple 'PrtScn'.
Switching to GDI+ won't solve it, nor will switching to SDI.
If it's the content of the CView that you want, then yes, that should be right one. If it's the content of the whole screen (at least the content, without the toolbar(s) and status bar), then you should pass it the CMainFrame (that's the default name which may have been changed, the one that is derived from CMDIFrameWnd).
Can you post the code of WindowToDIB()? I've just tried it and It Works For Me (TM), but without OpenGL code in the view. Try passing the following windows to your WindowToDIB() function:
CMainFrame* mainfrm = static_cast<CMainFrame*>(::AfxGetMainWnd());
- mainfrm
- mainfrm->MDIGetActive()
- mainfrm->MDIGetActive()->GetActiveView()
and see what you get.
The contents of each window are directX surfaces and are only assembled by the window manager in the graphics card. You'd not be able to capture this unless you switch off the new interface (DWM) or code specifically for screen capture from the DWM.
Wikipedia has a good description of the Desktop Window Manager (DWM)
Sorry, I still don't understand. You're trying to get the Print Screen key to work on all four applications? Or you're trying to get the WindowtoDIB() function to work, which takes a 'screenshot' (from within your own application) of the application itself, so that it can be saved as an image file?
Also, what do you mean with 'he Print Screen key works as expected, but it does not save the screen as a JPEG.'? Print Screen only copies to the clipboard, what happens when you paste in Paint?
If your WindowtoDIB() function only 'captures' the window you pass to it, then yes, your MDI child windows are not going to show up.
We eventually solved this by creating a different OpenGL context, and drawing everything to that. We gave up on the screen capture.