Results 1 to 8 of 8

Thread: Make VB6 Aware of Hibernation?

  1. #1
    Variable Bitrate
    Auto Apps:loading...
    mezz64's Avatar
    Join Date
    Nov 2004
    Location
    PA
    Posts
    379
    Blog Entries
    1

    Make VB6 Aware of Hibernation?

    I'm nearly finished with writing an OBD MPG plugin for RR, my only problem is the behavior on resume from hibernate.

    A restart of RR gets things going again so it's not the ELM interface dropping out. So I was going to see if it was possible to make the .dll aware of when the hibernate process was occurring, I could then tell it to close the port, and then do the opposite when it comes back.

    Is this possible with vb6? How do people usually handle hibernation when using an MSComm object? I've been doing a fair bit of google searching but haven't come up with anything useful yet.

    Thanks!

  2. #2

  3. #3
    Variable Bitrate
    Auto Apps:loading...
    mezz64's Avatar
    Join Date
    Nov 2004
    Location
    PA
    Posts
    379
    Blog Entries
    1
    I'm taking a look right now, working on understanding what I'm seeing.

    First off I guess I was a bit off on my terminology in my first post, I'm making a extension plugin, not a base plugin. Whether or not that alters your advice I don't know.

    I see in ModSDK.bas PrepareForHibernate and ResumeFromHibernate subroutines, can I just place the necessary code in these subroutines and have it executed upon entrance and return from hibernation?

    It's been a few years since I've done any programming and I'm just getting used to vb6 and how RR is setup. Thanks for your help!

  4. #4
    Confusion Master
    Auto Apps:loading...
    Enforcer's Avatar
    Join Date
    Sep 2003
    Location
    If you go down to the woods today, You're sure of
    Posts
    14,625
    in ModCom.bas is the important parts


    Code:
     
     
    Private lpPrevWndProc As Long
    Private Const WM_COPYDATA = &H4A
    Private Const GWL_WNDPROC = (-4)
    Private Const SW_HIDE = 0
    Private Const SW_NORMAL = 1
    Private Const WM_POWERBROADCAST = &H218
    Private Const PBT_APMSUSPEND = 4
    Private Const PBT_APMRESUMESUSPEND = 7
     
     
    Private Declare Function CallWindowProc Lib "user32" Alias _
       "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As _
       Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As _
       Long) As Long
     
     
    'Process Window Events
    Private Function WindowProc(ByVal hw As Long, ByVal uMsg As Long, _
             ByVal wParam As Long, ByVal lParam As Long) As Long
     
    Select Case uMsg
        Case WM_COPYDATA 'If our function process data
            Call ReceiveMsg(lParam)
     
        Case WM_POWERBROADCAST 'System is asking about/entering/resuming from standby
            If wParam = PBT_APMSUSPEND Then
                PrepareForHibernate
            End If
            If wParam = PBT_APMRESUMESUSPEND Then
                ResumeFromHibernate
            End If
    End Select
     
    'If we're still hooked
    If lpPrevWndProc <> 0 Then
        ' Call the original window procedure associated with this form.
        WindowProc = CallWindowProc(lpPrevWndProc, hw, uMsg, wParam, lParam)
    Else
        WindowProc = 0
    End If
    End Function

    So if you add ModCom.bas to your project just add PrepareForHibernate and ResumeFromHibernate Public Subs to your project

  5. #5
    Variable Bitrate
    Auto Apps:loading...
    mezz64's Avatar
    Join Date
    Nov 2004
    Location
    PA
    Posts
    379
    Blog Entries
    1
    I've been playing around with this a little bit and so far using private subs in ModCom whenever I put anything in the PrepareForHibernate or ResumeFromHibernate, RR is closed when I resume from hibernate.

    I realized today it might be do to the private subs in ModCom so I moved them into my form and made them public. I'm going to test after work. Any ideas?

  6. #6
    Confusion Master
    Auto Apps:loading...
    Enforcer's Avatar
    Join Date
    Sep 2003
    Location
    If you go down to the woods today, You're sure of
    Posts
    14,625
    You will need to add

    COMHook Me.hwnd


    to form_load

    to enable your program to receive messages.


    And add

    COMUnhook Me.hwnd

    to form_unload

  7. #7
    Variable Bitrate
    Auto Apps:loading...
    mezz64's Avatar
    Join Date
    Nov 2004
    Location
    PA
    Posts
    379
    Blog Entries
    1
    I've got COMHook Me.hwnd in place, i'll add COMUnhook Me.hwnd to the unload routine

    Thanks!

  8. #8
    Variable Bitrate
    Auto Apps:loading...
    mezz64's Avatar
    Join Date
    Nov 2004
    Location
    PA
    Posts
    379
    Blog Entries
    1
    Ok everything is setup I believe the correct way yet RR is still closed every time I return from hibernate. If I comment out the routines RR is fine on return from hibernate, but unfortunately my plugin isn't.

    Any suggestions? I'm attaching my VB6 project, any help would be greatly appreciated.

    Thanks!
    Attached Files Attached Files

Similar Threads

  1. Set RR resolution on resume from hibernation?
    By htsource in forum Road Runner
    Replies: 5
    Last Post: 08-08-2007, 03:05 PM
  2. Replies: 1
    Last Post: 11-28-2006, 09:32 AM
  3. Hibernation drawing too much power...
    By Borte in forum General Hardware Discussion
    Replies: 21
    Last Post: 09-06-2006, 08:03 AM
  4. Phoco and hibernation
    By carlospelos in forum PhoneControl
    Replies: 2
    Last Post: 12-15-2005, 05:04 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •