summaryrefslogtreecommitdiff
path: root/navit/gui/win32/ceglue.c
blob: ff3310fb214aec79e9c4e2f945cbf3ead824f4d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <windows.h>
#include "ceglue.h"

BOOL FAR (*SHFullScreenPtr)(HWND hwnd, DWORD state) = NULL;

void InitCeGlue (void) {
    HINSTANCE ayg = LoadLibraryW (TEXT ("aygshell.dll"));
    if (ayg != NULL) {
        SHFullScreenPtr = (BOOL (*)(HWND, DWORD))
                          GetProcAddressW (ayg, TEXT ("SHFullScreen"));
    }
}

// code to turn of screen adopted from
// http://msdn.microsoft.com/en-us/library/ms838354.aspx

// GDI Escapes for ExtEscape()
#define QUERYESCSUPPORT    8

// The following are unique to CE
#define GETVFRAMEPHYSICAL   6144
#define GETVFRAMELEN    6145
#define DBGDRIVERSTAT    6146
#define SETPOWERMANAGEMENT   6147
#define GETPOWERMANAGEMENT   6148


typedef enum _VIDEO_POWER_STATE {
    VideoPowerOn = 1,
    VideoPowerStandBy,
    VideoPowerSuspend,
    VideoPowerOff
} VIDEO_POWER_STATE, *PVIDEO_POWER_STATE;


typedef struct _VIDEO_POWER_MANAGEMENT {
    ULONG Length;
    ULONG DPMSVersion;
    ULONG PowerState;
} VIDEO_POWER_MANAGEMENT, *PVIDEO_POWER_MANAGEMENT;


int CeEnableBacklight(int enable) {
    HDC gdc;
    int iESC=SETPOWERMANAGEMENT;

    gdc = GetDC(NULL);
    if (ExtEscape(gdc, QUERYESCSUPPORT, sizeof(int), (LPCSTR)&iESC,
                  0, NULL)==0) {
        MessageBox(NULL,
                   L"Sorry, your Pocket PC does not support DisplayOff",
                   L"Pocket PC Display Off Feature",
                   MB_OK);
        ReleaseDC(NULL, gdc);
        return FALSE;
    } else {
        VIDEO_POWER_MANAGEMENT vpm;
        vpm.Length = sizeof(VIDEO_POWER_MANAGEMENT);
        vpm.DPMSVersion = 0x0001;
        if (enable) {
            vpm.PowerState = VideoPowerOn;
        } else {
            vpm.PowerState = VideoPowerOff;
        }
        // Power off the display
        ExtEscape(gdc, SETPOWERMANAGEMENT, vpm.Length, (LPCSTR) &vpm,
                  0, NULL);
        ReleaseDC(NULL, gdc);
        return TRUE;
    }
}