Setting AdvancedPrintingOptions from C++ code - c++

I'm working with my friend to create a simple Photo Booth device. We are using DNP RX1 Printer, and this printer has the ability to cut photos in half.
When printing photos directly from windows cutting can be set as Enabled/Disabled via "Advanced Options" window in Printer Properties.
How to Enable/Disable Cut (2inch cut)
I'm working on application for this Photo Booth device (Developed on Windows 7). I'm using C++ and Qt as my GUI framework. There is a QPrintSupport module in Qt library that can be used to print images from my application, and I know how to do it. But the problem is that there is no way to Enable/Disable this "cut photos in half" option using Qt library. It is possible to display settings window to user using QPrintDialog class, but I want the process of taking photo and printing to be automatic ( User only press start button, smiles and waits till photo comes out). My workaround for this problem was to save files to two folders, and use different program to print photos from the first folder with cut option enabled and from the other folder with cut option disabled. But the problem was that printer was sometimes detected as DS-RX1 and sometimes as "DS-RX1 (Copy)" or even "DS-RX1 Copy 1", then this solution didn't work and someone had to manually delete printer from the system and reconnect it.
My question is: Is there a way to print a photo from C++ program using default printer and change this Advanced Printer Option (2inch cut) from C++ code? OR: Is there a way to force this printer to be detected always as DS-RX1?

Maybe you can set priner by substring "DS-RX1".
You can get list of available printers http://doc.qt.io/qt-5/qprinterinfo.html#availablePrinters by substring and as a variant you can set printer by setPrinterName function http://doc.qt.io/qt-5/qprinter.html#setPrinterName

Related

Expanding A Console In Windows 10 OS

Background Information: I'm developing an Windows 10 app. Within my app, I'm working with nested consoles. I'm familiar with GetSystemMetrics() and using some of it's parameters to define my console physical appearance (i.e. SM_CXBORDER, SM_CXDLGFRAME, etc).
Snip: Nested Child Console
Problem: What parameter should I look into if I want my nested child consoles (i.e. child's child console) to be resizable? My current logic output a user cmd onto this console. Overtime, the outputs accumulate. For example, if a user inputs the cmd Time 10 times then he/she will need to start scrolling through the outputs to see any previous output. In the desired scenario, the user can input the cmd Time 10 times without having to scroll which can be done by extending the console vertically. As a user, I rather extend the console than scroll through the outputs. This is purely for better visibility and less congestion.
Attempt: I tried altering DLGFRAME, DLGWINFRAME, RESIZEFRAME, and SCROLL. However, I didn't have much success.
There is no layout engine in the classic Windows API that will make your window extend size automatically
"Fit window size to text" is a feature that is implemented only in more sophisticated GUI toolkits.
If you insist on using the classic Windows API for your GUI (kind of like using stone age tools) - the only option is to calculate how big your rendered text is going to be (either assume it is always one line or use DrawText with the DT_CALCRECT flag) and extend your main window and text control by that amount.
On the whole you would be far more wise to switch to a real GUI toolkit, than wrestle with WINAPI and reinvent extremely complex wheels
BTW don't call it a console - because console is a term used to refer to Windows console terminals that use a different API - your question is confusing with existing terminology

Qt Disable Windows 10 Game Bar

I have an application developed in Qt that causes Windows 10 to think it is a game, and opens a pop up box that says Press the Win-key + G to open the Game bar. This is very unhelpful as my application is not a game; and it interferes with the user experience. How can I turn this off from within my application code? I have been unable to find any documentation related to this. Thanks in advance.
It is not possible to neither capture Windows shortcuts (in order to stop propagation and disable them), nor to disable game bar in a per-app base.
Options you have are:
to disable it globally (see this post): you can do it using the Registry, so it can be included in an installation package, but you'll affect the global settings of the user,
change the shortcut used to access it in the Xbox app,
use some third-party app, such as AutoHotKey, to map keyboard sequences to an empty action (related question).
Edit:
Also you can (from user side) disable it for your app in Xbox app. (Xbox support):
Open Xbox app
In my games list select your app
Right click on it and delete it
This will delete your app from games list, so GameBar will not appear.

Trying to write a c++ console program to change a setting controlled by a windows checkbox

Is it possible to create a keyboard shortcut to switch between the monitor and portion selection of this wacom preferences window, via a c++ console program?
Sorry if this is poorly worded, I've had trouble trying to find the right words to search for ways to do it.
I think it should be possible, although a bit tedious. You should be able to use the Windows API, and try to EnumWindows/EnumDesktopWindows to identify the respective application Window, and its respective controls (which are also Windows).
You should identify the window title, and class ids, for the app window, and the checkbox button controls, then when you enumerate through all the desktop windows, you can identify the ones you are interested in.
Then you can use the SendMessage() API to send messages to the controls (Windows) of interest to manipulate them.
It's a bit tedious, but sounds possible.
An example of use here to get an idea:
http://www.cplusplus.com/forum/windows/25280/

Paste From QT Window to Another Application Input Widget

I am very new to C++ programming and the bulk of my program will be using the QT libraries. However, there is one part where I believe I will need to use Win32.
The scenario I want to code for is as follows:
I will have a QT application running. I want to be able to take some text which has been typed into a TextBox on the QT Window and paste that text into a TextBox in another application e.g. the address bar of Chrome, the address bar of Windows Explorer.
I want to be able to do that as a response to a button click on the QT Window. So, it would all happen in 3 steps. For example:
User types text into QT Window;
User places cursor in address bar of Chrome (Browser);
User clicks button on Window which pastes text into address bar of Chrome.
A nudge in the right direction would be most appreciated.
Edit - Additional Info
The application I’m building is a self-set assignment. I want to build a clipboard manager, similar to this old Delphi application http://www.joejoesoft.com/vcms/97/ . It will run in the system tray, in a minimised state.
The user, will put their focus into a text input in some application
which is running on their Windows machine e.g. Notepad.
Then, they will hit a hot key combination which will open a form (my QT Window.
The application will have been collecting clips as the user presses Ctrl-C (or by right-clicking) and those will be listed in that QT Form (just like the app in the link above).
The user then clicks on the particular item that they want paste and it will be pasted into the original input that they had put the cursor into.
Further Edit - further info
I'll break step 4 into a couple of sub-steps as it is causing confusion:
The user then clicks on the particular item that they want paste
Focus changes from QT Window back to the window of the other Win32 application which originally had focus
Content is pasted into the input control which now has the focus
I pretty much know how I can gather up items when the user copies things. But I have no idea how I will paste from my application to the target application.
Cheers

Usage of software input panel in DirectX based app

I am trying to add text input functionality into existing DirectX application that was being ported to Windows Store / Phone 8.1. The problem is that I can't even get the sample code provided by microsoft in this article to compile:
http://msdn.microsoft.com/en-us/library/windows/apps/jj247546%28v=vs.105%29.aspx
I am using Universal App project as a base and I have no acces to Windows::Phone::UI::Core (there is no Core namespace at all!)
I was trying to add dummy textbox and hid it somewhere but without luck as to appear the software keyboard you need to focus the textbox - the moment it receives focus it appears on the screen (we draw our own controls so I don't want the system one) despite the fact being set to Transparent, both foreground and background and width to 0.
How can I manipulate SIP to show/hide and retrieve input from the keyboard without having to hack my way through XAML and stuff?
On Windows Phone (but not Windows) apps can request the InputPane hide and show programmatically by calling InputPane.TryShow and TryHide.
If you want the InputPane to show automatically then you need to set focus to a control which identifies itself as a text control to the automation system (see the Touch Keyboard documentation on MSDN. Windows Phone works essentially the same as Windows 8 here).
There are two ways to do this in a DirectX app:
As the other thread describes and as you've tried, you can use a Xaml TextBox on top of your DirectX surface. This has the advantage of being easy as the Xaml controls already implement the accessibility and IME interfaces needed for full text support. It has the disadvantage of being external to the DX scene so it can require some care to place it nicely. You can't really hide the TextBox and divert the input, but need to use the TextBox for input. I prefer to do the full interactive form in Xaml rather than trying to merge a single TextBox into a full scene.
The other option is to implement a text control in DirectX. Windows uses the UI Automation API to identify and interact with text controls. If you implement the TextPattern and focus for your control within DirectX then the keyboad will automatically invoke when the user sets focus to it. There's a sample at Input: Touch keyboard sample which demonstrates the necessary interfaces within a custom Xaml control context. It won't apply directly to DX, but will give the general idea. The UI Automation Provider Programmer's Guide has more in depth information on implementing UI Automation interfaces. Again, while these docs target Windows they will also apply to Windows Phone.
I'm not sure exactly which code didn't compile for you. The linked pages are a bit out of date (SwapChainPanel is now preferred over SwapChainBackgroundPanel), but the classes and techniques involved should be valid for Windows Phone Runtime apps.