I am trying to add touchpad gesture support to an existing MFC application. I'm using VS 2010, with the new MFC which supports OnGestureZoom and OnGesturePan(), however, I can't make these work. I have breakpoints in them, but they are never called.
I have a touchpad on my laptop, and it is working with the default windows processing (i.e. zoom comes through as a mouse scroll wheel event). However, I want to override this zoom behaviour and also process panning, rotation, etc.
In OnCreate(), I am calling
int lval = GetSystemMetrics(SM_DIGITIZER);
int ltouches = GetSystemMetrics(SM_MAXIMUMTOUCHES);
and both functions return zero, so this indicates that there is some other problem here that is stopping gestures from working correctly
I have also tried calling RegisterTouchWindow() in OnCreate, but this makes no difference.
Edit to add - I've tried following this simple tutorial [http://msdn.microsoft.com/en-us/windows7trainingcourse_win7multitouchgesturemfc_topic2.aspx][1], but still no joy. At Task 2, step 4, my application simply says that "No touch input is currently available."
What O/S are you running on?
Also check if the Tablet PC Input service is started -- the GetSystemMetrics function for SM_DIGITIZER says "Nonzero if the current operating system is Windows 7 or Windows Server 2008 R2 and the Tablet PC Input service is started".
Related
The question
Is there a method to prevent an X session from starting the screensaver, going into power save mode, or performing a screen blank from code?
What I'm working with
Language: C/C++
GUI framework: GTK3
Hardware: Raspberry Pi 3B
Software: Raspbian 10 - Buster
My program needs to run on screen for long periods (up to 12 hours) with the GUI running without user interaction. The GUI acts as a status monitor for systems in field (if the screen goes black, something went wrong).
What I know
GTK3 can determine if the screensaver is active
GTK3 has a boolean property to report if the screensaver of the system is active (see here), but no other references are made in the documentation.
Raspbian uses screen blanking
Raspbian does not come installed with xscreensaver or other package to control the screen off time. Instead, it relies mostly on X to "blank screen". This can be managed with the xset command as a superuser. The canonical way to do this is reported in the hardware-specific Stack Exchange (here).
End-users cannot be trusted
In my case, the program will be used by folks who are barely computer literate. The result must be user-friendly and not expect the user to ever touch a terminal, let alone to make permanent changes to the startup config of X. While one option would be to distribute the program as a customized Raspbian disk image, I would like to explore other options.
I need to see an example
While there were some places to start using this question, implementing them is problematic. When I attempt to use the following MWE with and without the commented line, nothing happens. I cannot simulate the screen blanking function.
#include <X11/extensions/scrnsaver.h>
int main() {
// XScreenSaverSuspend;
XForceScreenSaver;
usleep(1000000);
return 0;
}
You have to pass parameters to the function:
void XScreenSaverSuspend(Display *dpy, Bool suspend);
#include <X11/extensions/scrnsaver.h>
int main() {
XScreenSaverSuspend (display, True);
usleep(1000000);
return 0;
}
But I don't think you have time to see the result with this program and when program ends the screensaver goes back to its previous state.
For your GTK framework, you can obtain the Display use:
Display *
gdk_x11_display_get_xdisplay (GdkDisplay *display);
Docs here.
For X:
/* use the information from the environment variable DISPLAY
to create the X connection:
*/
Display * dis = XOpenDisplay((char *)0); // or ":0.0"
A hacky, OS-specific solution:
Raspbian does not appear to require super user elevation to modify the xset. Adding the line to the code:
system("xset -dpms");
system("xset s off");
is sufficient to turn off the power management settings and the screensaver.
This is obviously sloppy, and it potentially leaves the OS in an undesirable state if the program breaks before these have a chance to be reset to default values. More elegant answers are encouraged.
I have an MFC based application. I have dragged the file created from my application to say(bottom right) of the desktop, it could be any location on the desktop.
Now if I open up my file again and perform a save operation, it always gets auto aligned to left. My application's files could retain their position on Windows XP.It works all fine there. This issue is on Windows 7 and Windows 8.
On debugging my codebase, I found that the call made to ::MoveFile() (http://msdn.microsoft.com/en-us/library/windows/desktop/aa365239%28v=vs.85%29.aspx), is actually putting the file to left of desktop.
I couldn't get any thing much on this issue. It seems nobody else has faced this problem :(.
Any pointers in this direction - What could be wrong, or if such things needs a completely separate handling and if there is a standard way to do that would be of great help.
Also, MS Word, Wordpad, Notepad all works fine on my win 7 and win 8 machine in the mentioned scenario.
I coded a Windows screensaver using C++/WinAPIs some time ago but now when I try it on Windows 8 at a logon screen (when no users are yet logged in) it doesn't seem to work. It is clearly a bug in Windows 8, because when I reboot the system my screensaver begins to work just fine. (Note that this behavior never happened on any previous version of Windows.)
What happens is that when the screensaver starts, the screen turns black and nothing happens after that moment. Obviously I can't debug it with the Visual Studio, so I added a trace statement into the first line where it should begin executing in WM_CREATE in ScreenSaverProc() but that line never gets called when the screensaver hangs up like I described above.
This tells me that some initialization code hangs up before the WM_CREATE message is sent, but to fix that I do not have access to that code because Microsoft's tutorial on WinAPI screensavers instructs to link to Scrnsave.lib (or ScrnsavW.lib in my case.)
So I was wondering, is there any way to build a WinAPI screensaver without using Scrnsave.lib?
I am having a problem with the program I am currently working on. It is caused by the increased security in vista/Windows 7, specifically the UIPI which prevents a window with a lower integrity level 'talking' to a higher one.
In my case, i am wanting to tell the window with a high Integrity level to move into our application, It works flawlessly on XP or windows 7 with the security off.
I have tried setting the HWND of the higher IL window directly, rather than using the findwindow() function, this works fine but the program then fails when trying to move it or generally interact with it. The windowhandle is saved by the app to be embedded and read by the app running at a lower IL.
I have also tried setting UIaccess in the manifest to TRUE and digitally signing the program but no luck.
Any ideas on how to solve this problem?
thanks.
Just thought i would follow this up for anyone who also struggled as I have finally found a way to do this.
IL = Integrity Level.
I had 2 apps, highIL.exe and lowIL.exe, the highIL wanted to find the lowIL.exe window, set it as a child window and move it into a zone created for it on the highIL.exe. This was blocked by the UIPI in vista+.
In the end i used the ChangeWindowMessageFilter method in vista and the ChangeWindowMessageFilterEx in Windows7, both found in the user32.dll. These functions allow you to poke a hole in the UIPI to allow messages that you want through.
I created a few custom messages using RegisterWindowMessage function, I used this function to register the method in both highIL and lowIL applications, the line looked a little like this:
const UINT MY_MOVEINTWINDOW_MSG = RegisterWindowMessage(_T("MyMsg.MoveWindow"));
The lowIL.exe is then able to send these messages to the highIL.exe window without them being blocked. Then it was a case of just simply adding and writing message handlers.
This method will only work if you have access to both the high and low IL.
The MSDN also has a working example of the ChangeWindowMessageFilterEx function on there Website
I'm using QTP 10 together with VMWare to test a Siebel Application.
I'm executing the following code to click on a Save button.
Browser("Siebel").Dialog("Filedownload").WinButton("Save").Click
The code works perfectly fine when I'm connected to the VM via Remote Desktop.
On the other side, when I'm starting the QTP test through the scheduler, without having a Remote Desktop connection, the code above fails without any error message. The WinButton is simply not clicked.
Any idea?
Just to add from my experience.
In some companies I worked for I couldn't change screensaver or standby settings due to security policy. A PC was bringing up screensaver during long synchronization periods (like generating really big report), and execution was broken.
To avoid that I created simple "Anti Sleep" function that slightly "moves" mouse every 5 minutes.
http://automation-beyond.com/2009/08/18/anti-sleep-function/
Private Const SleepTime_Max = 300 ‘ 5 minutes
Public Function AntiSleep()
Dim iter
Dim objTimer
Dim objDeviceReplay
Dim intTimeElapsed
Set objTimer = MercuryTimers(“AntiSleep”)
intTimeElapsed = CInt(objTimer.ElapsedTime/1000)
If intTimeElapsed = 0 Then
MercuryTimers(“AntiSleep”).Start
Exit Function
End If
If intTimeElapsed < SleepTime_Max Then
Exit Function
End If
Set objDeviceReplay = CreateObject(“Mercury.DeviceReplay”)
For iter = 100 To 110
objDeviceReplay.MouseMove iter,300
Next
MercuryTimers(“AntiSleep”).Start
Set objDeviceReplay = Nothing
End Function
Example of using it in a custom synchronization function:
http://automation-beyond.com/2009/08/20/gui-object-synchronization-custom-function/
Thank you,
Albert Gareev
QTP can't interact with a locked desktop, that's why it'll only work for you when logged in interactively either locally or over RDP. It's a well known limitation of QTP, most automation engineers go through this pain at some point. :)
To be more specific, it can't interact with Win32 objects (can't think of a better way of putting it), so it'll interact with basic browser controls on a locked desktop no problem, but browser popups and Windows applications can't be interacted with in those circumstances.
I strongly recommend (if your system policy allows) that you install something like UltraVNC or another VNC variant to interact with your remote machines. That way you can leave the remote machine's desktop logged on and active at all times. Since it's a VM that shouldn't cause you any major security problems either. Make sure you turn off any screen savers and don't auto-lock the desktop too. QTP should work just fine for you if you do that.