Landscape() not working on my WinCE 5.0 Device

Landscape() not working on my WinCE 5.0 Device

Postby ChrisMillard » Wed Jul 09, 2008 11:31 pm

Hi

Landscape() makes the standard Portrait screen inverted i.e. it turns 180 degrees.

Portrait() turns the screen 270 degrees. I then have no way to return it to 0 degrees.

This happens with the sample landscap.prg once CE functions added.

What I am actually after is a 90 degree turn, and then the ability to return to 0 degrees.
Regards

Chris Millard
ChrisMillard
 
Posts: 12
Joined: Wed Jul 09, 2008 7:07 pm
Location: Manchester, UK

Postby Antonio Linares » Thu Jul 10, 2008 1:38 am

Chris,

This is the source code for LandScape() and Portrait(). You may modify DMD0_... used constants to get the desired effect:
Code: Select all  Expand view  RUN
HB_FUNC( LANDSCAPE ) // turns the display into landscape
{
   DEVMODE devmode;
   
   memset( &devmode, 0, sizeof( devmode ) );
   devmode.dmSize = sizeof( DEVMODE );
   devmode.dmDisplayOrientation = DMDO_90; //landscape mode
   devmode.dmFields = DM_DISPLAYORIENTATION;
   ChangeDisplaySettingsEx( NULL, &devmode, NULL, 0, NULL );
}

HB_FUNC( PORTRAIT ) // turns the display into portrait
{
   DEVMODE devmode;
   
   memset( &devmode, 0, sizeof( devmode ) );
   devmode.dmSize = sizeof( DEVMODE );
   devmode.dmDisplayOrientation = DMDO_0; // portrait mode
   devmode.dmFields = DM_DISPLAYORIENTATION;
   ChangeDisplaySettingsEx( NULL, &devmode, NULL, 0, NULL );
}   

These are the possible constants to use:

/* rotation angle for screen rotation */
#define DMDO_0 0
#define DMDO_90 1
#define DMDO_180 2
#define DMDO_270 4
#define DMDO_DEFAULT DMDO_0
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby ChrisMillard » Thu Jul 10, 2008 12:23 pm

Thanks for the quick response, I had seen references to ChangeDisplaySettingsEx but was unsure how to implement it.

Here is my attempt to get an Orientation function working.

#include "FWCE.ch"

#DEFINE DMDO_0 0
#DEFINE DMDO_90 1
#DEFINE DMDO_180 2
#DEFINE DMDO_270 4

function Main()

local oWnd, oBtn

DEFINE WINDOW oWnd TITLE "Orientation Test"

@ 2, 2 BUTTON oBtn PROMPT "0" SIZE 80, 25 ACTION Orientation( DMDO_0 )
@ 4, 2 BUTTON oBtn PROMPT "90" SIZE 80, 25 ACTION Orientation( DMDO_90 )
@ 6, 2 BUTTON oBtn PROMPT "180" SIZE 80, 25 ACTION Orientation( DMDO_180 )
@ 8, 2 BUTTON oBtn PROMPT "270" SIZE 80, 25 ACTION Orientation( DMDO_270 )

ACTIVATE WINDOW oWnd ON CLICK MsgInfo( "Click!" )

return nil

function CeSetmenu() ; return nil
function GetMenu() ; return nil
function ReadBitmap() ; return nil
function PalBmpRead() ; return nil

#pragma BEGINDUMP
#include "windows.h"
#include "hbapi.h"
HB_FUNC( ORIENTATION )
{
DEVMODE devmode;

memset( &devmode, 0, sizeof( devmode ) );
devmode.dmSize = sizeof( DEVMODE );
devmode.dmDisplayOrientation = hb_parnl( 1 ) );
devmode.dmFields = DM_DISPLAYORIENTATION;
ChangeDisplaySettingsEx( NULL, &devmode, NULL, 0, NULL );
}
#pragma ENDDUMP


However I get this from BUILDCE

Compiling...
Harbour Compiler Alpha build 46.2 (Flex)
Copyright 1999-2006, http://www.harbour-project.org/
Compiling 'orientat.prg' and generating preprocessed output to 'orientat.ppo'...

Lines 43, Functions/Procedures 5
Generating C source output to 'orientat.c'... Done.
Microsoft (R) C/C++ Optimizing Compiler Version 12.20.9615 for ARM
Copyright (C) Microsoft Corp 1984-2002. All rights reserved.

orientat.c
orientat.prg(35) : error C2059: syntax error : ')'

Line 35 is the memset( &devmode, 0, sizeof( devmode ) );

My C knowledge is very limited so not sure what I am doing wrong.
Regards

Chris Millard
ChrisMillard
 
Posts: 12
Joined: Wed Jul 09, 2008 7:07 pm
Location: Manchester, UK

Postby Antonio Linares » Thu Jul 10, 2008 6:42 pm

Chris,

There is an extra ")" here:

devmode.dmDisplayOrientation = hb_parnl( 1 ) );

Just remove it and it will compile fine
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby ChrisMillard » Sun Jul 13, 2008 12:14 pm

How embarrassing, its always obvious when pointed out.

What makes my shame worse is I had an idea the compiler was reporting a different line number to my editor (Multi Edit 8.0), I also had removed the hb_parnl addition and tried a constant but still left in the offending bracket, when testing myself.

Anyway thankyou for your help the test app has allowed me to discover that my devices 0 degree position is actually in Landscape mode and thus why the FWPPC function appear to misbehave, they of course work as intended as I imagine all other devices default to a Portrait starting position. The device itself must be doing a rotate on startup, its a TouchStar Falcon for reference.
Regards

Chris Millard
ChrisMillard
 
Posts: 12
Joined: Wed Jul 09, 2008 7:07 pm
Location: Manchester, UK

Postby Antonio Linares » Sun Jul 13, 2008 7:55 pm

Chris,

I also needed some time to locate the obvious extra ")". It was there but I was not seeing it :-)

I am glad to know that you have solved it,
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Pocket PC

Who is online

Users browsing this forum: No registered users and 1 guest