Showing posts with label Coding_PPC. Show all posts

How To Run an eMbedded Visual Basic Application Full Screen on a Pocket PC Device

Written By Akki On Tuesday, November 6, 2007

link to MSDN

How To Run an eMbedded Visual Basic Application Full Screen on a Pocket PC Device

Article ID:265451
Last Review:July 13, 2004
Revision:3.1
This article was previously published under Q265451

SUMMARY

This article illustrates how to programmatically manipulate the various screen objects on a Pocket PC device by using the SHFullScreen API function from an eMbedded Visual Basic (eVB) application.

It is popular for applications that target Windows CE to use as much of the screen of the smaller Palm-sized devices as possible. The new user interface (UI) of the Pocket PC platform requires additional work for an application to use the full screen area.

Back to the top

MORE INFORMATION

To understand the comments in the code examples in the article, the new Pocket PC UI terms are described as follows:
The taskbar is located at the top of the screen, it displays application captions, and gives the user the ability to start applications.

The command bar, also known as the menu bar, is located at the bottom of the screen.

The soft input panel (SIP) button is located on the command bar, to the lower-right corner of the screen.
To create a window that uses as much of the screen as possible, the application calls SHFullScreen to hide these elements.

Back to the top

Step-by-Step Example

1.Start eMbedded Visual Basic, and create a new Windows CE for the Pocket PC project.
2.Add four CommandButton controls to Form1.
3.Paste the following code into Form1:
Option Explicit

Const SW_HIDE = 0
Const SW_SHOWNORMAL = 1

Const SHFS_SHOWTASKBAR = &H1
Const SHFS_HIDETASKBAR = &H2
Const SHFS_SHOWSIPBUTTON = &H4
Const SHFS_HIDESIPBUTTON = &H8
Const SHFS_SHOWSTARTICON = &H10
Const SHFS_HIDESTARTICON = &H20
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2

Const SWP_SHOWWINDOW = &H40
Const SM_CXSCREEN = &H0
Const SM_CYSCREEN = &H1
Const HHTASKBARHEIGHT = 26

Dim bShowMenu As Boolean
Dim bShowStart As Boolean
Dim bShowTaskbar As Boolean
Dim bFullScreen As Boolean
Dim lHwnd As Long

Declare Function GetSystemMetrics Lib "Coredll" ( _
ByVal nIndex As Long) As Long

Declare Function SHFullScreen Lib "aygshell" ( _
ByVal hwndRequester As Long, _
ByVal dwState As Long) As Boolean

Declare Function MoveWindow Lib "Coredll" ( _
ByVal hwnd As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal nWidth As Long, _
ByVal nHeight As Long, _
ByVal bRepaint As Long) As Long

Declare Function SetForegroundWindow Lib "Coredll" ( _
ByVal hwnd As Long) As Boolean

Declare Function GetLastError Lib "Coredll" () As Long

Declare Function ShowWindow Lib "Coredll" ( _
ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long

Declare Function FindWindow Lib "Coredll" Alias "FindWindowW" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

Private Sub Form_Load()
bShowMenu = True
bShowStart = True
bShowTaskbar = True
bFullScreen = False
lHwnd = Form1.hwnd
Command1.Caption = "Full Screen"
Command2.Caption = "Hide Menu"
Command3.Caption = "Hide Start"
Command4.Caption = "Hide Taskbar"
Command4.Visible = False
Command1.Move 120, 480, 1335, 495
Command2.Move 120, 1080, 1335, 495
Command3.Move 120, 1680, 1335, 495
Command4.Move 120, 2280, 1335, 495
End Sub

Private Sub Form_OKClick()
App.End
End Sub

Private Sub Command1_Click()
Dim lret
If bFullScreen Then
lret = FindWindow("menu_worker", "")
If lret <> 0 Then 'window found
ShowWindow lret, SW_SHOWNORMAL
End If
lret = SetForegroundWindow(Me.hwnd)
lret = MoveWindow(Me.hwnd, 0, HHTASKBARHEIGHT, _
GetSystemMetrics(SM_CXSCREEN), _
GetSystemMetrics(SM_CYSCREEN), True)
Command1.Caption = "Full Screen"
Else
'show form full screen
lret = FindWindow("menu_worker", "")
If lret <> 0 Then 'window found
ShowWindow lret, SW_HIDE
End If
lret = SetForegroundWindow(Me.hwnd)
lret = MoveWindow(Me.hwnd, 0, 0, _
GetSystemMetrics(SM_CXSCREEN), _
GetSystemMetrics(SM_CYSCREEN) + HHTASKBARHEIGHT, 0)
Command1.Caption = "Not Full Screen"
End If
bFullScreen = Not bFullScreen
Command4.Visible = bFullScreen
End Sub

Private Sub Command2_Click()
Dim lret
lret = SetForegroundWindow(lHwnd)
If bShowMenu Then
lret = SHFullScreen(lHwnd, SHFS_HIDESIPBUTTON)
Command2.Caption = "Show Menu"
Else
lret = SHFullScreen(lHwnd, SHFS_SHOWSIPBUTTON)
Command2.Caption = "Hide Menu"
End If
bShowMenu = Not bShowMenu
End Sub

Private Sub Command3_Click()
Dim lret
lret = SetForegroundWindow(lHwnd)
If bShowStart Then
lret = SHFullScreen(lHwnd, SHFS_HIDESTARTICON)
Command3.Caption = "Show Start"
Else
lret = SHFullScreen(lHwnd, SHFS_SHOWSTARTICON)
Command3.Caption = "Hide Start"
End If
bShowStart = Not bShowStart
End Sub

Private Sub Command4_Click()
Dim lret
lret = SetForegroundWindow(lHwnd)
If bShowTaskbar Then
lret = SHFullScreen(lHwnd, SHFS_HIDETASKBAR)
Command4.Caption = "Show TaskBar"
Else
lret = SHFullScreen(lHwnd, SHFS_SHOWTASKBAR)
Command4.Caption = "Hide TaskBar"
End If
bShowTaskbar = Not bShowTaskbar
End Sub
4.Run the project and test the functionality by clicking the CommandButtons.

Back to the top

REFERENCES

For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
266244 (http://support.microsoft.com/kb/266244/EN-US/) How To Create Full-Screen Applications for the Pocket PC

Share and Enjoy:
  • del.icio.us
  • StumbleUpon
  • Digg
  • Sphinn
  • Facebook
  • Mixx
  • Reddit
  • Technorati
  • IndianPad
  • YahooMyWeb

How To Distribute an eMbedded Visual Basic Application

Written By Akki

Link to MSDN

How To Distribute an eMbedded Visual Basic Application

Article ID:307595
Last Review:January 16, 2006
Revision:3.0
This article was previously published under Q307595

SUMMARY

After you complete the development and testing of an eMbedded Visual Basic (eVB) application, you need to properly compile, distribute, and install the application on target devices. The purpose of this article is to guide you through the steps necessary to complete this process by using the Application Install Wizard, which is included with the eMbedded Visual Tools (eVT), and to provide information on some of the issues that may come up during the distribution process.

Back to the top

MORE INFORMATION

The Application Install Wizard handles the creation of the installation package for your application (including the project and all of the necessary supporting files) and takes care of downloading the required components to Microsoft Windows CE-based devices.

This article assumes that your application has been fully tested for use on the targeted Windows CE devices and that the project has been compiled into a .vb file before you create the installation package for your project by using the Application Install Wizard. Note that, unlike the Package and Deployment Wizard in Microsoft Visual Basic, the eVB Application Install Wizard does not give you the option of recompiling the program.

By default, the folder in which compiled eVB applications are placed is:
C:\Program Files\Microsoft eMbedded Tools\EVB
Of course, you can compile the application to the location of your choice.

The Application Install Wizard can be accessed by selecting it from the Remote Tools submenu under the Tools menu in the eVB design environment.

Back to the top

Creating the Installation Program

1.Start the Application Install Wizard. An introduction screen will appear. Click Next to begin.
2.The step 2 page of the Application Install Wizard appears. It prompts you for the full path to the .ebp project file. Click Browse to go to the correct location. Click Next to continue.
3.In step 3, you are prompted for the full path to the compiled .vb file. Click Browse to go to the correct location. eVB will save the .vb file to the location you specified when the .vb file was compiled. Click Next to continue.

Note If you have not yet compiled the .vb file, when you click Next, you receive the following error message:
The build file is invalid or does not exist. It is required that the eMbedded Basic Project file be compiled before installation wizard runs.
4.In step 4, you are prompted for the full path to where the Setup folder is to be created. The Application Install Wizard outputs all components that will be distributed to this folder. (Specific information on the files generated and output to this folder is provided later in this article.) Provide an appropriate path, and then click Next to continue.

Note If the following error occurs, the VBCE.ini file may be damaged, missing, or incomplete:
Unable to find list of available processors from the SDK specified by this project. Please verify that the most recent version of this platform SDK has been installed on your system.


The VBCE.ini file should include processor information for each of the installed Platform SDKs. The format of a platform section should look something like this:
[{0B7D1301-289F-11D2-974F-00A0240918F0}]
SH 3 (1K) v2.0=4,3,2,0,1024,10003
Mips 3000 (4K) v2.0=1,3,2,0,4096,4000
Mips 4000 (1K) v2.0=1,4,2,0,1024,4000
If the VBCE.ini file is not present or the necessary information is not present, reinstall the appropriate Platform SDK.
5.In step 5, you are prompted to select the target processors. You must select at least one processor. Although your application is the same across all processors, the run-time components and ActiveX controls that are to be distributed with your project are processor-specific. This step in the process tells the Wizard which processor-specific files are to be included with the distribution package. Click Next to continue.
6.In step 6, you choose the ActiveX controls that must be distributed and installed with your application. If an ActiveX control is not supported for a processor you selected in step 5, it will not appear on the list of available controls. Click Next to continue.

Note If no ActiveX controls are listed in step 6, the VBCE.ini file may be damaged, missing, or incomplete.
7.In step 7, you can include any additional files that you want to distribute with your program. This could include data, text, or any other files. Once a file has been selected, the wizard will ask whether the file selected is a system file. All system files are installed to the \Windows folder. All other files are installed to the application folder. If you decide to include the device run-time in the .cab file, the following files will be included:
pvbform2.dll
pvbhost2.dll
pvbload.exe
vbscript.dll
vbsen.dll (for Windows CE 2.11-based platforms only)
If the device you are targeting already has the eVB run-time files installed (either in ROM or in RAM), you can clear this check box to minimize the size of the installation package. Click Next to continue.
8.In step 8, you specify the following:
Default install directory
Application name
Description
Company name
Each field must be filled in. The default install directory will include "Program Files\" plus whatever folder name that you provide. For example, if you specify "MyApp" as the install directory, the Application Install Wizard will install the program to the "Program Files\MyApp" folder. This information can be modified in the .inf file after the package is created if a different install path is preferred.

The application name that you provide will be the name that your application is given on the Windows CE device. Click Next to continue.
9.In step 9, you have one last chance to cancel the process. Click Create Install to begin the process of generating the installation package. Click Finish when the process has completed.
The Application Install Wizard creates the following directories, based on the processors you specified in step 7, in the location that you specified in step 4.

For Windows CE HPC Pro projects:

\App
\Arm 1100 (4K) v2.10
\Cd1
\Mips 4000 (1k) v2.10
\SH 3 (1k) v2.10
\SH 4 (4K) v2.10

For Windows CE Palm-size PC projects:

\App
\Cd1
\Mips 3000 (4k) v2.11
\Mips 4000 (1k) v2.11
\SH 3 (1k) v2.11

For PocketPC projects:

\App
\Arm 1100 (4K) v3.00
\Arm 720T (4K) v3.00
\Cd1
\Mips 4000 (4k) v3.00
\SH 3 (1k) v3.00

For Handheld PC 2000 projects:

\App
\Arm 1100 (4K) v3.00
\CD1
\I486 (4K) v3.00
\Mips 3000 (4k) v3.00
\Mips 4000 (4k) v3.00
The "App" directory includes the compiled .vb file as well as any additional files that were specified in step 7 above.

The "CD1" directory includes the Setup.exe file that will be started from the desktop to install the application on a remote device. Also in this directory are the .cab files for the appropriate processors and the initialization file for the Setup program.

The remaining directories include the processor-specific eVB run-time and ActiveX Control files that were specified during the Wizard process.

For more information, see the "References" section of this article.

Back to the top

Distributing and Installing the Application

Only the contents of the Cd1 directory need to be distributed in order to install the application on the device.

To install your application, run the Setup.exe program on your desktop computer. The first dialog box that appears allows the user to select the location on the desktop to which the application's .cab and .ini files will be copied. If the handheld device is connected to the desktop, the program will be downloaded and installed. Otherwise, this will occur on the next connection.

To remove a program from the handheld device, run the Remove Programs tool. To access it, from the Start menu on the device, click Settings.

Back to the top

REFERENCES

For additional information, click the article numbers below to view the articles in the Microsoft Knowledge Base:
194837 (http://support.microsoft.com/kb/194837/EN-US/) How To Distribute a Visual Basic Windows CE Application
185223 (http://support.microsoft.com/kb/185223/EN-US/) How To Manually Uninstall Visual Basic CE Programs
240435 (http://support.microsoft.com/kb/240435/EN-US/) PATCH: WCELoad.exe Fixes ActiveX Control Hanging Problem on Palm-size PC
242312 (http://support.microsoft.com/kb/242312/EN-US/) How To Distribute an ADOCE 2.0 Application to a PsPC Device
For more information concerning how to customize the installation to handle additional nondefault preferences, see the following MSDN topic:
Using the CAB Wizard
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcesetup/html/_wcesdk_Using_the_CAB_Wizard.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcesetup/html/_wcesdk_Using_the_CAB_Wizard.asp)

Back to the top


APPLIES TO
Microsoft eMbedded Visual Basic 3.0

Back to the top

Keywords:
kbhowto KB307595

Share and Enjoy:
  • del.icio.us
  • StumbleUpon
  • Digg
  • Sphinn
  • Facebook
  • Mixx
  • Reddit
  • Technorati
  • IndianPad
  • YahooMyWeb