From 3032b7b5c2d19764e4e7f3b50a5f727cbbaccc45 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Sat, 27 May 2006 14:29:30 +0000
Subject: [PATCH] moved power functions for MSW from utils.cpp to (new)
 power.cpp and implemented them

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39360 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 Makefile.in                | 17 +++++++
 build/bakefiles/files.bkl  |  1 +
 build/msw/makefile.bcc     | 16 +++++++
 build/msw/makefile.gcc     | 16 +++++++
 build/msw/makefile.vc      | 16 +++++++
 build/msw/makefile.wat     | 16 +++++++
 build/msw/wx_base.dsp      |  4 ++
 docs/latex/wx/function.tex |  4 +-
 samples/power/power.cpp    | 79 +++++++++++++++++++++++++++++++
 src/msw/power.cpp          | 97 ++++++++++++++++++++++++++++++++++++++
 src/msw/utils.cpp          | 13 -----
 src/wxWindows.dsp          |  4 ++
 12 files changed, 268 insertions(+), 15 deletions(-)
 create mode 100644 src/msw/power.cpp

diff --git a/Makefile.in b/Makefile.in
index a89ba4f8ed..25f6c14e5c 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -585,6 +585,7 @@ ALL_BASE_SOURCES =  \
 	src/msw/dir.cpp \
 	src/msw/dlmsw.cpp \
 	src/msw/mimetype.cpp \
+	src/msw/power.cpp \
 	src/msw/regconf.cpp \
 	src/msw/registry.cpp \
 	src/msw/snglinst.cpp \
@@ -2952,6 +2953,7 @@ COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS =  \
 	monodll_dir.o \
 	monodll_dlmsw.o \
 	monodll_mimetype.o \
+	monodll_power.o \
 	monodll_regconf.o \
 	monodll_registry.o \
 	monodll_snglinst.o \
@@ -4587,6 +4589,7 @@ COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS_1 =  \
 	monolib_dir.o \
 	monolib_dlmsw.o \
 	monolib_mimetype.o \
+	monolib_power.o \
 	monolib_regconf.o \
 	monolib_registry.o \
 	monolib_snglinst.o \
@@ -6260,6 +6263,7 @@ COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS_2 =  \
 	basedll_dir.o \
 	basedll_dlmsw.o \
 	basedll_mimetype.o \
+	basedll_power.o \
 	basedll_regconf.o \
 	basedll_registry.o \
 	basedll_snglinst.o \
@@ -6419,6 +6423,7 @@ COND_PLATFORM_WIN32_1___BASE_PLATFORM_SRC_OBJECTS_3 =  \
 	baselib_dir.o \
 	baselib_dlmsw.o \
 	baselib_mimetype.o \
+	baselib_power.o \
 	baselib_regconf.o \
 	baselib_registry.o \
 	baselib_snglinst.o \
@@ -11381,6 +11386,9 @@ monodll_dde.o: $(srcdir)/src/msw/dde.cpp $(MONODLL_ODEP)
 monodll_dlmsw.o: $(srcdir)/src/msw/dlmsw.cpp $(MONODLL_ODEP)
 	$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/dlmsw.cpp
 
+monodll_power.o: $(srcdir)/src/msw/power.cpp $(MONODLL_ODEP)
+	$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/power.cpp
+
 monodll_regconf.o: $(srcdir)/src/msw/regconf.cpp $(MONODLL_ODEP)
 	$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/regconf.cpp
 
@@ -15194,6 +15202,9 @@ monolib_dde.o: $(srcdir)/src/msw/dde.cpp $(MONOLIB_ODEP)
 monolib_dlmsw.o: $(srcdir)/src/msw/dlmsw.cpp $(MONOLIB_ODEP)
 	$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/dlmsw.cpp
 
+monolib_power.o: $(srcdir)/src/msw/power.cpp $(MONOLIB_ODEP)
+	$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/power.cpp
+
 monolib_regconf.o: $(srcdir)/src/msw/regconf.cpp $(MONOLIB_ODEP)
 	$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/regconf.cpp
 
@@ -19010,6 +19021,9 @@ basedll_dde.o: $(srcdir)/src/msw/dde.cpp $(BASEDLL_ODEP)
 basedll_dlmsw.o: $(srcdir)/src/msw/dlmsw.cpp $(BASEDLL_ODEP)
 	$(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $(srcdir)/src/msw/dlmsw.cpp
 
+basedll_power.o: $(srcdir)/src/msw/power.cpp $(BASEDLL_ODEP)
+	$(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $(srcdir)/src/msw/power.cpp
+
 basedll_regconf.o: $(srcdir)/src/msw/regconf.cpp $(BASEDLL_ODEP)
 	$(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $(srcdir)/src/msw/regconf.cpp
 
@@ -19568,6 +19582,9 @@ baselib_dde.o: $(srcdir)/src/msw/dde.cpp $(BASELIB_ODEP)
 baselib_dlmsw.o: $(srcdir)/src/msw/dlmsw.cpp $(BASELIB_ODEP)
 	$(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $(srcdir)/src/msw/dlmsw.cpp
 
+baselib_power.o: $(srcdir)/src/msw/power.cpp $(BASELIB_ODEP)
+	$(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $(srcdir)/src/msw/power.cpp
+
 baselib_regconf.o: $(srcdir)/src/msw/regconf.cpp $(BASELIB_ODEP)
 	$(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $(srcdir)/src/msw/regconf.cpp
 
diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl
index 4c877b7bad..8a727c9eb5 100644
--- a/build/bakefiles/files.bkl
+++ b/build/bakefiles/files.bkl
@@ -88,6 +88,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
     src/msw/dir.cpp
     src/msw/dlmsw.cpp
     src/msw/mimetype.cpp
+    src/msw/power.cpp
     src/msw/regconf.cpp
     src/msw/registry.cpp
     src/msw/snglinst.cpp
diff --git a/build/msw/makefile.bcc b/build/msw/makefile.bcc
index f19d2dc698..33fecbd5ec 100644
--- a/build/msw/makefile.bcc
+++ b/build/msw/makefile.bcc
@@ -265,6 +265,7 @@ MONODLL_OBJECTS =  \
 	$(OBJS)\monodll_dir.obj \
 	$(OBJS)\monodll_dlmsw.obj \
 	$(OBJS)\monodll_mimetype.obj \
+	$(OBJS)\monodll_power.obj \
 	$(OBJS)\monodll_regconf.obj \
 	$(OBJS)\monodll_registry.obj \
 	$(OBJS)\monodll_snglinst.obj \
@@ -375,6 +376,7 @@ MONOLIB_OBJECTS =  \
 	$(OBJS)\monolib_dir.obj \
 	$(OBJS)\monolib_dlmsw.obj \
 	$(OBJS)\monolib_mimetype.obj \
+	$(OBJS)\monolib_power.obj \
 	$(OBJS)\monolib_regconf.obj \
 	$(OBJS)\monolib_registry.obj \
 	$(OBJS)\monolib_snglinst.obj \
@@ -486,6 +488,7 @@ BASEDLL_OBJECTS =  \
 	$(OBJS)\basedll_dir.obj \
 	$(OBJS)\basedll_dlmsw.obj \
 	$(OBJS)\basedll_mimetype.obj \
+	$(OBJS)\basedll_power.obj \
 	$(OBJS)\basedll_regconf.obj \
 	$(OBJS)\basedll_registry.obj \
 	$(OBJS)\basedll_snglinst.obj \
@@ -582,6 +585,7 @@ BASELIB_OBJECTS =  \
 	$(OBJS)\baselib_dir.obj \
 	$(OBJS)\baselib_dlmsw.obj \
 	$(OBJS)\baselib_mimetype.obj \
+	$(OBJS)\baselib_power.obj \
 	$(OBJS)\baselib_regconf.obj \
 	$(OBJS)\baselib_registry.obj \
 	$(OBJS)\baselib_snglinst.obj \
@@ -4289,6 +4293,9 @@ $(OBJS)\monodll_dlmsw.obj: ..\..\src\msw\dlmsw.cpp
 $(OBJS)\monodll_mimetype.obj: ..\..\src\msw\mimetype.cpp
 	$(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) $**
 
+$(OBJS)\monodll_power.obj: ..\..\src\msw\power.cpp
+	$(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) $**
+
 $(OBJS)\monodll_regconf.obj: ..\..\src\msw\regconf.cpp
 	$(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) $**
 
@@ -6083,6 +6090,9 @@ $(OBJS)\monolib_dlmsw.obj: ..\..\src\msw\dlmsw.cpp
 $(OBJS)\monolib_mimetype.obj: ..\..\src\msw\mimetype.cpp
 	$(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) $**
 
+$(OBJS)\monolib_power.obj: ..\..\src\msw\power.cpp
+	$(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) $**
+
 $(OBJS)\monolib_regconf.obj: ..\..\src\msw\regconf.cpp
 	$(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) $**
 
@@ -7880,6 +7890,9 @@ $(OBJS)\basedll_dlmsw.obj: ..\..\src\msw\dlmsw.cpp
 $(OBJS)\basedll_mimetype.obj: ..\..\src\msw\mimetype.cpp
 	$(CXX) -q -c -P -o$@ $(BASEDLL_CXXFLAGS) $**
 
+$(OBJS)\basedll_power.obj: ..\..\src\msw\power.cpp
+	$(CXX) -q -c -P -o$@ $(BASEDLL_CXXFLAGS) $**
+
 $(OBJS)\basedll_regconf.obj: ..\..\src\msw\regconf.cpp
 	$(CXX) -q -c -P -o$@ $(BASEDLL_CXXFLAGS) $**
 
@@ -8120,6 +8133,9 @@ $(OBJS)\baselib_dlmsw.obj: ..\..\src\msw\dlmsw.cpp
 $(OBJS)\baselib_mimetype.obj: ..\..\src\msw\mimetype.cpp
 	$(CXX) -q -c -P -o$@ $(BASELIB_CXXFLAGS) $**
 
+$(OBJS)\baselib_power.obj: ..\..\src\msw\power.cpp
+	$(CXX) -q -c -P -o$@ $(BASELIB_CXXFLAGS) $**
+
 $(OBJS)\baselib_regconf.obj: ..\..\src\msw\regconf.cpp
 	$(CXX) -q -c -P -o$@ $(BASELIB_CXXFLAGS) $**
 
diff --git a/build/msw/makefile.gcc b/build/msw/makefile.gcc
index 3a3b4eb8b6..a04df06964 100644
--- a/build/msw/makefile.gcc
+++ b/build/msw/makefile.gcc
@@ -251,6 +251,7 @@ MONODLL_OBJECTS =  \
 	$(OBJS)\monodll_dir.o \
 	$(OBJS)\monodll_dlmsw.o \
 	$(OBJS)\monodll_mimetype.o \
+	$(OBJS)\monodll_power.o \
 	$(OBJS)\monodll_regconf.o \
 	$(OBJS)\monodll_registry.o \
 	$(OBJS)\monodll_snglinst.o \
@@ -361,6 +362,7 @@ MONOLIB_OBJECTS =  \
 	$(OBJS)\monolib_dir.o \
 	$(OBJS)\monolib_dlmsw.o \
 	$(OBJS)\monolib_mimetype.o \
+	$(OBJS)\monolib_power.o \
 	$(OBJS)\monolib_regconf.o \
 	$(OBJS)\monolib_registry.o \
 	$(OBJS)\monolib_snglinst.o \
@@ -473,6 +475,7 @@ BASEDLL_OBJECTS =  \
 	$(OBJS)\basedll_dir.o \
 	$(OBJS)\basedll_dlmsw.o \
 	$(OBJS)\basedll_mimetype.o \
+	$(OBJS)\basedll_power.o \
 	$(OBJS)\basedll_regconf.o \
 	$(OBJS)\basedll_registry.o \
 	$(OBJS)\basedll_snglinst.o \
@@ -569,6 +572,7 @@ BASELIB_OBJECTS =  \
 	$(OBJS)\baselib_dir.o \
 	$(OBJS)\baselib_dlmsw.o \
 	$(OBJS)\baselib_mimetype.o \
+	$(OBJS)\baselib_power.o \
 	$(OBJS)\baselib_regconf.o \
 	$(OBJS)\baselib_registry.o \
 	$(OBJS)\baselib_snglinst.o \
@@ -4393,6 +4397,9 @@ $(OBJS)\monodll_dlmsw.o: ../../src/msw/dlmsw.cpp
 $(OBJS)\monodll_mimetype.o: ../../src/msw/mimetype.cpp
 	$(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $<
 
+$(OBJS)\monodll_power.o: ../../src/msw/power.cpp
+	$(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $<
+
 $(OBJS)\monodll_regconf.o: ../../src/msw/regconf.cpp
 	$(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $<
 
@@ -6291,6 +6298,9 @@ $(OBJS)\monolib_dlmsw.o: ../../src/msw/dlmsw.cpp
 $(OBJS)\monolib_mimetype.o: ../../src/msw/mimetype.cpp
 	$(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $<
 
+$(OBJS)\monolib_power.o: ../../src/msw/power.cpp
+	$(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $<
+
 $(OBJS)\monolib_regconf.o: ../../src/msw/regconf.cpp
 	$(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $<
 
@@ -8192,6 +8202,9 @@ $(OBJS)\basedll_dlmsw.o: ../../src/msw/dlmsw.cpp
 $(OBJS)\basedll_mimetype.o: ../../src/msw/mimetype.cpp
 	$(CXX) -c -o $@ $(BASEDLL_CXXFLAGS) $(CPPDEPS) $<
 
+$(OBJS)\basedll_power.o: ../../src/msw/power.cpp
+	$(CXX) -c -o $@ $(BASEDLL_CXXFLAGS) $(CPPDEPS) $<
+
 $(OBJS)\basedll_regconf.o: ../../src/msw/regconf.cpp
 	$(CXX) -c -o $@ $(BASEDLL_CXXFLAGS) $(CPPDEPS) $<
 
@@ -8432,6 +8445,9 @@ $(OBJS)\baselib_dlmsw.o: ../../src/msw/dlmsw.cpp
 $(OBJS)\baselib_mimetype.o: ../../src/msw/mimetype.cpp
 	$(CXX) -c -o $@ $(BASELIB_CXXFLAGS) $(CPPDEPS) $<
 
+$(OBJS)\baselib_power.o: ../../src/msw/power.cpp
+	$(CXX) -c -o $@ $(BASELIB_CXXFLAGS) $(CPPDEPS) $<
+
 $(OBJS)\baselib_regconf.o: ../../src/msw/regconf.cpp
 	$(CXX) -c -o $@ $(BASELIB_CXXFLAGS) $(CPPDEPS) $<
 
diff --git a/build/msw/makefile.vc b/build/msw/makefile.vc
index cb46c122d8..563782f3bf 100644
--- a/build/msw/makefile.vc
+++ b/build/msw/makefile.vc
@@ -264,6 +264,7 @@ MONODLL_OBJECTS =  \
 	$(OBJS)\monodll_dir.obj \
 	$(OBJS)\monodll_dlmsw.obj \
 	$(OBJS)\monodll_mimetype.obj \
+	$(OBJS)\monodll_power.obj \
 	$(OBJS)\monodll_regconf.obj \
 	$(OBJS)\monodll_registry.obj \
 	$(OBJS)\monodll_snglinst.obj \
@@ -379,6 +380,7 @@ MONOLIB_OBJECTS =  \
 	$(OBJS)\monolib_dir.obj \
 	$(OBJS)\monolib_dlmsw.obj \
 	$(OBJS)\monolib_mimetype.obj \
+	$(OBJS)\monolib_power.obj \
 	$(OBJS)\monolib_regconf.obj \
 	$(OBJS)\monolib_registry.obj \
 	$(OBJS)\monolib_snglinst.obj \
@@ -497,6 +499,7 @@ BASEDLL_OBJECTS =  \
 	$(OBJS)\basedll_dir.obj \
 	$(OBJS)\basedll_dlmsw.obj \
 	$(OBJS)\basedll_mimetype.obj \
+	$(OBJS)\basedll_power.obj \
 	$(OBJS)\basedll_regconf.obj \
 	$(OBJS)\basedll_registry.obj \
 	$(OBJS)\basedll_snglinst.obj \
@@ -598,6 +601,7 @@ BASELIB_OBJECTS =  \
 	$(OBJS)\baselib_dir.obj \
 	$(OBJS)\baselib_dlmsw.obj \
 	$(OBJS)\baselib_mimetype.obj \
+	$(OBJS)\baselib_power.obj \
 	$(OBJS)\baselib_regconf.obj \
 	$(OBJS)\baselib_registry.obj \
 	$(OBJS)\baselib_snglinst.obj \
@@ -4598,6 +4602,9 @@ $(OBJS)\monodll_dlmsw.obj: ..\..\src\msw\dlmsw.cpp
 $(OBJS)\monodll_mimetype.obj: ..\..\src\msw\mimetype.cpp
 	$(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) $**
 
+$(OBJS)\monodll_power.obj: ..\..\src\msw\power.cpp
+	$(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) $**
+
 $(OBJS)\monodll_regconf.obj: ..\..\src\msw\regconf.cpp
 	$(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) $**
 
@@ -6392,6 +6399,9 @@ $(OBJS)\monolib_dlmsw.obj: ..\..\src\msw\dlmsw.cpp
 $(OBJS)\monolib_mimetype.obj: ..\..\src\msw\mimetype.cpp
 	$(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) $**
 
+$(OBJS)\monolib_power.obj: ..\..\src\msw\power.cpp
+	$(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) $**
+
 $(OBJS)\monolib_regconf.obj: ..\..\src\msw\regconf.cpp
 	$(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) $**
 
@@ -8189,6 +8199,9 @@ $(OBJS)\basedll_dlmsw.obj: ..\..\src\msw\dlmsw.cpp
 $(OBJS)\basedll_mimetype.obj: ..\..\src\msw\mimetype.cpp
 	$(CXX) /c /nologo /TP /Fo$@ $(BASEDLL_CXXFLAGS) $**
 
+$(OBJS)\basedll_power.obj: ..\..\src\msw\power.cpp
+	$(CXX) /c /nologo /TP /Fo$@ $(BASEDLL_CXXFLAGS) $**
+
 $(OBJS)\basedll_regconf.obj: ..\..\src\msw\regconf.cpp
 	$(CXX) /c /nologo /TP /Fo$@ $(BASEDLL_CXXFLAGS) $**
 
@@ -8429,6 +8442,9 @@ $(OBJS)\baselib_dlmsw.obj: ..\..\src\msw\dlmsw.cpp
 $(OBJS)\baselib_mimetype.obj: ..\..\src\msw\mimetype.cpp
 	$(CXX) /c /nologo /TP /Fo$@ $(BASELIB_CXXFLAGS) $**
 
+$(OBJS)\baselib_power.obj: ..\..\src\msw\power.cpp
+	$(CXX) /c /nologo /TP /Fo$@ $(BASELIB_CXXFLAGS) $**
+
 $(OBJS)\baselib_regconf.obj: ..\..\src\msw\regconf.cpp
 	$(CXX) /c /nologo /TP /Fo$@ $(BASELIB_CXXFLAGS) $**
 
diff --git a/build/msw/makefile.wat b/build/msw/makefile.wat
index 640f9740cc..edd3525c19 100644
--- a/build/msw/makefile.wat
+++ b/build/msw/makefile.wat
@@ -2735,6 +2735,7 @@ MONODLL_OBJECTS =  &
 	$(OBJS)\monodll_dir.obj &
 	$(OBJS)\monodll_dlmsw.obj &
 	$(OBJS)\monodll_mimetype.obj &
+	$(OBJS)\monodll_power.obj &
 	$(OBJS)\monodll_regconf.obj &
 	$(OBJS)\monodll_registry.obj &
 	$(OBJS)\monodll_snglinst.obj &
@@ -2846,6 +2847,7 @@ MONOLIB_OBJECTS =  &
 	$(OBJS)\monolib_dir.obj &
 	$(OBJS)\monolib_dlmsw.obj &
 	$(OBJS)\monolib_mimetype.obj &
+	$(OBJS)\monolib_power.obj &
 	$(OBJS)\monolib_regconf.obj &
 	$(OBJS)\monolib_registry.obj &
 	$(OBJS)\monolib_snglinst.obj &
@@ -2957,6 +2959,7 @@ BASEDLL_OBJECTS =  &
 	$(OBJS)\basedll_dir.obj &
 	$(OBJS)\basedll_dlmsw.obj &
 	$(OBJS)\basedll_mimetype.obj &
+	$(OBJS)\basedll_power.obj &
 	$(OBJS)\basedll_regconf.obj &
 	$(OBJS)\basedll_registry.obj &
 	$(OBJS)\basedll_snglinst.obj &
@@ -3053,6 +3056,7 @@ BASELIB_OBJECTS =  &
 	$(OBJS)\baselib_dir.obj &
 	$(OBJS)\baselib_dlmsw.obj &
 	$(OBJS)\baselib_mimetype.obj &
+	$(OBJS)\baselib_power.obj &
 	$(OBJS)\baselib_regconf.obj &
 	$(OBJS)\baselib_registry.obj &
 	$(OBJS)\baselib_snglinst.obj &
@@ -4593,6 +4597,9 @@ $(OBJS)\monodll_dlmsw.obj :  .AUTODEPEND ..\..\src\msw\dlmsw.cpp
 $(OBJS)\monodll_mimetype.obj :  .AUTODEPEND ..\..\src\msw\mimetype.cpp
 	$(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $<
 
+$(OBJS)\monodll_power.obj :  .AUTODEPEND ..\..\src\msw\power.cpp
+	$(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $<
+
 $(OBJS)\monodll_regconf.obj :  .AUTODEPEND ..\..\src\msw\regconf.cpp
 	$(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $<
 
@@ -6491,6 +6498,9 @@ $(OBJS)\monolib_dlmsw.obj :  .AUTODEPEND ..\..\src\msw\dlmsw.cpp
 $(OBJS)\monolib_mimetype.obj :  .AUTODEPEND ..\..\src\msw\mimetype.cpp
 	$(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $<
 
+$(OBJS)\monolib_power.obj :  .AUTODEPEND ..\..\src\msw\power.cpp
+	$(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $<
+
 $(OBJS)\monolib_regconf.obj :  .AUTODEPEND ..\..\src\msw\regconf.cpp
 	$(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $<
 
@@ -8392,6 +8402,9 @@ $(OBJS)\basedll_dlmsw.obj :  .AUTODEPEND ..\..\src\msw\dlmsw.cpp
 $(OBJS)\basedll_mimetype.obj :  .AUTODEPEND ..\..\src\msw\mimetype.cpp
 	$(CXX) -bt=nt -zq -fo=$^@ $(BASEDLL_CXXFLAGS) $<
 
+$(OBJS)\basedll_power.obj :  .AUTODEPEND ..\..\src\msw\power.cpp
+	$(CXX) -bt=nt -zq -fo=$^@ $(BASEDLL_CXXFLAGS) $<
+
 $(OBJS)\basedll_regconf.obj :  .AUTODEPEND ..\..\src\msw\regconf.cpp
 	$(CXX) -bt=nt -zq -fo=$^@ $(BASEDLL_CXXFLAGS) $<
 
@@ -8632,6 +8645,9 @@ $(OBJS)\baselib_dlmsw.obj :  .AUTODEPEND ..\..\src\msw\dlmsw.cpp
 $(OBJS)\baselib_mimetype.obj :  .AUTODEPEND ..\..\src\msw\mimetype.cpp
 	$(CXX) -bt=nt -zq -fo=$^@ $(BASELIB_CXXFLAGS) $<
 
+$(OBJS)\baselib_power.obj :  .AUTODEPEND ..\..\src\msw\power.cpp
+	$(CXX) -bt=nt -zq -fo=$^@ $(BASELIB_CXXFLAGS) $<
+
 $(OBJS)\baselib_regconf.obj :  .AUTODEPEND ..\..\src\msw\regconf.cpp
 	$(CXX) -bt=nt -zq -fo=$^@ $(BASELIB_CXXFLAGS) $<
 
diff --git a/build/msw/wx_base.dsp b/build/msw/wx_base.dsp
index 294c71bcd7..025a9b26cc 100644
--- a/build/msw/wx_base.dsp
+++ b/build/msw/wx_base.dsp
@@ -743,6 +743,10 @@ SOURCE=..\..\src\msw\mslu.cpp
 # End Source File
 # Begin Source File
 
+SOURCE=..\..\src\msw\power.cpp
+# End Source File
+# Begin Source File
+
 SOURCE=..\..\src\msw\regconf.cpp
 # End Source File
 # Begin Source File
diff --git a/docs/latex/wx/function.tex b/docs/latex/wx/function.tex
index 78ae7251df..4db79cb10f 100644
--- a/docs/latex/wx/function.tex
+++ b/docs/latex/wx/function.tex
@@ -2975,7 +2975,7 @@ Returns battery state as one of \texttt{wxBATTERY\_NORMAL\_STATE},
 \texttt{wxBATTERY\_LOW\_STATE}, \texttt{wxBATTERY\_CRITICAL\_STATE},
 \texttt{wxBATTERY\_SHUTDOWN\_STATE} or \texttt{wxBATTERY\_UNKNOWN\_STATE}.
 \texttt{wxBATTERY\_UNKNOWN\_STATE} is also the default on platforms where
-this feature is not implemented.
+this feature is not implemented (currently everywhere but MS Windows).
 
 \wxheading{Include files}
 
@@ -3000,7 +3000,7 @@ Under X only, returns the current display name. See also \helpref{wxSetDisplayNa
 Returns the type of power source as one of \texttt{wxPOWER\_SOCKET},
 \texttt{wxPOWER\_BATTERY} or \texttt{wxPOWER\_UNKNOWN}.
 \texttt{wxPOWER\_UNKNOWN} is also the default on platforms where this
-feature is not implemented.
+feature is not implemented (currently everywhere but MS Windows).
 
 \wxheading{Include files}
 
diff --git a/samples/power/power.cpp b/samples/power/power.cpp
index 04b9ab3c63..5649e29b57 100644
--- a/samples/power/power.cpp
+++ b/samples/power/power.cpp
@@ -52,8 +52,12 @@ public:
                                           wxTE_MULTILINE | wxTE_READONLY);
         m_logOld = wxLog::SetActiveTarget(new wxLogTextCtrl(text));
 
+        CreateStatusBar();
+
         SetIcon(wxICON(sample));
 
+        UpdatePowerSettings(wxPOWER_UNKNOWN, wxBATTERY_UNKNOWN_STATE);
+
         Show();
     }
 
@@ -63,6 +67,17 @@ public:
     }
 
 private:
+    void OnIdle(wxIdleEvent& WXUNUSED(event))
+    {
+        const wxPowerType powerType = wxGetPowerType();
+        const wxBatteryState batteryState = wxGetBatteryState();
+        if ( powerType != m_powerType || batteryState != m_batteryState )
+        {
+            UpdatePowerSettings(powerType, batteryState);
+        }
+    }
+
+#ifdef wxHAS_POWER_EVENTS
     void OnSuspending(wxPowerEvent& event)
     {
         wxLogMessage(_T("System suspend starting..."));
@@ -88,7 +103,67 @@ private:
     {
         wxLogMessage(_T("System resumed from suspend."));
     }
+#endif // wxHAS_POWER_EVENTS
+
+
+    void UpdatePowerSettings(wxPowerType powerType, wxBatteryState batteryState)
+    {
+        wxString powerStr;
+        switch ( m_powerType = powerType )
+        {
+            case wxPOWER_SOCKET:
+                powerStr = _T("wall");
+                break;
+
+            case wxPOWER_BATTERY:
+                powerStr = _T("battery");
+                break;
+
+            default:
+                wxFAIL_MSG(_T("unknown wxPowerType value"));
+                // fall through
+
+            case wxPOWER_UNKNOWN:
+                powerStr = _T("psychic");
+                break;
+        }
+
+        wxString batteryStr;
+        switch ( m_batteryState = batteryState )
+        {
+            case wxBATTERY_NORMAL_STATE:
+                batteryStr = _T("charged");
+                break;
+
+            case wxBATTERY_LOW_STATE:
+                batteryStr = _T("low");
+                break;
+
+            case wxBATTERY_CRITICAL_STATE:
+                batteryStr = _T("critical");
+                break;
+
+            case wxBATTERY_SHUTDOWN_STATE:
+                batteryStr = _T("empty");
+                break;
+
+            default:
+                wxFAIL_MSG(_T("unknown wxBatteryState value"));
+                // fall through
+
+            case wxBATTERY_UNKNOWN_STATE:
+                batteryStr = _T("unknown");
+                break;
+        }
+
+        SetStatusText(wxString::Format(
+                        _T("System is on %s power, battery state is %s"),
+                        powerStr.c_str(),
+                        batteryStr.c_str()));
+    }
 
+    wxPowerType m_powerType;
+    wxBatteryState m_batteryState;
 
     wxLog *m_logOld;
 
@@ -96,10 +171,14 @@ private:
 };
 
 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
+    EVT_IDLE(MyFrame::OnIdle)
+
+#ifdef wxHAS_POWER_EVENTS
     EVT_POWER_SUSPENDING(MyFrame::OnSuspending)
     EVT_POWER_SUSPENDED(MyFrame::OnSuspended)
     EVT_POWER_SUSPEND_CANCEL(MyFrame::OnSuspendCancel)
     EVT_POWER_RESUME(MyFrame::OnResume)
+#endif // wxHAS_POWER_EVENTS
 END_EVENT_TABLE()
 
 // ----------------------------------------------------------------------------
diff --git a/src/msw/power.cpp b/src/msw/power.cpp
new file mode 100644
index 0000000000..022e624dad
--- /dev/null
+++ b/src/msw/power.cpp
@@ -0,0 +1,97 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        src/msw/power.cpp
+// Purpose:     power management functions for MSW
+// Author:      Vadim Zeitlin
+// Modified by:
+// Created:     2006-05-27
+// RCS-ID:      $Id$
+// Copyright:   (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
+// Licence:     wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+// for compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+    #pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#endif //WX_PRECOMP
+
+#include "wx/power.h"
+
+// ----------------------------------------------------------------------------
+// helper functions
+// ----------------------------------------------------------------------------
+
+static inline bool wxGetPowerStatus(SYSTEM_POWER_STATUS *sps)
+{
+    if ( !::GetSystemPowerStatus(sps) )
+    {
+        wxLogLastError(_T("GetSystemPowerStatus()"));
+        return false;
+    }
+
+    return true;
+}
+
+// ============================================================================
+// implementation
+// ============================================================================
+
+wxPowerType wxGetPowerType()
+{
+    SYSTEM_POWER_STATUS sps;
+    if ( wxGetPowerStatus(&sps) )
+    {
+        switch ( sps.ACLineStatus )
+        {
+            case 0:
+                return wxPOWER_BATTERY;
+
+            case 1:
+                return wxPOWER_SOCKET;
+
+            default:
+                wxLogDebug(_T("Unknown ACLineStatus=%u"), sps.ACLineStatus);
+            case 255:
+                break;
+        }
+    }
+
+    return wxPOWER_UNKNOWN;
+}
+
+wxBatteryState wxGetBatteryState()
+{
+    SYSTEM_POWER_STATUS sps;
+    if ( wxGetPowerStatus(&sps) )
+    {
+        // there can be other bits set in the flag field ("charging" and "no
+        // battery"), extract only those which we need here
+        switch ( sps.BatteryFlag & 7 )
+        {
+            case 1:
+                return wxBATTERY_NORMAL_STATE;
+
+            case 2:
+                return wxBATTERY_LOW_STATE;
+
+            case 3:
+                return wxBATTERY_CRITICAL_STATE;
+        }
+    }
+
+    return wxBATTERY_UNKNOWN_STATE;
+}
+
+
diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp
index 5b418e2167..d94f52caa2 100644
--- a/src/msw/utils.cpp
+++ b/src/msw/utils.cpp
@@ -37,7 +37,6 @@
 #include "wx/dynlib.h"
 #include "wx/dynload.h"
 #include "wx/scopeguard.h"
-#include "wx/power.h"
 
 #include "wx/confbase.h"        // for wxExpandEnvVars()
 
@@ -1004,18 +1003,6 @@ bool wxShutdown(wxShutdownFlags WXUNUSED_IN_WINCE(wFlags))
 #endif // Win32/16
 }
 
-wxPowerType wxGetPowerType()
-{
-    // TODO
-    return wxPOWER_UNKNOWN;
-}
-
-wxBatteryState wxGetBatteryState()
-{
-    // TODO
-    return wxBATTERY_UNKNOWN_STATE;
-}
-
 // ----------------------------------------------------------------------------
 // misc
 // ----------------------------------------------------------------------------
diff --git a/src/wxWindows.dsp b/src/wxWindows.dsp
index 0182d1d720..8d1e857e9c 100644
--- a/src/wxWindows.dsp
+++ b/src/wxWindows.dsp
@@ -1543,6 +1543,10 @@ SOURCE=.\msw\popupwin.cpp
 # End Source File
 # Begin Source File
 
+SOURCE=.\msw\power.cpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\msw\printdlg.cpp
 # End Source File
 # Begin Source File
-- 
2.45.2

