Click here to Skip to main content
13,193,048 members (62,910 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi folks,

I am writing an add on for existing application dialog based. It has to have following feature:

When user hit button named preview application has to display content of a clipboard (i know how to handle clipboard), Scaled or over the black background, in FullScreen on a selected monitor. It can be current monitor on a single monitor system (or in clone mode), or one that is in application settings designated as preview monitor, in multimonitor settings.

I am not constrained with programming language or anything else. It can be separate application that I call from my application by passing parameters (such as which monitor, resolution , scaling etc), even better if that application can be preloaded and put in system tray.

I would highly appreciate if you can give me easy starting point.

Momir Zecevic
Ars Media
Posted 31-Jul-12 22:16pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Your app shouldn't handle monitors, you just have to avoid making some mistakes by using api from one monitored old times. All you have to do in your clipboard viewer app is saving the restored (not maximized) position of your window, plus saving if its maximized or not. When the app starts it creates the window in its saved non-maximized state, then it sets the window to maximized if the user quit the program in maximized state last time. Maximization will maximize the window automatically to the monitor that contains the biggest part of your window. So: let the user position the window, and don't build in an annoying artificial intelligence that wants to find out what the user wants! :-) If your window is built-in to your application then do the same thing, but in this case I usually don't destroy the window when the usr presses the X button, I just handle WM_CLOSE and hide the window an next time I need it I just put it on visible state again.

Note: When you create the window, its saved position might be completely out of screen. A tipical scenario is when you put your window on a secondary monitor and later you restart the prog when that monitor is detached. If you want to handle such cases, thus checking and correcting the window position before creating the window, then you have to enumerate all monitors, get the region of the monitors and check if you window (or at least the titlebar of the window) intersects with one of the monitors. If not, then you put it to a default position (lets say you center it on primary screen). You can skip this step if you don't want to be that sophisticated but then give the chance to the user to reset the saved config (for example by deleting the config files). If you insist on putting this position correction to your prog then the api you need: EnumDisplayMonitors()[^] and GetMonitorInfo()[^].

EDIT: Showing the window in maximized state: ShowWindow(hWnd, SW_MAXIMIZE);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.171017.2 | Last Updated 1 Aug 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100