Results 1 to 3 of 3

Thread: Change Start Menu Settings Problem!!

  1. #1

    Thread Starter
    Hyperactive Member TupacShakur's Avatar
    Join Date
    Mar 2002
    Location
    Da Land Of Da Heartless...
    Posts
    493

    Thumbs up Change Start Menu Settings Problem!!

    Hey...
    I posted a Help-Message a week ago asking for some help on how to change the start menu settings.
    Someone posted a Zip Project Sample, including a Class Module(Thanx a lot!!)
    Anyway, that module needed some refinement so i've done some changes to it, and i got it working almost properly. I just faced a few problems that i could not work out!! Here:

    After making the exe, i run it and did some changes to the start button. As soon as i exited the application, everything seemed to be just fine. But when i first used the start button, its image disappeared, without reseting to the default one. instead, the button face went BLANK, although all other changes remained (size, position...)!!!
    when i restarted Windows, all start settings were reset to the default state (including the start image)!

    Then, i noticed something:
    ---------------------------------
    When i was running the program from the VB Project, the image disappearing only happened when i stopped the program, AND closed the folder containing the project!!
    If i exited the project, without closing the folder, or if i stopped the Run of the program, without closing both the project and the folder, and used the start, its image will remian as i set it!
    P.S: the image i was using was located in another Drive, so i don't think it's related to the Default Directory thing!!!

    Anyway, please someone, HELP - SOS - PLEASE!!!!
    Sorry 4 this long message... Down is the module i'm using:

    MODULE:
    -----------

    VERSION 1.0 CLASS
    BEGIN
    MultiUse = -1 'True
    Persistable = 0 'NotPersistable
    DataBindingBehavior = 0 'vbNone
    DataSourceBehavior = 0 'vbNone
    MTSTransactionMode = 0 'NotAnMTSObject
    END
    Attribute VB_Name = "cStartButton"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = True
    Attribute VB_PredeclaredId = False
    Attribute VB_Exposed = False

    Private Declare Function FindWindowEx Lib "User32" Alias "FindWindowExA" (ByVal hwnd As Long,

    ByVal hWndChild As Long, ByVal lpszClassName As Any, ByVal lpszWindow As Any) As Long
    Private Declare Function LoadImage Lib "User32" Alias "LoadImageA" (ByVal hInst As Long, ByVal

    lpsz As String, ByVal iImageType As Long, ByVal cx As Long, ByVal cy As Long, ByVal fFlags As

    Long) As Long
    Private Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal

    wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Private 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
    Private Declare Function GetWindowRect Lib "User32" (ByVal hwnd As Long, lpRect As Rect) As Long
    Private Declare Function GetWindowPlacement Lib "User32" (ByVal hwnd As Long, lpwndpl As

    WindowPlacement) As Long

    Private Type PointApi
    x As Long
    y As Long
    End Type

    Private Type Rect
    Left As Long
    top As Long
    Right As Long
    Bottom As Long
    End Type

    Private Type WindowPlacement
    Length As Long
    Flags As Long
    ShowCmd As Long
    MinPosition As PointApi
    MaxPosition As PointApi
    NormalPosition As Rect
    End Type

    Private Const Bm_GetImage = &HF6
    Private Const Bm_SetImage = &HF7

    Private Const Img_Bitmap = &H0

    Private Const Lr_DefaultColor = &H0
    Private Const Lr_LoadFromFile = &H10
    Private Const Lr_DefaultSize = &H40

    Private Const Swp_Position = &H1
    Private Const Swp_Size = &H2

    Private hTaskbar As Long, hStartButton As Long, hOriginal As Long, hCustom As Long
    Private ButtonWidth As Long, ButtonHeight As Long, ButtonLeft As Long, ButtonTop As Long

    Private Sub Class_Initialize()
    Dim r As Rect, wp As WindowPlacement: wp.Length = Len(wp)
    hTaskbar = FindWindowEx(0, 0, "Shell_TrayWnd", 0&)
    hStartButton = FindWindowEx(hTaskbar, 0, "BUTTON", 0&)
    hOriginal = SendMessage(hStartButton, Bm_GetImage, Img_Bitmap, ByVal 0&)
    GetWindowRect hStartButton, r
    GetWindowPlacement hStartButton, wp
    ButtonWidth = (r.Right - r.Left) * 15
    ButtonHeight = (r.Bottom - r.top) * 15
    ButtonLeft = wp.NormalPosition.Left * 15
    ButtonTop = wp.NormalPosition.top * 15
    End Sub

    Sub RestoreAll()
    SendMessage hStartButton, Bm_SetImage, Img_Bitmap, ByVal hOriginal
    SetWindowPos hStartButton, 0, 0, 0, ButtonWidth / 15, ButtonHeight / 15, Swp_Size
    SetWindowPos hStartButton, 0, ButtonLeft / 15, ButtonTop / 15, 0, 0, Swp_Position
    End Sub

    Property Let Bitmap(ByVal Filename As String)
    If Filename <> "" Then
    hCustom = LoadImage(0&, Filename, Img_Bitmap, 0, 0, Lr_DefaultColor Or Lr_LoadFromFile Or

    lr_defaulsize)
    SendMessage hStartButton, Bm_SetImage, Img_Bitmap, ByVal hCustom
    Else
    SendMessage hStartButton, Bm_SetImage, Img_Bitmap, ByVal 0&
    End If
    End Property

    Property Get Width() As Long
    Dim r As Rect
    GetWindowRect hStartButton, r
    Width = (r.Right - r.Left) * 15
    End Property

    Property Let Width(ByVal Width As Long)
    SetWindowPos hStartButton, 0, Left / 15, top / 15, Width / 15, height / 15, Swp_Size
    End Property

    Property Get height() As Long
    Dim r As Rect
    GetWindowRect hStartButton, r
    height = (r.Bottom - r.top) * 15
    End Property

    Property Let height(ByVal height As Long)
    SetWindowPos hStartButton, 0, Left / 15, top / 15, Width / 15, height / 15, Swp_Size
    End Property

    Property Get Left() As Long
    Dim wp As WindowPlacement
    wp.Length = Len(wp)
    GetWindowPlacement hStartButton, wp
    Left = wp.NormalPosition.Left * 15
    End Property

    Property Let Left(ByVal Left As Long)
    SetWindowPos hStartButton, 0, Left / 15, top / 15, 0, 0, Swp_Position
    End Property

    Property Get top() As Long
    Dim wp As WindowPlacement
    wp.Length = Len(wp)
    GetWindowPlacement hStartButton, wp
    top = wp.NormalPosition.top * 15
    End Property

    Property Let top(ByVal top As Long)
    SetWindowPos hStartButton, 0, Left / 15, top / 15, 0, 0, Swp_Position
    End Property

  2. #2
    Addicted Member
    Join Date
    Feb 2002
    Location
    Belgium
    Posts
    190
    look on the next thread http://www.vbforums.com/showthread.p...hreadid=164004

    mayby you will find here a solution for your problem

  3. #3

    Thread Starter
    Hyperactive Member TupacShakur's Avatar
    Join Date
    Mar 2002
    Location
    Da Land Of Da Heartless...
    Posts
    493

    Exclamation I'm Not Sure!!!

    This thread is about a module to manipulate Data Base Files(*.db, *.dbf)...
    Are u sure that this is the right link??

Posting Permissions

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



Click Here to Expand Forum to Full Width