Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to change display settings: screen resolution, screen refresh rate
Adding and deleting Scheduled Tasks using NetScheduleJob API functions
Custom GDI+ class
Converting Unicode data from the Clipboard to a character string using a given code page
Capturing keyboard activity of another application with the Raw Input API (VFP9)
Enumerating data formats currently available on the clipboard
Winsock: sending email messages (SMTP, port 25)
How to download a file from the FTP server using FtpGetFile
Detecting changes in connections to removable drives (VFP9)
Custom FTP Class for Visual FoxPro application
Enumerating raw input devices attached to the system (keyboard, mouse, human interface device)
How to play AVI file on the _screen
Custom HttpRequest class (WinHTTP)
How to activate Windows Calculator
Splash Screen for the VFP application
Custom HttpRequest class (WinINet)
Using Font and Text functions
Mapping and disconnecting network drives
Establishing connection using the SQLDriverConnect
Creating the Open dialog box to specify the drive, directory, and name of a file to open
Deleting files into the Recycle Bin
How to convert a bitmap file to monochrome format (1 bpp)
How to display the Properties dialog box for a file (ShellExecuteEx)
Displaying bitmap using the AlphaBlend function
How to change display settings: screen resolution, screen refresh rate

User rating: 10/10 (2 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
Versions:
click to open
Before you begin:
This code sample shows how to switch the monitor resolution to 800x600 pixels and back, keeping the existing refresh rate.

Before changing the resolution the code verifies if the hardware supports the requested graphics mode.



See also:
  • How to adjust monitor brightness (Vista, monitor with DDC support)
  • How to detect if additional monitor is connected and active
  •  
      Members area. Log in to view this example.
     
      User name:
      Password:
     
     
      Forgot your password?
     
      Sign up for
    the Membership
     
     


    User rating: 10/10 (2 votes)
    Rate this code sample:
    • ~
    6320 bytes  
    Created: 2003-01-21 10:56:03  
    Modified: 2011-01-29 06:42:30  
    Visits in 7 days: 505  
    Listed functions:
    ChangeDisplaySettings
    EnumDisplayDevices
    EnumDisplaySettings
    GetDesktopWindow
    GetMonitorInfo
    MonitorFromWindow
    Printer friendly API declarations
    My comment:
    A screenshot of C# version of this code sample.


    * * *
    Five ways of obtaining current monitor resolution:

  • The SYSMETRIC(1 | 2) is the simplest one. Very likely it is a wrapper around either GetSystemMetrics (SM_CXFULLSCREEN | SM_CYFULLSCREEN) call or SystemParametersInfo call. Each of three reports data for the primary monitor only.

  • Presented in the code sample above, the EnumDisplaySettings populates the DEVMODE structure. Members dmPelsWidth and dmPelsHeight of this structure contain the width and the height for enumerated monitor.

  • The GetMonitorInfo populates the MONITORINFO structure. The rcMonitor member in this structure is the RECT structure itself. It contains the display monitor rectangle expressed in virtual-screen coordinates.

  • The GetWindowPlacement populates a rectangle -- RECT rcNormalPosition. Call this function with the handle to the desktop window. For multiple monitor configuration, such desktop rectanlge is a combination of all active monitor rectangles.

  • Normally the mouse cursor is confined inside the desktop window. The GetClipCursor copies the desktop window dimensions into the RECT structure.
  • Word Index links for this example:
    Translate this page:
      Spanish    Portuguese    German    French    Italian  
    FreeTranslation.com offers instant, free translations of text or web pages.
    User Contributed Notes:
    Rosemar | 2006-12-08 11:49:22
    I have 2 computers.

    One of then, with Windows XP and another one, with Windows 98.

    In the machine with Windows XP this code works right, but, in another computer with Windows 98, when I run the code, the desktop area lost the original icons positions and the Windows Task Bar became HIDED outside the desktop area.

    This problem have solution ?

    Thank's.
    A.M. | 2006-12-11 20:09:50
    You may try to refresh the Desktop window by calling an API function like ShowWindow, MoveWindow, SetWindowPos, SetForegroundWindow, SwitchToThisWindow.

    Win98 -- this is an old system. Some API calls are not supported or behave in a different way.

    Copyright © 2001-2013 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

    Privacy policy
    Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.1.55-log), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (23.20.196.179)
    8 sec.Function: 'GetComputerObjectName'
    4.16 hrs.Example: 'HOWTO: Use the Win32 API to Access File Dates and Times'
     Example: 'Accessing the list of Windows Recent Documents'
    11.39 hrs.Example: 'How to find the application associated with a file name'
    11.4 hrs.Function: 'CreateDirectory'
    13.26 hrs.Function: 'UuidToString'
    Function group: 'Remote Procedure Call (RPC)'
     Example: 'Testing MS Internet Explorer version installed'
    17.43 hrs.Example: 'Storing screen shot of a form to enhanced metafile (*.emf)'
     Function: 'WNetGetUniversalName'
     Example: 'Obtaining I/O counts for the current process'
    Google
    Advertise here!