PPCGeeks

PPCGeeks (http://forum.ppcgeeks.com/index.php)
-   HTC Apache (http://forum.ppcgeeks.com/forumdisplay.php?f=14)
-   -   Slide to Text? (http://forum.ppcgeeks.com/showthread.php?t=7375)

sublynx 08-19-2007 06:29 PM

would it be possible to grab the source code for this application?

I'm an avid vb6/vb net developer, but haven't yet tried to write code for the ppc platform. the part I'm most interested in is how to detect the slide (you said you query the window rotation). Is that on a timer? or does it hook and get the message automatically? I'm not sure if its just my device, but on slide it takes 2-3 seconds before the messaging app appears and another 2-3 seconds for it to close/minimize.

tiermann 08-19-2007 07:00 PM

Quote:

Originally Posted by sublynx
would it be possible to grab the source code for this application?

I'm an avid vb6/vb net developer, but haven't yet tried to write code for the ppc platform. the part I'm most interested in is how to detect the slide (you said you query the window rotation). Is that on a timer? or does it hook and get the message automatically? I'm not sure if its just my device, but on slide it takes 2-3 seconds before the messaging app appears and another 2-3 seconds for it to close/minimize.

Since the SlideSoundService doesn't actually have a form it uses a Sub Main() with a loop sleeping for 250ms each cycle (if screen.primaryscreen.bounds.height). The most it should be off noticibly is by half a second (+ or - the processing time which isn't humanly noticeable) when running the application. The rest of the lag comes from how fast windows mobile and the device can process the shell request.

If I can clean my code up a bit, I'll post it on the ftp, but for now it's sloppy as heck, hehe.

Basically the module looks like this...
Code:

    Public running As Boolean
    Public old_height = Screen.PrimaryScreen.Bounds.Height
    Private Declare Sub sapiSleep Lib "coredll" Alias "Sleep" (ByVal dwMilliseconds As Long)



    Public Sub sSleep(ByVal lngMilliSec As Long)
        If lngMilliSec > 0 Then
            Call sapiSleep(lngMilliSec)
        End If
    End Sub

    Public Sub Main(ByVal cmdArgs() As String)
        running = True
        Registry.SetValue(regKey, "Running", True)

        Do While running = True
            If Screen.PrimaryScreen.Bounds.Height <> old_height And old_height = 240 Then
                old_height = Screen.PrimaryScreen.Bounds.Height
                If playSounds Then playIn()
                If RunApps Then launchapp(slideInApp, "In")

            ElseIf Screen.PrimaryScreen.Bounds.Height <> old_height And old_height = 320 Then
                old_height = Screen.PrimaryScreen.Bounds.Height
                If playSounds Then playOut()
                If RunApps Then launchapp(slideOutApp, "Out")
            End If
            sSleep(250)
            running = Registry.GetValue(regKey, "Running", False)
            If running = False Then Exit Sub
            slideInApp = Registry.GetValue(regKey, "SlideInApp", "\Windows\calc.exe")
            slideOutApp = Registry.GetValue(regKey, "SlideOutApp", "\Windows\calc.exe")
            playSounds = Registry.GetValue(regKey, "PlaySounds", True)
            RunApps = Registry.GetValue(regKey, "RunApps", False)

            Application.DoEvents()
        Loop

    End Sub

SlideSound (the config panel) sets the "Running" regkey to false to stop the service.

gguruusa 08-19-2007 08:45 PM

Ugh. You need to change it to be event driven. Polling should have died with VB6.

tiermann 08-19-2007 08:53 PM

Which event?

sublynx 08-19-2007 09:03 PM

I've been researching this for several hours now, but there is very limited documentation that I've been able to come across. What I'm trying to find out is just how and where the physical act of sliding the keyboard out triggers the screen rotation. Does anyone know if its linked to a hardware button?

If i can find that button i can hook into it, if not I've been looking into writing a Today Screen plugin, which would allow me (i think) even greater flexibility. I only really want the messaging app to appear if I'm on the today screen, if I'm in my email wanting to reply its a bit of a pain. If i can write the plugin to just sit there invisible, i think you would have to be on the today screen for the ScreenOrientation event to be raised. If so i can attempt to go as far as disable the today screen while in landscape mode, thus saving the time to render it before opening the messaging app and instantly pop up my messaging. Sound feasible to anyone? Tips appreciated, as well as good sites with sample code/forums for cf2 vb net or c# programming.

tiermann 08-19-2007 10:04 PM

http://www.freevbcode.com/ShowCode.asp?ID=4042

If that's possible using coredll you'd be able to output the keypresses to a textbox and see what the value is for the slide function. I'm going to mess around a bit.

gguruusa 08-19-2007 11:12 PM

That's unlikely to produce anything, as it is designed to tell you about key states that, when passed to the keytranslator, results in a keycode. Try this: Microsoft.WindowsMobile.Status namespace

tiermann 08-19-2007 11:36 PM

Thanks, gguruusa :)

That helps a lot. I'm going to try this out tonight and see if I can convert most of what I have.

Edit: This is much nicer. It's working like it did before but it's actually using the event (SystemProperty.DisplayRotation) instead of pooling from that loop. I'll see what I can come up with for tomorrow. Thanks again.

Edit: The problem I'm running into now (with the launched application not staying in foreground) seems to be that the OS is setting the last foreground application (from the previous screen orientation) as foreground after the screen update completes so it negates my foreground setting. I would have to wait until after the redraw to set the launched app to foreground.


All times are GMT -4. The time now is 08:19 PM.

Powered by vBulletin® ©2000 - 2025, Jelsoft Enterprises Ltd.
©2012 - PPCGeeks.com


Content Relevant URLs by vBSEO 3.6.0