Results 1 to 7 of 7

Thread: Windows Messages

  1. #1

    Thread Starter
    Addicted Member VB6Coder's Avatar
    Join Date
    Apr 2001
    Location
    Northampton, UK
    Posts
    185

    Question Windows Messages

    Which Windows Message gets raised when you change the icon of an existing File Type?

    Can you also tell me which Windows Message get raised when a file is deleted, renamed or moved?

    Thanks in advance

  2. #2
    Frenzied Member
    Join Date
    Jul 2002
    Posts
    1,370
    Windows messages provide I/O and control over any window (control)

    There are no messages for file deletion. In other words, the OS doesn't send a message, put it in the message queue for the file system that says ' delete file.dat'.

    The same for changing an icon - other than WM_PAINT to refresh a window (if a user requests a repaint).

    When an app makes a request of the kernel it does whatever (file delete, etc) without using messaging. It may cause subsequent messages to be sent, like WM_QUIT. You can see this when you have Windows Explorer open. Delete a file using another app, and the change WILL NOT show up in windows Explorer unless you go into VIEW>REFRESH.

    The reason messages exist is because EVERYTHING on your screen is a window. The OS needs a reliable way to talk to each one as the user requests it.

  3. #3

    Thread Starter
    Addicted Member VB6Coder's Avatar
    Join Date
    Apr 2001
    Location
    Northampton, UK
    Posts
    185
    If you have 2 instances of the Windows Explorer open, and you delete, move or rename a file the other instance updates. The 2 Windows Explorer instances must talk to each other for this to happen. Is there any way of detecting this?

  4. #4
    Frenzied Member
    Join Date
    Jul 2002
    Posts
    1,370
    Um.

    They are actually the 'same' app. They are a single instance of a COM server, residing in the same place in memory, shred by two separate processes.

    Okay. I think I get what you want - it isn't a message it's a series of api's, FindFirstChangeNotification and company. See if this doesn't do what you want:
    Code:
    Private Const FILE_NOTIFY_CHANGE_ATTRIBUTES = &H4
    Private Const FILE_NOTIFY_CHANGE_DIR_NAME = &H2
    Private Const FILE_NOTIFY_CHANGE_FILE_NAME = &H1
    Private Const FILE_NOTIFY_CHANGE_SIZE = &H8
    Private Const FILE_NOTIFY_CHANGE_LAST_WRITE = &H10
    Private Const FILE_NOTIFY_CHANGE_SECURITY = &H100
    Private Const FILE_NOTIFY_CHANGE_ALL = &H4 Or &H2 Or &H1 Or &H8 Or &H10 Or &H100
    Private Declare Function FindFirstChangeNotification Lib "kernel32" Alias "FindFirstChangeNotificationA" (ByVal lpPathName As String, ByVal bWatchSubtree As Long, ByVal dwNotifyFilter As Long) As Long
    Private Declare Function FindCloseChangeNotification Lib "kernel32" (ByVal hChangeHandle As Long) As Long
    Private Declare Function FindNextChangeNotification Lib "kernel32" (ByVal hChangeHandle As Long) As Long
    Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
    Private Declare Function ResetEvent Lib "kernel32" (ByVal hEvent As Long) As Long
    Private Sub Form_Load()
        'KPD-Team 2000
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
        Dim Ret As Long
        'Set the notification hook
        Ret = FindFirstChangeNotification("C:\", &HFFFFFFFF, FILE_NOTIFY_CHANGE_ALL)
        'Wait until the event is triggered
        WaitForSingleObject Ret, &HFFFFFFFF
        MsgBox "Event Triggered for the first time"
        'Reactivate our hook
        FindNextChangeNotification Ret
        'Wait until the event is triggered
        WaitForSingleObject Ret, &HFFFFFFFF
        MsgBox "Event Triggered for the second time"
        'Remove our hook
        FindCloseChangeNotification Ret
    End Sub

  5. #5

    Thread Starter
    Addicted Member VB6Coder's Avatar
    Join Date
    Apr 2001
    Location
    Northampton, UK
    Posts
    185
    Cheers Jim
    I'll have a play around with that.

  6. #6
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286
    But keep in mind, there's not always a window message for everything (e.g. there's no message sent when a file is deleted, created etc.).

  7. #7
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,631
    The problem with WaitForSingleObject is that it locks your thread. Your app won't respond to anything until kernel32 releases it.
    Please rate my post.

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