|
From: Nbell on 16 Feb 2005 09:49 I would like to do some skins with ppc task bar and the bottom tray bar. After searched sdk and newsgroup, I got some clues to do it. It seems to FindWindow and get handle of taskbar, then SetWindowLong to replace window procedure. But I can't find anymore than it. Here is the page that implement what i want. http://www.pocketpcdn.com/articles/taskbar_icon.html but I just want to paint the bg of task bar and the bottom tray bar. Any help or example is really appreciated.
From: Nathan Lewis on 16 Feb 2005 21:02 Assuming you are using eMbedded Visual C++, you could do something like this: WNDPROC g_wpOld = NULL; LRESULT CALLBACK TBWndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ); BOOL TBSubclass() { HWND hTaskbar = FindWindow( _T("HHTaskBar"), NULL ); if( hTaskbar ) { g_wpOld = (WNDPROC)SetWindowLong( hTaskbar, GWL_WNDPROC, (LONG)TBWndProc ); } return( NULL != g_wpOld ); } void TBUnsubclass() { if( g_wpOld ) { HWND hTaskbar = FindWindow( _T("HHTaskBar"), NULL ); if( hTaskbar ) SetWindowLong( hTaskbar, GWL_WNDPROC, (LONG)g_wpOld ); } g_wpOld = NULL; } LRESULT CALLBACK TBWndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ) { switch( msg ) { case WM_PAINT: { // TODO: Add your drawing code here... } break; case WM_DESTROY: TBUnsubclass(); break; } return CallWindowProc( g_wpOld, hwnd, msg, wp, lp ); } Then you would just need to call TBSubclass() to subclass the taskbar - and don't forget to call TBUnsubclass() when your application exits! The same approach should work for the bottom tray bar, but I'm not sure what the correct class name would be for that. --- Nathan Lewis Microsoft Mobile and Embedded Devices Developer Support This posting is provided "AS IS" with no warranties, and confers no rights. -------------------- From: "=?Utf-8?B?TmJlbGw=?=" <Nbell(a)discussions.microsoft.com> Subject: Paint background of Pocket pc task bar ? Date: Wed, 16 Feb 2005 06:49:12 -0800 I would like to do some skins with ppc task bar and the bottom tray bar. After searched sdk and newsgroup, I got some clues to do it. It seems to FindWindow and get handle of taskbar, then SetWindowLong to replace window procedure. But I can't find anymore than it. Here is the page that implement what i want. http://www.pocketpcdn.com/articles/taskbar_icon.html but I just want to paint the bg of task bar and the bottom tray bar. Any help or example is really appreciated.
From: Nbell on 17 Feb 2005 09:31 Yes, it's helpful. Thanks a lot. And I found it paints not only background but foreground. And the problem is: When clicked the time area or open a program, the time numbers and "X" or "OK" button showed. It seems it's not the part of WM_PAINT of hhtaskbar. OR Is it possible to paint bg only. I have tried handle the WM_ERASEBKGND but it works only bg of Win, speaker and time area. So need to deal with further messages between child windows and taskbar. "Nathan Lewis" wrote: > Assuming you are using eMbedded Visual C++, you could do something like > this: > > WNDPROC g_wpOld = NULL; > LRESULT CALLBACK TBWndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ); > > BOOL TBSubclass() > { > HWND hTaskbar = FindWindow( _T("HHTaskBar"), NULL ); > > if( hTaskbar ) > { > g_wpOld = (WNDPROC)SetWindowLong( hTaskbar, GWL_WNDPROC, > (LONG)TBWndProc ); > } > > return( NULL != g_wpOld ); > } > > void TBUnsubclass() > { > if( g_wpOld ) > { > HWND hTaskbar = FindWindow( _T("HHTaskBar"), NULL ); > > if( hTaskbar ) > SetWindowLong( hTaskbar, GWL_WNDPROC, (LONG)g_wpOld ); > } > > g_wpOld = NULL; > } > > LRESULT CALLBACK TBWndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ) > { > switch( msg ) > { > case WM_PAINT: > { > // TODO: Add your drawing code here... > } > break; > > case WM_DESTROY: > TBUnsubclass(); > break; > } > > return CallWindowProc( g_wpOld, hwnd, msg, wp, lp ); > } > > > Then you would just need to call TBSubclass() to subclass the taskbar - and > don't forget to call TBUnsubclass() when your application exits! The same > approach should work for the bottom tray bar, but I'm not sure what the > correct class name would be for that. > > > --- > > Nathan Lewis > Microsoft Mobile and Embedded Devices Developer Support > > This posting is provided "AS IS" with no warranties, and confers no rights. > > > > > -------------------- > From: "=?Utf-8?B?TmJlbGw=?=" <Nbell(a)discussions.microsoft.com> > Subject: Paint background of Pocket pc task bar ? > Date: Wed, 16 Feb 2005 06:49:12 -0800 > > > I would like to do some skins with ppc task bar and the bottom tray bar. > > > After searched sdk and newsgroup, I got some clues to do it. > It seems to FindWindow and get handle of taskbar, then SetWindowLong to > replace window procedure. > > > But I can't find anymore than it. > > > Here is the page that implement what i want. > http://www.pocketpcdn.com/articles/taskbar_icon.html > but I just want to paint the bg of task bar and the bottom tray bar. > > > Any help or example is really appreciated
From: Nathan Lewis on 17 Feb 2005 15:22 You can call the original window procedure first to do the default painting, then override it with your own. I played with this a little bit, but I'm not a graphics expert so I didn't go real far with it. You might be able to take my code and run with it, though - so here are the important bits: case WM_ERASEBKGND: { RECT rc = {0}; GetClientRect( hwnd, &rc ); FillRect( (HDC)wp, &rc, (HBRUSH)GetStockObject( BLACK_BRUSH ) ); } return 1; case WM_PAINT: { // Call original window procedure first to do default painting! LRESULT lResult = CallWindowProc( g_wpOld, hwnd, msg, wp, lp ); // Ugh - I should do some error checking here, but I'm feeling lazy.. RECT rc = {0}; HDC hdc = GetDC( hwnd ); HDC hdcMem = CreateCompatibleDC( hdc ); GetClientRect( hwnd, &rc ); int iWidth = rc.right - rc.left; int iHeight = rc.bottom - rc.top; HBITMAP hbm = CreateCompatibleBitmap( hdcMem, iWidth, iHeight ); HBITMAP hbmOld = (HBITMAP)SelectObject( hdcMem, hbm ); FillRect( hdcMem, &rc, (HBRUSH)GetStockObject( BLACK_BRUSH ) ); BitBlt( hdcMem, 0, 0, iWidth, iHeight, hdc, 0, 0, SRCINVERT ); BitBlt( hdc, 0, 0, iWidth, iHeight, hdcMem, 0, 0, SRCCOPY ); SelectObject( hdcMem, hbmOld ); DeleteObject( hbm ); DeleteDC( hdcMem ); ReleaseDC( hwnd, hdc ); // Do *not* call original window procedure again! return lResult; } break; BTW - Keep in mind that this is obviously *not* something that Microsoft generally supports. So if it works, great. But if it breaks, you get to keep both pieces. :) --- Nathan Lewis Microsoft Mobile and Embedded Devices Developer Support This posting is provided "AS IS" with no warranties, and confers no rights. -------------------- From: "=?Utf-8?B?TmJlbGw=?=" <Nbell(a)discussions.microsoft.com> Subject: RE: Paint background of Pocket pc task bar ? Date: Thu, 17 Feb 2005 06:31:04 -0800 Yes, it's helpful. Thanks a lot. And I found it paints not only background but foreground. And the problem is: When clicked the time area or open a program, the time numbers and "X" or "OK" button showed. It seems it's not the part of WM_PAINT of hhtaskbar. OR Is it possible to paint bg only. I have tried handle the WM_ERASEBKGND but it works only bg of Win, speaker and time area. So need to deal with further messages between child windows and taskbar. "Nathan Lewis" wrote: > Assuming you are using eMbedded Visual C++, you could do something like > this: > > WNDPROC g_wpOld = NULL; > LRESULT CALLBACK TBWndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ); > > BOOL TBSubclass() > { > HWND hTaskbar = FindWindow( _T("HHTaskBar"), NULL ); > > if( hTaskbar ) > { > g_wpOld = (WNDPROC)SetWindowLong( hTaskbar, GWL_WNDPROC, > (LONG)TBWndProc ); > } > > return( NULL != g_wpOld ); > } > > void TBUnsubclass() > { > if( g_wpOld ) > { > HWND hTaskbar = FindWindow( _T("HHTaskBar"), NULL ); > > if( hTaskbar ) > SetWindowLong( hTaskbar, GWL_WNDPROC, (LONG)g_wpOld ); > } > > g_wpOld = NULL; > } > > LRESULT CALLBACK TBWndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ) > { > switch( msg ) > { > case WM_PAINT: > { > // TODO: Add your drawing code here... > } > break; > > case WM_DESTROY: > TBUnsubclass(); > break; > } > > return CallWindowProc( g_wpOld, hwnd, msg, wp, lp ); > } > > > Then you would just need to call TBSubclass() to subclass the taskbar - and > don't forget to call TBUnsubclass() when your application exits! The same > approach should work for the bottom tray bar, but I'm not sure what the > correct class name would be for that. > > > --- > > Nathan Lewis > Microsoft Mobile and Embedded Devices Developer Support > > This posting is provided "AS IS" with no warranties, and confers no rights. > > > > > -------------------- > From: "=?Utf-8?B?TmJlbGw=?=" <Nbell(a)discussions.microsoft.com> > Subject: Paint background of Pocket pc task bar ? > Date: Wed, 16 Feb 2005 06:49:12 -0800 > > > I would like to do some skins with ppc task bar and the bottom tray bar. > > > After searched sdk and newsgroup, I got some clues to do it. > It seems to FindWindow and get handle of taskbar, then SetWindowLong to > replace window procedure. > > > But I can't find anymore than it. > > > Here is the page that implement what i want. > http://www.pocketpcdn.com/articles/taskbar_icon.html > but I just want to paint the bg of task bar and the bottom tray bar. > > > Any help or example is really appreciated
From: Nbell on 18 Feb 2005 11:31 Thanks again Nathan , It's totally different with the way I try to do. But it's direct. Yes, tested in real device and emulator, it works well but some clicked area such as in time numbers and "X" button where still showed the original blue when clicked it. Also, the original background color flashs and then replaced by new color when opens a program. I think low speed cpu of ppc may cause it. Anyway, this code is really helpful to me. "Nathan Lewis" wrote: > You can call the original window procedure first to do the default > painting, then override it with your own. I played with this a little bit, > but I'm not a graphics expert so I didn't go real far with it. You might > be able to take my code and run with it, though - so here are the important > bits: > > case WM_ERASEBKGND: > { > RECT rc = {0}; > GetClientRect( hwnd, &rc ); > FillRect( (HDC)wp, &rc, (HBRUSH)GetStockObject( BLACK_BRUSH ) ); > } > return 1; > > case WM_PAINT: > { > // Call original window procedure first to do default painting! > LRESULT lResult = CallWindowProc( g_wpOld, hwnd, msg, wp, lp ); > > // Ugh - I should do some error checking here, but I'm feeling > lazy.. > RECT rc = {0}; > HDC hdc = GetDC( hwnd ); > HDC hdcMem = CreateCompatibleDC( hdc ); > > GetClientRect( hwnd, &rc ); > > int iWidth = rc.right - rc.left; > int iHeight = rc.bottom - rc.top; > > HBITMAP hbm = CreateCompatibleBitmap( hdcMem, iWidth, iHeight ); > HBITMAP hbmOld = (HBITMAP)SelectObject( hdcMem, hbm ); > > FillRect( hdcMem, &rc, (HBRUSH)GetStockObject( BLACK_BRUSH ) ); > BitBlt( hdcMem, 0, 0, iWidth, iHeight, hdc, 0, 0, SRCINVERT ); > BitBlt( hdc, 0, 0, iWidth, iHeight, hdcMem, 0, 0, SRCCOPY ); > > SelectObject( hdcMem, hbmOld ); > DeleteObject( hbm ); > DeleteDC( hdcMem ); > ReleaseDC( hwnd, hdc ); > > // Do *not* call original window procedure again! > return lResult; > } > break; > > > BTW - Keep in mind that this is obviously *not* something that Microsoft > generally supports. So if it works, great. But if it breaks, you get to > keep both pieces. :) > > > --- > > Nathan Lewis > Microsoft Mobile and Embedded Devices Developer Support > > This posting is provided "AS IS" with no warranties, and confers no rights. > > > > -------------------- > From: "=?Utf-8?B?TmJlbGw=?=" <Nbell(a)discussions.microsoft.com> > Subject: RE: Paint background of Pocket pc task bar ? > Date: Thu, 17 Feb 2005 06:31:04 -0800 > > > Yes, it's helpful. Thanks a lot. > > And I found it paints not only background but foreground. And the problem > is: > When clicked the time area or open a program, the time numbers and "X" or > "OK" button showed. It seems it's not the part of WM_PAINT of hhtaskbar. > OR > Is it possible to paint bg only. I have tried handle the WM_ERASEBKGND but > it works only bg of Win, speaker and time area. > > So need to deal with further messages between child windows and taskbar. > > "Nathan Lewis" wrote: > > > Assuming you are using eMbedded Visual C++, you could do something like > > this: > > > > WNDPROC g_wpOld = NULL; > > LRESULT CALLBACK TBWndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp > ); > > > > BOOL TBSubclass() > > { > > HWND hTaskbar = FindWindow( _T("HHTaskBar"), NULL ); > > > > if( hTaskbar ) > > { > > g_wpOld = (WNDPROC)SetWindowLong( hTaskbar, GWL_WNDPROC, > > (LONG)TBWndProc ); > > } > > > > return( NULL != g_wpOld ); > > } > > > > void TBUnsubclass() > > { > > if( g_wpOld ) > > { > > HWND hTaskbar = FindWindow( _T("HHTaskBar"), NULL ); > > > > if( hTaskbar ) > > SetWindowLong( hTaskbar, GWL_WNDPROC, (LONG)g_wpOld ); > > } > > > > g_wpOld = NULL; > > } > > > > LRESULT CALLBACK TBWndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ) > > { > > switch( msg ) > > { > > case WM_PAINT: > > { > > // TODO: Add your drawing code here... > > } > > break; > > > > case WM_DESTROY: > > TBUnsubclass(); > > break; > > } > > > > return CallWindowProc( g_wpOld, hwnd, msg, wp, lp ); > > } > > > > > > Then you would just need to call TBSubclass() to subclass the taskbar - > and > > don't forget to call TBUnsubclass() when your application exits! The > same > > approach should work for the bottom tray bar, but I'm not sure what the > > correct class name would be for that. > > > > > > --- > > > > Nathan Lewis > > Microsoft Mobile and Embedded Devices Developer Support > > > > This posting is provided "AS IS" with no warranties, and confers no > rights. > > > > > > > > > > -------------------- > > From: "=?Utf-8?B?TmJlbGw=?=" <Nbell(a)discussions.microsoft.com> > > Subject: Paint background of Pocket pc task bar ? > > Date: Wed, 16 Feb 2005 06:49:12 -0800 > > > > > > I would like to do some skins with ppc task bar and the bottom tray bar. > > > > > > After searched sdk and newsgroup, I got some clues to do it. > > It seems to FindWindow and get handle of taskbar, then SetWindowLong to > > replace window procedure. > > > > > > But I can't find anymore than it. > > > > > > Here is the page that implement what i want. > > http://www.pocketpcdn.com/articles/taskbar_icon.html > > but I just want to paint the bg of task bar and the bottom tray bar. > > > > > > Any help or example is really appreciated >
|
Pages: 1 Prev: Create a virtual comport for gps data? Next: Programatically Provisioning PocketPC for 802.11 |