hey, how can i make my program flash when the text inside a text box changes, like chat programs when you have a message?
cheers
EDIT: and also how do i disable the X in the top right hand corner?
Printable View
hey, how can i make my program flash when the text inside a text box changes, like chat programs when you have a message?
cheers
EDIT: and also how do i disable the X in the top right hand corner?
Quote:
Originally Posted by JoshUK
VB Code:
Private Declare Function GetActiveWindow Lib "user32.dll" () As Long Private Declare Function FlashWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal wActive As Long) As Long Private Declare Sub Sleep Lib "kernel32" (ByVal dMilliseconds As Long) Private Sub Text1_Change() Dim i As Integer Dim handle As Long ' Handle for the active window Dim rval As Long handle = GetActiveWindow() 'Get the handle of active window For i = 1 To 10 ' Flash five times rval = FlashWindow(handle, 1) 'Flash the window Sleep 500 ' Delay the execution for 1/2 minute Next rval = FlashWindow(handle, 0) ' Bring the window to normal positionQuote:
Originally Posted by JoshUK
VB Code:
Private Const SC_CLOSE As Long = &HF060& Private Const MIIM_STATE As Long = &H1& Private Const MIIM_ID As Long = &H2& Private Const MFS_GRAYED As Long = &H3& Private Const WM_NCACTIVATE As Long = &H86 Private Type MENUITEMINFO cbSize As Long fMask As Long fType As Long fState As Long wID As Long hSubMenu As Long hbmpChecked As Long hbmpUnchecked As Long dwItemData As Long dwTypeData As String cch As Long End Type Private Declare Function GetSystemMenu Lib "user32" ( _ ByVal hWnd As Long, ByVal bRevert As Long) As Long Private Declare Function GetMenuItemInfo Lib "user32" Alias _ "GetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, _ ByVal b As Boolean, lpMenuItemInfo As MENUITEMINFO) As Long Private Declare Function SetMenuItemInfo Lib "user32" Alias _ "SetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, _ ByVal bool As Boolean, lpcMenuItemInfo As MENUITEMINFO) 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 IsWindow Lib "user32" _ (ByVal hWnd As Long) As Long ' Enables / Disables the close button on the titlebar and in the system menu ' of the form window passed. ' Return Values: ' ' 0 Close button state changed succesfully / nothing to do. ' -1 Invalid Window Handle (hWnd argument) Passed to the function ' -2 Failed to switch command ID of Close menu item in system menu ' -3 Failed to switch enabled state of Close menu item in system menu Public Function EnableCloseButton(ByVal hWnd As Long, Enable As Boolean) As Integer Const xSC_CLOSE As Long = -10 ' Check that the window handle passed is valid EnableCloseButton = -1 If IsWindow(hWnd) = 0 Then Exit Function ' Retrieve a handle to the window's system menu Dim hMenu As Long hMenu = GetSystemMenu(hWnd, 0) ' Retrieve the menu item information for the close menu item/button Dim MII As MENUITEMINFO MII.cbSize = Len(MII) MII.dwTypeData = String(80, 0) MII.cch = Len(MII.dwTypeData) MII.fMask = MIIM_STATE If Enable Then MII.wID = xSC_CLOSE Else MII.wID = SC_CLOSE End If EnableCloseButton = -0 If GetMenuItemInfo(hMenu, MII.wID, False, MII) = 0 Then Exit Function ' Switch the ID of the menu item so that VB can not undo the action itself Dim lngMenuID As Long lngMenuID = MII.wID If Enable Then MII.wID = SC_CLOSE Else MII.wID = xSC_CLOSE End If MII.fMask = MIIM_ID EnableCloseButton = -2 If SetMenuItemInfo(hMenu, lngMenuID, False, MII) = 0 Then Exit Function ' Set the enabled / disabled state of the menu item If Enable Then MII.fState = (MII.fState Or MFS_GRAYED) MII.fState = MII.fState - MFS_GRAYED Else MII.fState = (MII.fState Or MFS_GRAYED) End If MII.fMask = MIIM_STATE EnableCloseButton = -3 If SetMenuItemInfo(hMenu, MII.wID, False, MII) = 0 Then Exit Function SendMessage hWnd, WM_NCACTIVATE, True, 0 EnableCloseButton = 0 End Function 'Usage Private Sub Form_Load() 'enabled EnableCloseButton Me.hWnd, True End Sub Private Sub Command1_Click() 'disabled EnableCloseButton Me.hWnd, False End Sub
neither of them seemed to work, do they work in VB5?
Bump :)
I guess not. Just make it visible and not every 50 milliseconds. It should flash.
Change the border stype to 0. No border.
i mean say on MSN when you receive a message when the message window is minimized or behind another program the bar on the task bar flashes, how would i gio about doing that?
According to AllAPI.Net, this API calls should work in VB4(32 bit), VB5 and VB6 (although I've no way of testing them in anything but VB6)Quote:
Originally Posted by JoshUK
What happens when you run that code?
the flash window worked for me, but when i put it in the form load event i flashed the calling window, maybe he wants it to change color, like yahoo's and keeps flashing till it gets focus
you can set me.controlbox to false to hide the X and the other controls, or you can put code in the form unload event to make it do something else, Cancel = True, will stop the unload processQuote:
disable the X in the top right hand corner
pete
thats exactly what i need!, do you have to code for it?Quote:
Originally Posted by westconn1
nope, probably have to send message to titlebar,
someone else may be able to tell you how it is done now they know what you want
pete
have a look here, there is 3 example to flashing the window
vbnet
rgds pete
http://vbnet.mvps.org/index.html?code/forms/index.html
this one does exactly what i want it to do, but i can't seem to impliment it into my program, on txtmain_change