WM_DEVICECHANGE ???????

WM_DEVICECHANGE ???????

Postby lailton.webmaster » Wed Mar 24, 2010 2:16 am

How capture this event in fivewin.

i wanna know when is pluged a pen drive or other hardware disk

http://msdn.microsoft.com/en-us/library ... 85%29.aspx

someone can help me ?
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: WM_DEVICECHANGE ???????

Postby lailton.webmaster » Wed Mar 24, 2010 5:02 pm

up !
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: WM_DEVICECHANGE ???????

Postby lailton.webmaster » Sat Mar 27, 2010 4:57 am

go top
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: WM_DEVICECHANGE ???????

Postby lailton.webmaster » Mon Mar 29, 2010 12:04 am

up. :roll:
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: WM_DEVICECHANGE ???????

Postby anserkk » Mon Mar 29, 2010 5:09 am

Dear Mr.Lailton,

May be useful for you

To detect the Hardware device change, the operating system will send a WM_DEVICECHANGE message to the application when a device change is detected. All we
need to do is handle this message in the window procedure of the application. When the window procedure is called the parameters passed will be as follows.

Parameter & Description
HWND hWnd Handle to the window
UINT uiMessage WM_DEVICECHANGE
WPARAM wParam Device-change event
LPARAM lParam Event-specific data

This means, hWnd will be the handle to our window, uiMessage will be the window
message WM_DEVICECHANGE, wParam will be the device-change event such as
DBT_DEVICEARRIVAL or DBT_DEVICEREMOVECOMPLETE, and finally lParam is a pointer to
the device broadcast header. Below is an example of how you could implement a handler
for WM_DEVICECHANGE

Code: Select all  Expand view  RUN

LRESULT CALLBACK WindowProcedure(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
switch (uiMsg)
  {
     case WM_DEVICECHANGE:
     {
        PDEV_BROADCAST_HDR pHdr = (PDEV_BROADCAST_HDR) lParam;
        switch (wParam)
        {
           case DBT_DEVICEARRIVAL:
              MessageBox(hWnd, "A device has been inserted.", "USB Notice", MB_OK);
           break;
           case DBT_DEVICEREMOVECOMPLETE:
              MessageBox(hWnd, "A device has been removed.", "USB Notice", MB_OK);
           break;
        }
     }
     break;
     default:
        return DefWindowProc(hWnd, uiMsg, wParam, lParam);
     break;
  }
  return 0;
}


This code will display a message box when a new device is inserted or removed from the
system, with an appropriate message.

Regards
Anser
User avatar
anserkk
 
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: WM_DEVICECHANGE ???????

Postby Daniel Garcia-Gil » Mon Mar 29, 2010 5:43 am

Lailton

other way

As a start you could inherit a new Class TMyWindow FROM TWindow and redefine the Method HandleEvent() to process WM_DEVICECHANGE message

like this
Code: Select all  Expand view  RUN

function Main()

   local oWnd := TMyWindow():New()

   oWnd:Activate()

return nil

CLASS TMyWindow FROM TWindow

   CLASSDATA lRegistered

   METHOD HandleEvent( nMsg, nWParam, nLParam )

ENDCLASS

METHOD HandleEvent( nMsg, nWParam, nLParam ) CLASS TMyWindow

   if nMsg == WM_DEVICECHANGE
      MsgBeep() // ok, we are receiving WM_DEVICECHANGE  messages
   endif  

return Super:HandleEvent( nMsg, nWParam, nLParam )
 
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: WM_DEVICECHANGE ???????

Postby lailton.webmaster » Mon Mar 29, 2010 11:29 am

i will try this way

thanks so much for yours reply.
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: WM_DEVICECHANGE ???????

Postby Baxajaun » Tue May 30, 2017 11:27 am

Dear Anser,

could you post a small and whole sample ?

Thanks in advance !

Best regards,
User avatar
Baxajaun
 
Posts: 968
Joined: Wed Oct 19, 2005 2:17 pm
Location: Gatika. Bizkaia

Re: WM_DEVICECHANGE ???????

Postby horacio » Tue May 30, 2017 2:04 pm

What value WM_DEVICECHANGE has ?. Thank you

Saludos
horacio
 
Posts: 1363
Joined: Wed Jun 21, 2006 12:39 am
Location: Capital Federal Argentina

Re: WM_DEVICECHANGE ???????

Postby cnavarro » Tue May 30, 2017 2:17 pm

Try

WM_DEVICECHANGE = 537
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: WM_DEVICECHANGE ???????

Postby Baxajaun » Wed May 31, 2017 9:38 am

Dear Anser,

please, could you post a small and whole sample ?

Thanks in advance !

Best regards,
User avatar
Baxajaun
 
Posts: 968
Joined: Wed Oct 19, 2005 2:17 pm
Location: Gatika. Bizkaia

Re: WM_DEVICECHANGE ???????

Postby anserkk » Fri Jun 02, 2017 4:41 am

Baxajaun wrote:Dear Anser,

please, could you post a small and whole sample ?

Thanks in advance !

Best regards,


I tried this for experimentation long time back. Unfortunately, as of now, I am unable to locate the sample on my hard drive.

By the way did you try to use the sample posted by Mr.Daniel ? For me, his sample is working fine here on both Harbour and xHarbour.

Instead of return Super:HandleEvent( nMsg, nWParam, nLParam )
change it to
return ::Super:HandleEvent( nMsg, nWParam, nLParam )
User avatar
anserkk
 
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 45 guests