Add bitmap to taskbar

Add bitmap to taskbar

Postby reds » Wed Mar 07, 2018 9:57 am

I would like to show wi-fi signal status icon on the taskbar rather than within the app window is it possible ?

TIA
Peter
p.s. running WM6.1
reds
 
Posts: 50
Joined: Tue May 16, 2017 12:19 pm
Location: North London

Re: Add bitmap to taskbar

Postby Antonio Linares » Wed Mar 07, 2018 10:40 am

Peter,

Could you please post some screenshots to better understand what you mean ? thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Add bitmap to taskbar

Postby reds » Wed Mar 07, 2018 12:58 pm

Image
Antonio

I would like to place the 5 bar icon currently at at top right of the screen onto the taskbar next to the title,
in this example WiFi Status

Thanks
Peter

p.s. preview of message not showing photo but it is at https://imgur.com/a/Ssb1E
reds
 
Posts: 50
Joined: Tue May 16, 2017 12:19 pm
Location: North London

Re: Add bitmap to taskbar

Postby Antonio Linares » Thu Mar 08, 2018 8:37 am

Peter,

Are you creating that Wifi status window using FWPPC ?

If so, could you please post the code here ?

I guess that if we use the WM_NCPAINT message then you may be able to paint anything you need on the caption bar
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Add bitmap to taskbar

Postby reds » Fri Mar 09, 2018 11:12 am

Antonio
Code was found here or another forum, I can't remember now :!:

Regards
Peter
Code: Select all  Expand view

 #pragma BEGINDUMP


    #ifdef UNICODE
       #define UNDER_CE
    #endif

    #include <hbapi.h>
    #include <windows.h>
    #include <aygshell.h>
    #include <ntddndis.h>
    #include <nuiouser.h>
    #include <winioctl.h>
    #include <iphlpapi.h>

    BOOL GetFirstRFEthernetSignalStrength( int*, int* );

    HB_FUNC( SIGNAL  )
    {
    int nStrength = 0;
    int nQuality = 0;
    GetFirstRFEthernetSignalStrength(&nStrength, &nQuality);
    hb_retnl( ( long ) nQuality );
    }

    HRESULT GetSignalStrength(
    TCHAR *ptcDeviceName,
    int* piSignalStrength,
    int* piSignalQuality
    )
    { PNDISUIO_QUERY_OID queryOID;
       DWORD  dwBytesReturned = 0;
       UCHAR  QueryBuffer[sizeof(NDISUIO_QUERY_OID) +sizeof(DWORD)];
       HANDLE  ndisAccess = INVALID_HANDLE_VALUE;
       BOOL  retval;
       HRESULT  hr; // Attach to NDISUIO.
       ndisAccess = CreateFile( NDISUIO_DEVICE_NAME,    0, 0, NULL, OPEN_EXISTING,  FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,    INVALID_HANDLE_VALUE );
       if ( ndisAccess == INVALID_HANDLE_VALUE )
       return E_FAIL; // ????
       // Get Signal strength
       queryOID = (PNDISUIO_QUERY_OID)&QueryBuffer[0];
       queryOID->ptcDeviceName = ptcDeviceName;
       queryOID->Oid = OID_802_11_RSSI;
       retval = DeviceIoControl( ndisAccess,  IOCTL_NDISUIO_QUERY_OID_VALUE,  (LPVOID) queryOID,  sizeof(NDISUIO_QUERY_OID) + sizeof(DWORD),  (LPVOID) queryOID,  sizeof(NDISUIO_QUERY_OID) + sizeof(DWORD),  &dwBytesReturned,  NULL);
       if( retval && piSignalStrength && piSignalQuality )
          {
          hr = S_OK;
          *piSignalStrength = *(DWORD *)&queryOID->Data;
          //Here's Microsoft's interpretation
          //of the return value
          if(*piSignalStrength < -90)              
             *piSignalQuality =  0; // No signal
          else if(*piSignalStrength < -81)  
             *piSignalQuality  = 1; // Very low
          else if(*piSignalStrength < -71)  
             *piSignalQuality  = 2; // Low
          else if(*piSignalStrength < -67)  
             *piSignalQuality  = 3; // Good
          else if(*piSignalStrength < -57)  
              *piSignalQuality  = 4; // Very good
          else *piSignalQuality  = 5; // Excellent
          }
          else
          {
             hr = E_FAIL;
          }
          CloseHandle( ndisAccess );
          return hr;
       }
       BOOL GetFirstRFEthernetSignalStrength(
          int* pSignalStrength,
          int* pSignalQuality
          )
          { BOOL retval = FALSE;
          // Get the size of the adapters list.
          DWORD size = 0;
          GetAdaptersInfo( NULL, &size );
          // Allocate space for the list.
          IP_ADAPTER_INFO *info =  
            (IP_ADAPTER_INFO*)new char[ size ];
            DWORD err;
            if ((err = GetAdaptersInfo(info, &size ))  
             == NO_ERROR )
             {
             IP_ADAPTER_INFO *cinfo = info;
             while ( cinfo )
                {  
                 // Check the interface media type for  
                 // Ethernet, which both  
                 // standard Ethernet and RF Ethernet will return.  
                 if ( cinfo->Type == MIB_IF_TYPE_ETHERNET )  
                   {  
                   TCHAR wName[ MAX_ADAPTER_NAME_LENGTH + 4 ];  
                   MultiByteToWideChar( CP_ACP, 0,    cinfo->AdapterName, -1,     wName,     sizeof( wName ) / sizeof( wName[ 0 ] ) );
                   // Try to get the signal strength.  
                   // If it works, we  
                   // return the information.  
                   // If not, we move on.  
                   if ( GetSignalStrength( wName,    
                       pSignalStrength, pSignalQuality ) == S_OK )  
                       {  
                        retval = TRUE;    
                        break;  
                        }  
                    }  
                    // Go to the next adapter in the list.  
                    cinfo = cinfo->Next;
                    }
                   } // Don't forget to delete the allocation.
                   delete [] info;
                   return retval;
    }
    #pragma ENDDUMP
 
reds
 
Posts: 50
Joined: Tue May 16, 2017 12:19 pm
Location: North London

Re: Add bitmap to taskbar

Postby Antonio Linares » Fri Mar 09, 2018 11:22 am

Peter,

ok, thanks

So in your PRG you call Signal() and then paint the wifi icon, right ?

Please post here the PRG code used to paint the wifi icon too so we can modify it to be painted in the caption area, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Add bitmap to taskbar

Postby reds » Mon Mar 12, 2018 9:53 am

Antonio

Here it is

Regards
Peter


Code: Select all  Expand view
#include "FWCE.ch"


STATIC oWnd,oBMP
statiC cDir


 #define INTERVAL_SECONDS  5

 
 static aWifi := {"wifi-0.bmp","wifi-1.bmp","wifi-2.bmp","wifi-3.bmp","wifi-4.bmp","wifi-5.bmp"}

***********************
Procedure Main()
     
  LOCAl oBtn
     
  cDir :=  CurDir()
   
  DEFINE WINDOW oWnd TITLE "WiFi Status"

    @ 0, 26 BITMAP oBmp FILENAME cDir +"\"+aWiFi[ SIGNAL() +1 ] NOBORDER

    @ 260, 15   BTNBMP  oBtn    SIZE 25, 25 FILE cDir + "
\EXIT.bmp" ACTION FINISH()

  ACTIVATE WINDOW oWnd ON INIT BuildTimer()
 
*********************
FUNCTION BuildTimer()

   LOCAL oTmr
   

   DEFINE TIMER oTmr INTERVAL INTERVAL_SECONDS * 1000  ACTION TimerCalls( )
 
 ACTIVATE TIMER oTmr

return nil
*********************
Function TimerCalls()

    oBmp:LoadBMP(     cDir +"
\"+  aWifi[ SIGNAL() + 1 ] )

 

****************
FUNCTION FINISH()

 IF ! MSGNOYES("
Exit")
    RETURN .f.
 ENDIF
 
 oWnd:END()
reds
 
Posts: 50
Joined: Tue May 16, 2017 12:19 pm
Location: North London

Re: Add bitmap to taskbar

Postby Antonio Linares » Mon Mar 12, 2018 10:57 am

Peter,

Please try your example with these changes and let me know if you get a beep, thanks

replace this line:

DEFINE WINDOW oWnd TITLE "WiFi Status"

with:

oWnd = TMyWindow():New( "WiFi Status" )

and add this code to your prg:

Code: Select all  Expand view
#define WM_NCPAINT           133    // 0x085

CLASS TMyWindow FROM TWindow

   METHOD HandleEvent( nMsg, nWParam, nLParam )

ENDCLASS

METHOD HandleEvent( nMsg, nWParam, nLParam ) CLASS TMyWindow

   if nMsg == WM_NCPAINT
      MsgBeep()
   endif
     
return Super:HandleEvent( nMsg, nWParam, nLParam )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Add bitmap to taskbar

Postby reds » Tue Mar 13, 2018 10:13 am

Antonio

MsgBeep() does not get called and then crashes with variable does not exist Super


Regards
Peter
reds
 
Posts: 50
Joined: Tue May 16, 2017 12:19 pm
Location: North London

Re: Add bitmap to taskbar

Postby Antonio Linares » Tue Mar 13, 2018 11:35 am

Please use ::Super instead of Super
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Add bitmap to taskbar

Postby reds » Tue Mar 13, 2018 12:40 pm

MsgBeep() still not called
Regards
reds
 
Posts: 50
Joined: Tue May 16, 2017 12:19 pm
Location: North London


Return to FiveWin for Pocket PC

Who is online

Users browsing this forum: No registered users and 10 guests