Computing.Net > Forums > Programming > VB Problem

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

VB Problem

Reply to Message Icon

Original Message
Name: henry_joshua
Date: April 7, 2005 at 02:48:21 Pacific
Subject: VB Problem
OS: Win XP
CPU/Ram: p4,128
Comment:

Dear Friends, I am using VB MDI Forms and I want that whenever the focus is on the Form the TASKBAR MUST BE HIDDEN. i.e. this form must occupy the entire screen.

Pls help

thanx

Joshua


Report Offensive Message For Removal


Response Number 1
Name: RugZ
Date: April 7, 2005 at 07:28:34 Pacific
Reply: (edit)

You may need to use the Win32 API on how to hide the taskbar e.g. use the FindWindow API to locate the taskbar i.e

Private Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

called as follows i.e

lngHandle=FindWindow("Shell_TrayWind", "") then use the Show window API to hide or show the Taskbar i.e.

ShowWindow lngHandle, 0

The ShowWindow API is declared as follows:

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

hwnd is the handle to the window you want to show or hide, in this case the handle of the task bar. The handle is obtained by the FIndWindow API which returns the handle stored in the lngHandle variable. nCmdShow argument specifies whether you want to show the window or hide it, in this case we pass a value 0 to denote hiding the window.
If you want to show the window(taskbar) pass nCmdShow a value other than zero eg 5 i.e

ShowWindow lngHandle, 5

Try passing a value of 2

Hope this helps


Report Offensive Follow Up For Removal

Response Number 2
Name: StuartS
Date: April 7, 2005 at 07:48:38 Pacific
Reply: (edit)

The above will work but the following is the reccomended way using the SetWindowPos API.

Private Sub Command1_Click()
Dim cx As Long
Dim cy As Long
Dim RetVal As Long

' Determine if screen is already maximized.
If Me.WindowState = vbMaximized Then
' Set window to normal size
Me.WindowState = vbNormal
End If

' Get full screen width.
cx = GetSystemMetrics(SM_CXSCREEN)

' Get full screen height.
cy = GetSystemMetrics(SM_CYSCREEN)

' Call API to set new size of window.
RetVal = SetWindowPos(Me.hwnd, HWND_TOP, 0, 0, cx, cy, _
SWP_SHOWWINDOW)
End Sub


Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, _
ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

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

Public Const SM_CXSCREEN = 0
Public Const SM_CYSCREEN = 1
Public Const HWND_TOP = 0
Public Const SWP_SHOWWINDOW = &H40

Stuart


Report Offensive Follow Up For Removal

Response Number 3
Name: henry_joshua
Date: April 7, 2005 at 22:09:57 Pacific
Reply: (edit)

Dear Friends,
Both the above procedures doesn't works. Nothing happens with the Task Bar.

Pls help

Thanx

Joshua


Report Offensive Follow Up For Removal

Response Number 4
Name: StuartS
Date: April 8, 2005 at 04:17:36 Pacific
Reply: (edit)

Its not meant to do anything to the task bar. If fact it is impossible to do anything with the task bar from within an application.

What the API is supposed to do though is extend the window size so it covers the task bar. The normal max window function would only go as far as the task bar and leave it visible.

Stuart


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home








Do you have your own blog?

Yes
No
I did before
I will soon


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge
Poll History




Data Recovery Software