MFC - Printing rtf document - mfc

How to print a RTF document in a MFC application without displaying it?
The user will go through the following step to print the file:
1. Choose the rtf file.
2. A print dialog box will appear after that
3. Press OK to print the file.

You can load it in an invisible CRichEditCtrl and pass a printer DC when sending WM_PRINT to the window.

Related

how to hide cute report print dialog in qt?

I have an problem, I am making an invoice management application with Qt and Cute Report library. everything is working but, when I click on print button there is an print dialog that I don't want, how can I hide that and continue printing.
dialog that I highlighted in this image:
I have tried to set printer property ShowDialog to false but no luck.
I tried that:
reportCore->printer("printer")->setProperty("showDialog", "false");

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

Show Message Bar in ribbon mfc

Probabbly i am not sure what to search for ... But the idea is to display a message bar bellow ribbon control. When user try to edit a read only file. I don't want user to click on OK to remove error message. Thats why i can't use MessageBox.
Status bar doesn't seem right place to display error messages.
Which control i should start exploring.
MSOffice normally displays such message when user opens files in protected view .
I don't want you to do research for me, I just want the right direction i will do the rest.
Thanks
You can easily use CMFCCaptionBar for such an attempt. When you create a ribbon bar SDI application you get sample code for free.
Also it is possible to hide and Show such a bar on the fly with ShowWindow. Also this code is generated by the wizard.

Visual Studio C++ how to display a dynamic message (i.e., string) in my About box?

Should be trivial . . . when editing via the VS resource editor.... the tools/objects list only shows 'static text' and the create an event handler wizard has all fields and [next] button dimmed (disabled).
I have a lovely About box -- it all works -- but instead of static text fields to display --
I want/need to display several lines (strings) of current runtime status info.....
I just do know Visual Studio well enough (I'm using 2008). . .
If any one has a simple example -- that really is all I need.
Thanks in advance.
best regards,
Kevin Waite
If you put a static text box in your dialog you can set its text to anything you want at runtime. First you need to get the window handle of the text box:
HWND hwndText = GetDlgItem(hwndDialog, IDC_MYTEXT);
Then you can set the new text into it:
SetWindowText(hwndText, L"Hi mom, this is my first text box!");
Static text isn't meant to change, so Windows doesn't always do the right thing when you change it. You need to tell it to erase and repaint so that the new text is properly displayed.
InvalidateRect(hwndText, NULL, true);
How about adding an empty static text, and just setting its Text property?
I just made an empty Windows Forms application in Visual Studio C++ Express, and dragged a "Label" control onto the form. In the forms Load function, the text can be set like this:
this->label1->Text = "Hello World";
The same method can be used if you want larger texts. Just use a multiline TextBox instead.
If you want to display multiple lines of text, you can use the EditBox control and set the multiline property to True.
To pass the data to the about dialog, you will need to have to pass those strings to the dialog when the dialog is created (before the call to DoModal); and have the string added to the editbox in the aboutbox OnInitDialog.
If you need the text to be updated live while the about dialog is open you will probably have to add a thread that will fetch the strings from somewhere and the UI will be updated with those new strings.
Good luck.

How to send input to hidden program c++?

So my question is how to send some comands or input from one (c++) program to another if hi is on hidden mode? For example I want to open some text file in notepad with function WinExec("notepad", 0); and than want to print conetent of file, I make handle to that file, make sendinput with CTRL+P, and the window of printig show up,.... I want to make all that proces hidden from user, is it possible?
There're many ways to do it. You can open notepad on a separate desktop. If you run notepad with SW_HIDDEN it would also not show the window, and then you can use windows hooks to hook the creation of print window and ShowWindow() it to hidden.
But why all the hassle? If you don't need notepad's UI, why not just print the file yourself?