Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Drawing cursors for the classes defined by the system (preregistered): BUTTON, EDIT, LISTBOX etc.
Drawing standard Windows icons
Finding out if the current user is the Guest account
GDI+ fun: roach-infested desktop
How to control Adobe Reader 9.0 (SDI mode) from VFP application
Reading VFP settings from the Windows Registry
Retrieving file information for the VFP executable running
The DetectAutoProxyUrl function identifies the auto-config script location
Winsock: reading and setting socket options
Creating a unique filename based on existing filename
GDI+: sending image of FoxPro form to printer
How to browse and connect to printers on a network (WinNT)
How to download this reference`s archive through WinInet functions using InternetOpenUrl
How to find which fonts Windows uses for drawing captions, menus and message boxes
Locking the workstation
Converting an HTTP time/date string to a SYSTEMTIME structure
Displaying standard progress dialog box when copying files
GDI+: printing vertical text on VFP reports via generated images (VFP8)
How to delete IE cookies, clear IE history and delete files in Temporary Internet Files directory
Placing an arbitrary rectangular area of main VFP window on the Clipboard
Converting a hexadecimal string to an integer
Current keyboard type
Drawing Windows frame controls using the DrawFrameControl function
GDI+: how to make VFP controls visually shake and shudder
Get the power status of your laptop computer

User rating: 10/10 (1 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 helps to find whether the system is running on AC or DC power, whether the battery is currently charging, and how much battery life remains.
 
DECLARE INTEGER GetSystemPowerStatus IN kernel32;
    STRING @lpSystemPowerStatus
 
*|typedef struct _SYSTEM_POWER_STATUS {
*|  BYTE ACLineStatus;         0:1
*|  BYTE BatteryFlag;          1:1
*|  BYTE BatteryLifePercent;   2:1
*|  BYTE Reserved1;            3:1
*|  DWORD BatteryLifeTime;     4:4
*|  DWORD BatteryFullLifeTime; 8:4
*|} SYSTEM_POWER_STATUS, *LPSYSTEM_POWER_STATUS; total 12 bytes
 
LOCAL cBuffer
cBuffer = Repli(Chr(0), 12)
IF GetSystemPowerStatus(@cBuffer) = 0
    RETURN
ENDIF
 
LOCAL nStatus, nBattery
nStatus = Asc(SUBSTR(cBuffer,1,1))
nBattery = Asc(SUBSTR(cBuffer,2,1))
 
? "AC power status: "
DO CASE
CASE nStatus = 0
    ?? "offline"
CASE nStatus = 1
    ?? "online"
OTHER
    ?? "unknown"
ENDCASE
 
? "Battery flag: "
DO CASE
CASE nBattery = 1
    ?? "high"
CASE nBattery = 2
    ?? "low"
CASE nBattery = 4
    ?? "critical"
CASE nBattery = 8
    ?? "charging"
CASE nBattery = 128
    ?? "no system battery"
OTHER
    ?? "unknown"
ENDCASE
 
IF nBattery <= 8
    ? "Battery remaining, %:", Asc(SUBSTR(cBuffer,3,1))
    ? "Battery remaining, sec:", buf2dword(SUBSTR(cBuffer,5,4))
    ? "Battery full time, sec:", buf2dword(SUBSTR(cBuffer,9,4))
ENDIF
* end of main
 
FUNCTION buf2dword(lcBuffer)
RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ;
    BitLShift(Asc(SUBSTR(lcBuffer, 2,1)),  8) +;
    BitLShift(Asc(SUBSTR(lcBuffer, 3,1)), 16) +;
    BitLShift(Asc(SUBSTR(lcBuffer, 4,1)), 24)
 
 
 

User rating: 10/10 (1 votes)
Rate this code sample:
  • ~
1406 bytes  
Created: 2001-07-12 12:00:00  
Modified: 2006-01-05 13:11:07  
Visits in 7 days: 82  
Listed functions:
GetSystemPowerStatus
Printer friendly API declarations
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:
There are no notes on this subject.


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 (54.224.79.93)
28.48 min.Function: 'GetGUIThreadInfo'
28.53 min.Example: 'Setting the Window Region for a form'
28.58 min.Example: 'Bitmap Class for Visual FoxPro application'
1.51 hrs.Function: 'GetWindow'
 Function: 'EnumForms'
2.21 hrs.Function: 'AVIStreamTimeToSample'
Function group: 'Windows Multimedia'
 Function: 'HeapUnlock'
3.6 hrs.Function: 'CharUpper'
Function group: 'String'
13.96 hrs.Example: 'Custom GDI+ class'
 Function: 'CeFindFirstFile'
Google
Advertise here!