?
Solved

Start app minimized in vb.net (2005) Compact Framework

Posted on 2010-01-05
8
Medium Priority
?
933 Views
Last Modified: 2013-11-26
Hey All,

I've found a few examples for this, but I can't get any of them to work and/or I don't understand them. I have a small compact framework vb.net (2005) app that's running on a Windows CE 5.0 device. I want to start the application minimized, but of course that's not an option in the WindowState property of the form.

Can someone walk me through doing this?

Thanks,
Bret
0
Comment
Question by:FOS-Bret
  • 4
  • 3
8 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 26185291
Have you tried Me.Hide() in the form load event?
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Me.Hide()
End Sub

Open in new window

0
 

Author Comment

by:FOS-Bret
ID: 26185321
I have tried that, but when I do that, I can't get the app to come back to the front (with ALT-TAB).

There's a minimize button and it works perfectly. I just want to do what it does, but programatically.

Thanks,
Bret
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 1000 total points
ID: 26190441
Ok. The best I could come up with is to put the "Minimize" code on a timer (because just calling the code from Form_Load didn't seem to work). It's not ideal to your situation, but it does work. This was tested on my Win Mobile 6.0 pocket pc and one of the CE 5.0 emulators in VS.

I tried to give meaningful comments, but if you don't understand any part of it, please feel free to ask :)
Imports System.Runtime.InteropServices

Public Class Form1
    ' Per documentation, Delegates in WinMobile must derive
    '  from EventHandler
    Private sw As New EventHandler(AddressOf DelegateFunction)

    ' Constant - Instructs ShowWindow() to minimize
    Private Const SW_MINIMIZED As Integer = 6

    ' Interop function call = Used to access the native
    '    function ShowWindow, which is used to minimize the form
    <DllImport("coredll.dll")> _
    Public Shared Function ShowWindow(ByVal hWnd As IntPtr, ByVal nCmdShow As Integer) As Boolean
    End Function

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ' Create a new thread so that Form_Load can return
        Dim minimizeThread As New System.Threading.Thread(AddressOf MinimizeFormAfterSleep)

        ' Execute the thread
        minimizeThread.Start()
    End Sub

    Private Sub MinimizeFormAfterSleep()
        ' Pseudo-timer
        System.Threading.Thread.Sleep(4000)  ' Change 4000 (4 seconds) to a time more fitting to your needs

        ' Call the delegate that runs the minimize code
        Me.Invoke(sw, Me, EventArgs.Empty)
    End Sub

    Private Sub DelegateFunction(ByVal sender As Object, ByVal e As EventArgs)
        ' Execute the minimize code
        ShowWindow(Me.Handle, SW_MINIMIZED)
    End Sub

End Class

Open in new window

0
Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

 
LVL 8

Expert Comment

by:deepu chandran
ID: 26209230
hi,
Please fin the MSDN link already discussed,
http://social.msdn.microsoft.com/Forums/en-US/netfxcompact/thread/777da0d8-2930-46d1-b452-591b766b5d86

In that link there is an OpenNetCF solution can try out.

Regards

Deepu
0
 

Author Comment

by:FOS-Bret
ID: 26298216
I'm sorry for the delay in responding. I was called away from work for several days. My laptop died while I was away, so I'm now waiting for a restore to get my code back. I should have it tomorrow or the next day and I'll try the suggestions out a that time.

Thanks,
Bret
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 26303617
No worries  :)
0
 

Author Closing Comment

by:FOS-Bret
ID: 31673165
This worked great and it was first. Thanks very much.
Bret
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 26326877
NP. Glad to help :)
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month17 days, 2 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question