Recommend me a solution for generating print preview and printing - c++

INTRODUCTION AND RELEVANT INFORMATION:
I am maintaining an old application and I need to implement feature that generates reports based on data calculated from a database. User must also have an additional option of printing the file ( user must be able to choose printer, and must be able to see print preview ).
To improve my chances of getting satisfactory answer, allow me to additionally clarify matters with a small "example":
User presses a button -> application calculates data; // Done
Application creates file and populates it with the result; // Done
User gets informed that report is generated; // Done
User presses another button that is charged for printing; // Stuck here!
Print preview pops up and an option to run print dialog. // Stuck here
User starts the print dialog, chooses the printer and application prints the file;
The application is coded in C++ using raw WinAPI ( no MFC ). I am working on Windows XP.
PROBLEM:
I was able to successfully use OLE Automation to generate/save Word and Excel reports but I can not create print preview that matches exactly the print preview Word would create.
If I use OLE Automation to show Excel's print dialog/print preview, there is a following problem that might occur :
User can simply click "Close Print Preview", or can simply close print property sheet ( please see picture below ) and return to the document which might compromise document's data.
My employers do not like this ( they have no software engineering / developing background, so no matter what I say it will end up as an "echo in the wind"... ) and they wish that my print preview matches exactly the print preview Word generates.
Therefore, I need a solution for generating a print preview for the user, in a way that matches exactly print preview Word would create. Furthermore, user should be able only to see how this looks like, but not to be able to open the file from my application. User should be able to choose the printer that will print the file.
An implementation similar to the one from the picture would be fine.
QUESTION:
INTRODUCTORY NOTES:
The question is too broad to be answered in one post so I must limit myself only for seeking advice / general concept / pointing in the right direction.
THE ACTUAL QUESTIONS :
I did the best I could with the OLE Automation and Excel / Word files, but as you can see there are problems with generating a print preview, hence the following questions :
Since this is my first time to tackle this kind of task, can you recommend me the proper way to handle it ( general concepts of course )?
Is there a chance that there is a workaround for my printing problem ( like sending WM_PRINTCLIENT message to the Word / Excel or something like that )?
REMARKS :
Again, I realize the question is too broad so just give me general concepts / pointers, so I could post separate questions if I get stuck somewhere in the way.
I do not need to use Word / Excel and OLE Automation, it was my choice at the moment.
If you can recommend better solution I will gladly accept. I do not wish to use libraries.
If additional information is required, ask and I will edit my post.

You would need to bring up a dialog box when the user clicks the print button, the dialog box would contain a control that shows the preview for the default printer and three buttons to select another printer, print and exit.
The preview control could be a static control where the WM_PAINT handler would draw the preview (alternatives: a Web Browser control which is fed html text or a RichText control which is fed RTF text, but then you are constrained by the functionality of these controls).
Quote: Print preview
isn't that special. It just means that you have to render to screen
(or bitmap) what you'd otherwise would render to the printer DC. This
primarly means using the page size, and providing a UI control for the
prev/next page.
This SO Answer describes in detail the work you need to do to paint the preview.
This CodeProject article has some simple code for print-preview; it's in simple MFC which should not be too difficult to translate to plain C++/WinAPI.

Related

How do you display rapidly updating data to the user in a win32 GUI app?

So im building a basic win32 GUI app and I have a vector of data that gets constantly updated through an external source via a port. Im interested in displaying that list of data to the user but im not sure the best approach to go about it without causing update flickering.
I originally had an edit box in which I build a string with the information and update the window. But it has proved troublesome as the amount of data grows since I cant scroll down to look at additional data. Any ideas?
My idea is no point of updating the visual control as the same speed you receive the data. Because even-though you update at the same speed the users cannot see that change at the speed of data receiving. Human eye does not see a change happening in speed as 1/8th of a second. So better to update the visual control in a controlled manner. Maybe using a timer.
Appending to the text of an edit control for each subsequent data point will lead to flickering as the whole control re-renders as the text has changed.
I'd advise one of the following options:
1) use a ListBox or ListView control; when you add another row item, it only re-draws the new/changed/scrolled item. https://learn.microsoft.com/en-us/windows/desktop/controls/create-a-simple-list-box and https://learn.microsoft.com/en-us/windows/desktop/controls/list-view-controls-overview
2) If you only want an always-scrolling list of data, consider just having a command-line application that writes to the standard output and saves you a lot of trouble - cout or printf your data.
You can also use EM_SETSEL and EM_SCROLLCARET to automatically scroll, but also check the position of the scroll bar before doing that. If not at the bottom, it means that the user wanted to pause, so you can scroll.
Also, you can have the scroll lock key checked in order whether to scroll or not, after all that is what it's name is supposed to do.

How to look for a specific mapping in the navigator window

I'm new to powercenter and the learning curve of this tool seems to be different from the programming languages I'm used to. Where I work everyone tells me to ask people in the office. Access to the internet is non existant. Stack overflow is one of the few places where I can look for info.
I would like to do something basic like, in the navigator window, there are sometimes thousands of mappings with veeeery similar names, I would like to know if there is a way to enable a "control-f" type of functionality. As of right now, placing the mouse on the window and writing the name kinda helps, but since the names are stuff like
k_l_ll_sigpir_proyectname_mappingname
and there are dozens and hundreds that share the same structure: "k_l_ll_sigpir_" trying to navigate when you don't know where info is other than the name is a bit of a nightmare, compared to other tools at least.
Can someone point me in the right direction? Thanks in advance.
I guess I was able to find something that might help, although this is a bit counter-intuitive. I'm assuming you want to find and open some mapping in Mapping Designer. Here goes:
After you've connected to Repository and have the right folder opened (not just connected!), choose Tools => Queries from the menu bar. A Query Browser should open for you.
Choose New to create a new query
In the Query Editor there's a grid. Choose Object Name in the Parameter Name column. Change the Operator to Contains and put whatever you're looking for as Value 1 (using your example: mappingname)
Click the blue play button on the menu bar or choose Query => Execute from top menu. Give this a few seconds.
Give it a few more seconds...
A Query Results window should be opened for you. NOTE: if you've been clicking anything it might get opened in the background - just check the Designer button on Start Bar. It should contain all the objects that contain mappingname string it the name. We've not limited this to mappings only though (I'll discuss this below).
=== now here's the odd part ===
You can right click any item on the list in Query Results window and choose Open in Workspace. And it won't work :)
Switch back to Query Editor window and close it (don't close the Query Results!). You may save you'r query if you like to.
You should be back at Query Browser. Close it.
Return to Query Results.
Right click the desired item and choose Open in Workspace.
Voila!
Now some remarks:
The whole repository is searched. The Query Results may therefore contain items from other folders, than the one you have open. Trying to Open in Workspace such objects won't work since the folder is not open in Designer.
You may construct more sophisticated queries. Just click 'Add new...' icon on the Query Editor window. This will add a line and allow you to choose extra conditions. It will be spawned by a AND condition which you may change to OR. You get the idea.
PS.
Yes, it's odd, I know. Just don't blame me ;)
The quick answer is that the 'metadata manager' tool can do exactly what you ask for. It is basically a 'google search' for your entire data warehouse. Only hiccup is that it requires a lot of work from the admins of your power center servers to get it up and running...
Alternatives:
Basically it depends on what you want to DO with the mapping after you've found it and why you look for it in the first place:
1) in the 'designer tool' you can look under 'targets' in the right hand tree structure
- when you've found the target table you want the mappings for
- simply right-click and choose 'dependencies'
- in the following dialog uncheck everything except 'mappings'
- in the following right click on the most likely mapping and choose 'open in workspace'
2) in the repository database there is a view called opb_task_inst_run that contains a row for each session that has ever run. You can write simple sql against that view with '%like patterns%' to locate mappings... you may want to add a where clause to 'start time' for the most recent week or so - especially if the repository is old and runtime metadata has never been deleted...
Please write back if you need something different...
I'm not aware of the functionality you're after within informatica, however, the mappings are listed in alphanumeric order which should alleviate this. Within the mapping itself there is search functionality to find transformations within the mapping.
As far as a place to start learning Informatica, informatica tv is one place to get your feet wet https://network.informatica.com/support-videos.jspa

C++ Windows Forms - Password Strength

I've been following YouTube tutorials most of the day now and I think I've got the basic hang of forms. I'm aiming to create something like this below, which checks a users password and shows how strong it is:
This is what I have at the moment:
I'd like to know the basic theory behind how the top form works, specifically how I can take the user input of password in my form and just get it to print and update in realtime underneath below. I'm not quite sure what tool is used to do that, or for that matter what tool is used to create the colour changing box.
Any help or direction is appreciated, thanks!
Add a keyboardListener to your jtextfield. When a key is pressed get the text and do your stuff(figure out the strength, number of Uppercase etc)
Is this win32 or mfc forms, or some other tech like Qt or wxWidgets?
In both cases you will want to handle messages from the edit field as text is changed in it. This message is the EN_CHANGE message. Handle that message and you can get the text from the edit field and send messages to the strength form to tell it to change its color and text.
Add a System::Windows::Forms::KeyPressEventHandler (or similar) to the TextBox. When raised, do whatever analysis you need to do on the string and update the table below. The color changing box can be one of many implementations. It can be something as simple as a panel that changes its background with a System::Windows::Forms::Label positioned on top of it. It actually looks like that, as the text is not centered.

How to paste information into filtered CHeaderCtrl

We have an MFC application that uses the CHeaderCtrl and have been using the HDS_FILTERBAR style to filter data. Works great. But our users want to be able to paste in text into the filter cell. I have not found a way to get a pointer to any CEdit-type of control here so that I can call >Paste. I have managed to detect a Control-V while in the filter in the application's ::PreTranslateMessage. There is a way to send text to the filter by way of a CHeaderCtrl->SetItem call, but this will immediately launch the filter. I just want to be able to paste text.
So...I tried (I was desperate) using keybd_event and SendInput to force keystrokes. This worked but had undesirable side effects, probably due to MFC's message handling, and in my case, the user already had the Control + V pressed down. But in just sending the letter 'A', and forcing the SHIFT key, I accidently discovered that the CHeaderCtrl's filter does support a paste if you:
CONTROL + SHIFT + V
The problem is its hard to do, and hard to tell my users to do this.
I can simulate this sequence using keybd_event, but again, its real quirky.
Can anyone find a way to either get access to the CEdit (if there even is one) to a filtered CHeaderCtrl or know of another workaround ? I tried using a spy utility, but was not sure what to look for. Sorry for the long post.
So remove Ctrl+V from the accelerator list and you can handle it inside the control...
(Answer added according to the comment).

Lookup Combo that supports remote data - load data only after user wants to

I'm building a VCL c++ builder application. I would like to see if anyone knows of a component that can load data in the lookup upon drop down only after a user has typed a few letters to limit the rows queried? Preferably after pressing Tab, or Enter.
What I would like best is to get a behaviour similar to what Linux command line has, but that might be wishful thinking. The way it would work is to drop down the combo list after user presses tab only if there is multiple options available, and to fill in additional text till the point where characters are not the same anymore, then if user presses tab again, drop down list.
The next best would be if the drop down would only allow drop down if user has typed a few letters, then pressing a specific button opens the dataset with the parameter of the typed text so far, then drops down the combo.
Does a component like this exist?
You can check out TMS Software. I'm not sure if it has something exactly for you, but their components are quite flexible. And you can send a feature request to them - to consider for next update. If you are lucky they might add it to next release.