From: Mohammad Omer on
I tried those functions but water mark problem was not resolved.

> [CASE-I]
> LVBKIMAGE bkImage;
> if( l_Ctrl.GetBkImage( &bkImage ) && (bkImage.ulFlags ==
> LVBKIF_SOURCE_NONE ) )
> {
> bkImage.pszImage = TEXT( "E:\\ watermark.bmp" );
> bkImage.ulFlags = LVBKIF_SOURCE_URL |
> LVBKIF_TYPE_WATERMARK;
> bkImage.cchImageMax = sizeof( bkImage.hbm );
> bkImage.xOffsetPercent = 100;
> bkImage.yOffsetPercent = 100;
> if( l_Ctrl.SetBkImage( &bkImage ) )
> l_Ctrl.GetBkImage( &bkImage );
> }

In CASE-I, if LVBKIF_TYPE_WATERMARK removes, it will be working fine in
Win2K and WinXP. But this way anyone can change the image on the disk
and it'll get changed in the application which is of course what I
don't want. For this reason I tried to include that image in MFC
Resource and code in CASE-II.

> list view control name is l_Ctrl(List View Control)
> [CASE-II]
> LVBKIMAGE bkImage;
> if( l_Ctrl.GetBkImage( &bkImage ) && (bkImage.ulFlags ==
> LVBKIF_SOURCE_NONE ) )
> {
> HBITMAP hBitmap;
> hBitmap = (HBITMAP)::LoadImage( AfxGetInstanceHandle( ),
> MAKEINTRESOURCE( IDB_WATERMARK ),
> IMAGE_BITMAP,
> 0, 0,
> LR_CREATEDIBSECTION | LR_LOADMAP3DCOLORS
>);
> bkImage.hbm = hBitmap;
> bkImage.ulFlags = LVBKIF_SOURCE_HBITMAP;
> bkImage.cchImageMax = sizeof( bkImage.hbm );
> bkImage.xOffsetPercent = 100;
> bkImage.yOffsetPercent = 100;
> if( ! l_Ctrl.SetBkImage( &bkImage ) )
> {
> ::MessageBox( this->m_hWnd, TEXT("HBITMAP is Not Loaded"),
> TEXT("Load Error"), MB_OK );
> }
> }

For some reasons this code works in WinXP but not in Win2K. Please tell
me corrections in my code. Is there some other way to display image as
water mark on the right bottom side?

Regards,
-aims


On Nov 7, 2:39 am, "AliR \(VC++ MVP\)" <A...(a)online.nospam> wrote:
> Make sure you have the calls to set the bkcolor and textbkcolor to
> transparent
>
> m_cList.SetBkColor(CLR_NONE);
>
> m_cList.SetTextBkColor(CLR_NONE);
>
> m_cList.SetBkImage("c:\\gto.bmp",TRUE);
>
> AliR.
>
> "AliR (VC++ MVP)" <A...(a)online.nospam> wrote in messagenews:454fa8b6$0$2970$a8266bb1(a)reader.corenews.com...
>
> > Is it still returning 0 or is it returning 1 and you can't see the image?
>
> > AliR.
>
> > "Mohammad Omer" <momer...(a)gmail.com> wrote in message
> >news:1162636783.133100.277340(a)b28g2000cwb.googlegroups.com...
> > > I tried it, but it's not working.
>
> > > Regards,
> > > -aims
>
> > > On Nov 3, 10:18 pm, "AliR \(VC++ MVP\)" <A...(a)online.nospam> wrote:
> > > > Did you call AfxOleInit in your apps InitInstance?
>
> > > > AliR.
>
> > > > "Neo" <momer...(a)gmail.com> wrote in
> > messagenews:1162573158.692137.261190(a)b28g2000cwb.googlegroups.com...
>
> > > > > I am developing SDI application in vc using vs2k5. my *view* class
> > > > > (CTestView) inherited from CListView. I want to place background
> Image
> > > > > in list view. I wrote following code in
> > > > > "CTestView::OnInitialUpdate()" function, list view control name is
> > > > > l_Ctrl(List View Control), and working fine with Tile Style in both
> > > > > operating system Win2K and WinXP.
>
> > > > > if( l_Ctrl.GetBkImage( &bkImage ) && (bkImage.ulFlags ==
> > > > > LVBKIF_SOURCE_NONE ) )
> > > > > {
> > > > > l_Ctrl.SetBkImage( TEXT( "E:\\watermark.bmp" ), TRUE );
> > > > > }
>
> > > > > I want to show image as Water Mark in view area, following code
> (uses
> > > > > SetBkImage function by passing LVBKIMAGE structure) which is working
> > > > > fine (in case of loading image from file) only in Win2K but its not
> > > > > working in WinXP.
>
> > > > > [CASE-I]
>
> > > > > LVBKIMAGE bkImage;
> > > > > if( l_Ctrl.GetBkImage( &bkImage ) && (bkImage.ulFlags ==
> > > > > LVBKIF_SOURCE_NONE ) )
> > > > > {
> > > > > bkImage.pszImage = TEXT( "E:\\ watermark.bmp" );
> > > > > bkImage.ulFlags = LVBKIF_SOURCE_URL |
> > > > > LVBKIF_TYPE_WATERMARK;
>
> > > > > bkImage.cchImageMax = sizeof( bkImage.hbm );
> > > > > bkImage.xOffsetPercent = 100;
> > > > > bkImage.yOffsetPercent = 100;
>
> > > > > if( l_Ctrl.SetBkImage( &bkImage ) )
> > > > > l_Ctrl.GetBkImage( &bkImage );
> > > > > }
>
> > > > > the following code is not working in nieither Win2K nor WinXP,
> > > > > IDB_WATERMARK is Bitmap Resource which has been added in Project.
> But
> > > > > the following code works fine in WinXP only if "bkImage.ulFlags =
> > > > > LVBKIF_SOURCE_HBITMAP".
>
> > > > > [CASE-II]
>
> > > > > LVBKIMAGE bkImage;
> > > > > if( l_Ctrl.GetBkImage( &bkImage ) && (bkImage.ulFlags ==
> > > > > LVBKIF_SOURCE_NONE ) )
> > > > > {
> > > > > HBITMAP hBitmap;
> > > > > hBitmap = (HBITMAP)::LoadImage( AfxGetInstanceHandle( ),
> > > > > MAKEINTRESOURCE( IDB_WATERMARK ),
> > > > > IMAGE_BITMAP,
> > > > > 0, 0,
> > > > > LR_CREATEDIBSECTION |
> > LR_LOADMAP3DCOLORS
> > > > > );
>
> > > > > bkImage.hbm = hBitmap;
> > > > > bkImage.ulFlags = LVBKIF_SOURCE_HBITMAP |
> > > > > LVBKIF_TYPE_WATERMARK;
>
> > > > > bkImage.cchImageMax = sizeof( bkImage.hbm );
> > > > > bkImage.xOffsetPercent = 100;
> > > > > bkImage.yOffsetPercent = 100;
>
> > > > > if( ! l_Ctrl.SetBkImage( &bkImage ) )
> > > > > {
> > > > > ::MessageBox( this->m_hWnd, TEXT("HBITMAP is Not Loaded"),
> > > > > TEXT("Load Error"), MB_OK );
> > > > > }
> > > > > }
>
> > > > > please tell me mistakes in my code for displaying image as water
> mark
> > > > > in List View, and tell me corrections for making it work on Win2k
> and
> > > > > WinXP. Please explain, why Case-I works in Win2k but not in WinXP?
> And
> > > > > why case-II with changes works in WinXP but not in Win2k?
>
> > > > > regards,
>
> > > > > -aims

From: AliR (VC++ MVP) on
Dude you are jumping from one branch to another.
In Case I every thing is fine, but it will ONLY work on windows XP and
above. LVBKIF_TYPE_WATERMARK is not supported by any operating system older
than XP.

I don't know why Case II is not working correctly. Looking at the docs for
LVBKIMAGE struct it says that hbm is not being used. But you can clearly see
MFC using it in Winctrl6.cpp in CListCtrl::SetBkImage method. So there is a
goof somewhere.
But there is a work-around:

> > [CASE-II]
> > LVBKIMAGE bkImage;
> > if( l_Ctrl.GetBkImage( &bkImage ) && (bkImage.ulFlags ==
> > LVBKIF_SOURCE_NONE ) )
> > {
TCHAR szBuffer[_MAX_PATH];
VERIFY(::GetModuleFileName(AfxGetInstanceHandle(), szBuffer,
_MAX_PATH));
CString sPath;
sPath.Format(_T("res://%s/#2/#%ld"),szBuffer,IDB_WATERMARK);
bkImage.pszImage = sPath.GetBuffer();

> > bkImage.ulFlags = LVBKIF_SOURCE_HBITMAP;
> > bkImage.cchImageMax = sizeof( bkImage.hbm );
> > bkImage.xOffsetPercent = 100;
> > bkImage.yOffsetPercent = 100;
> > if( ! l_Ctrl.SetBkImage( &bkImage ) )
> > {
//error
> > }
spPath.ReleaseBuffer();
> > }

Again with all of these in order to see the image while there are items in
the list control you will need to set the bk color of the text to none.

So make sure you are calling
l_Ctrl.SetBkColor(CLR_NONE);
l_Ctrl.SetTextBkColor(CLR_NONE);



AliR.

"Mohammad Omer" <momer114(a)gmail.com> wrote in message
news:1162884300.535257.15010(a)f16g2000cwb.googlegroups.com...
> I tried those functions but water mark problem was not resolved.
>
> > [CASE-I]
> > LVBKIMAGE bkImage;
> > if( l_Ctrl.GetBkImage( &bkImage ) && (bkImage.ulFlags ==
> > LVBKIF_SOURCE_NONE ) )
> > {
> > bkImage.pszImage = TEXT( "E:\\ watermark.bmp" );
> > bkImage.ulFlags = LVBKIF_SOURCE_URL |
> > LVBKIF_TYPE_WATERMARK;
> > bkImage.cchImageMax = sizeof( bkImage.hbm );
> > bkImage.xOffsetPercent = 100;
> > bkImage.yOffsetPercent = 100;
> > if( l_Ctrl.SetBkImage( &bkImage ) )
> > l_Ctrl.GetBkImage( &bkImage );
> > }
>
> In CASE-I, if LVBKIF_TYPE_WATERMARK removes, it will be working fine in
> Win2K and WinXP. But this way anyone can change the image on the disk
> and it'll get changed in the application which is of course what I
> don't want. For this reason I tried to include that image in MFC
> Resource and code in CASE-II.
>
> > list view control name is l_Ctrl(List View Control)
> > [CASE-II]
> > LVBKIMAGE bkImage;
> > if( l_Ctrl.GetBkImage( &bkImage ) && (bkImage.ulFlags ==
> > LVBKIF_SOURCE_NONE ) )
> > {
> > HBITMAP hBitmap;
> > hBitmap = (HBITMAP)::LoadImage( AfxGetInstanceHandle( ),
> > MAKEINTRESOURCE( IDB_WATERMARK ),
> > IMAGE_BITMAP,
> > 0, 0,
> > LR_CREATEDIBSECTION | LR_LOADMAP3DCOLORS
> >);
> > bkImage.hbm = hBitmap;
> > bkImage.ulFlags = LVBKIF_SOURCE_HBITMAP;
> > bkImage.cchImageMax = sizeof( bkImage.hbm );
> > bkImage.xOffsetPercent = 100;
> > bkImage.yOffsetPercent = 100;
> > if( ! l_Ctrl.SetBkImage( &bkImage ) )
> > {
> > ::MessageBox( this->m_hWnd, TEXT("HBITMAP is Not Loaded"),
> > TEXT("Load Error"), MB_OK );
> > }
> > }
>
> For some reasons this code works in WinXP but not in Win2K. Please tell
> me corrections in my code. Is there some other way to display image as
> water mark on the right bottom side?
>
> Regards,
> -aims
>
>
> On Nov 7, 2:39 am, "AliR \(VC++ MVP\)" <A...(a)online.nospam> wrote:
> > Make sure you have the calls to set the bkcolor and textbkcolor to
> > transparent
> >
> > m_cList.SetBkColor(CLR_NONE);
> >
> > m_cList.SetTextBkColor(CLR_NONE);
> >
> > m_cList.SetBkImage("c:\\gto.bmp",TRUE);
> >
> > AliR.
> >
> > "AliR (VC++ MVP)" <A...(a)online.nospam> wrote in
messagenews:454fa8b6$0$2970$a8266bb1(a)reader.corenews.com...
> >
> > > Is it still returning 0 or is it returning 1 and you can't see the
image?
> >
> > > AliR.
> >
> > > "Mohammad Omer" <momer...(a)gmail.com> wrote in message
> > >news:1162636783.133100.277340(a)b28g2000cwb.googlegroups.com...
> > > > I tried it, but it's not working.
> >
> > > > Regards,
> > > > -aims
> >
> > > > On Nov 3, 10:18 pm, "AliR \(VC++ MVP\)" <A...(a)online.nospam> wrote:
> > > > > Did you call AfxOleInit in your apps InitInstance?
> >
> > > > > AliR.
> >
> > > > > "Neo" <momer...(a)gmail.com> wrote in
> > > messagenews:1162573158.692137.261190(a)b28g2000cwb.googlegroups.com...
> >
> > > > > > I am developing SDI application in vc using vs2k5. my *view*
class
> > > > > > (CTestView) inherited from CListView. I want to place background
> > Image
> > > > > > in list view. I wrote following code in
> > > > > > "CTestView::OnInitialUpdate()" function, list view control name
is
> > > > > > l_Ctrl(List View Control), and working fine with Tile Style in
both
> > > > > > operating system Win2K and WinXP.
> >
> > > > > > if( l_Ctrl.GetBkImage( &bkImage ) && (bkImage.ulFlags ==
> > > > > > LVBKIF_SOURCE_NONE ) )
> > > > > > {
> > > > > > l_Ctrl.SetBkImage( TEXT( "E:\\watermark.bmp" ), TRUE );
> > > > > > }
> >
> > > > > > I want to show image as Water Mark in view area, following code
> > (uses
> > > > > > SetBkImage function by passing LVBKIMAGE structure) which is
working
> > > > > > fine (in case of loading image from file) only in Win2K but its
not
> > > > > > working in WinXP.
> >
> > > > > > [CASE-I]
> >
> > > > > > LVBKIMAGE bkImage;
> > > > > > if( l_Ctrl.GetBkImage( &bkImage ) && (bkImage.ulFlags ==
> > > > > > LVBKIF_SOURCE_NONE ) )
> > > > > > {
> > > > > > bkImage.pszImage = TEXT( "E:\\ watermark.bmp" );
> > > > > > bkImage.ulFlags = LVBKIF_SOURCE_URL |
> > > > > > LVBKIF_TYPE_WATERMARK;
> >
> > > > > > bkImage.cchImageMax = sizeof( bkImage.hbm );
> > > > > > bkImage.xOffsetPercent = 100;
> > > > > > bkImage.yOffsetPercent = 100;
> >
> > > > > > if( l_Ctrl.SetBkImage( &bkImage ) )
> > > > > > l_Ctrl.GetBkImage( &bkImage );
> > > > > > }
> >
> > > > > > the following code is not working in nieither Win2K nor WinXP,
> > > > > > IDB_WATERMARK is Bitmap Resource which has been added in
Project.
> > But
> > > > > > the following code works fine in WinXP only if "bkImage.ulFlags
=
> > > > >
From: Mohammad Omer on
Thanks, it works with LVBKIF_SOURCE_URL flag.

> CString sPath;
> sPath.Format(_T("res://%s/#2/#%ld"),szBuffer,IDB_WATERMARK);

Few of things are not understand in "sPath" value, what is
representing in it? The "sPath" contains
"res://e:\vc\TestWaterMark\debug\TestWaterMark.exe/#2/#198". Is
"res://" mean protocol for loading thing from resources? Is
"e:\vc\TestWaterMark\debug\TestWaterMark.exe" will be the absolute
path of exe or dll path or only exe path? What is "#2" that means?
And "#198" is my resource Id.

Regards,

-aims


On Nov 7, 10:33 pm, "AliR \(VC++ MVP\)" <A...(a)online.nospam> wrote:
> Dude you are jumping from one branch to another.
> In Case I every thing is fine, but it will ONLY work on windows XP and
> above. LVBKIF_TYPE_WATERMARK is not supported by any operating system older
> than XP.
>
> I don't know why Case II is not working correctly. Looking at the docs for
> LVBKIMAGE struct it says that hbm is not being used. But you can clearly see
> MFC using it in Winctrl6.cpp in CListCtrl::SetBkImage method. So there is a
> goof somewhere.
> But there is a work-around:
>
> > > [CASE-II]
> > > LVBKIMAGE bkImage;
> > > if( l_Ctrl.GetBkImage( &bkImage ) && (bkImage.ulFlags ==
> > > LVBKIF_SOURCE_NONE ) )
> > > { TCHAR szBuffer[_MAX_PATH];
> VERIFY(::GetModuleFileName(AfxGetInstanceHandle(), szBuffer,
> _MAX_PATH));
> CString sPath;
> sPath.Format(_T("res://%s/#2/#%ld"),szBuffer,IDB_WATERMARK);
> bkImage.pszImage = sPath.GetBuffer();
>
> > > bkImage.ulFlags = LVBKIF_SOURCE_HBITMAP;
> > > bkImage.cchImageMax = sizeof( bkImage.hbm );
> > > bkImage.xOffsetPercent = 100;
> > > bkImage.yOffsetPercent = 100;
> > > if( ! l_Ctrl.SetBkImage( &bkImage ) )
> > > {
> //error
> > > } spPath.ReleaseBuffer();
>
> > > }Again with all of these in order to see the image while there are items in
> the list control you will need to set the bk color of the text to none.
>
> So make sure you are calling
> l_Ctrl.SetBkColor(CLR_NONE);
> l_Ctrl.SetTextBkColor(CLR_NONE);
>
> AliR.
>
> "Mohammad Omer" <momer...(a)gmail.com> wrote in messagenews:1162884300.535257.15010(a)f16g2000cwb.googlegroups.com...
>
> > I tried those functions but water mark problem was not resolved.
>
> > > [CASE-I]
> > > LVBKIMAGE bkImage;
> > > if( l_Ctrl.GetBkImage( &bkImage ) && (bkImage.ulFlags ==
> > > LVBKIF_SOURCE_NONE ) )
> > > {
> > > bkImage.pszImage = TEXT( "E:\\ watermark.bmp" );
> > > bkImage.ulFlags = LVBKIF_SOURCE_URL |
> > > LVBKIF_TYPE_WATERMARK;
> > > bkImage.cchImageMax = sizeof( bkImage.hbm );
> > > bkImage.xOffsetPercent = 100;
> > > bkImage.yOffsetPercent = 100;
> > > if( l_Ctrl.SetBkImage( &bkImage ) )
> > > l_Ctrl.GetBkImage( &bkImage );
> > > }
>
> > In CASE-I, if LVBKIF_TYPE_WATERMARK removes, it will be working fine in
> > Win2K and WinXP. But this way anyone can change the image on the disk
> > and it'll get changed in the application which is of course what I
> > don't want. For this reason I tried to include that image in MFC
> > Resource and code in CASE-II.
>
> > > list view control name is l_Ctrl(List View Control)
> > > [CASE-II]
> > > LVBKIMAGE bkImage;
> > > if( l_Ctrl.GetBkImage( &bkImage ) && (bkImage.ulFlags ==
> > > LVBKIF_SOURCE_NONE ) )
> > > {
> > > HBITMAP hBitmap;
> > > hBitmap = (HBITMAP)::LoadImage( AfxGetInstanceHandle( ),
> > > MAKEINTRESOURCE( IDB_WATERMARK ),
> > > IMAGE_BITMAP,
> > > 0, 0,
> > > LR_CREATEDIBSECTION | LR_LOADMAP3DCOLORS
> > >);
> > > bkImage.hbm = hBitmap;
> > > bkImage.ulFlags = LVBKIF_SOURCE_HBITMAP;
> > > bkImage.cchImageMax = sizeof( bkImage.hbm );
> > > bkImage.xOffsetPercent = 100;
> > > bkImage.yOffsetPercent = 100;
> > > if( ! l_Ctrl.SetBkImage( &bkImage ) )
> > > {
> > > ::MessageBox( this->m_hWnd, TEXT("HBITMAP is Not Loaded"),
> > > TEXT("Load Error"), MB_OK );
> > > }
> > > }
>
> > For some reasons this code works in WinXP but not in Win2K. Please tell
> > me corrections in my code. Is there some other way to display image as
> > water mark on the right bottom side?
>
> > Regards,
> > -aims
>
> > On Nov 7, 2:39 am, "AliR \(VC++ MVP\)" <A...(a)online.nospam> wrote:
> > > Make sure you have the calls to set the bkcolor and textbkcolor to
> > > transparent
>
> > > m_cList.SetBkColor(CLR_NONE);
>
> > > m_cList.SetTextBkColor(CLR_NONE);
>
> > > m_cList.SetBkImage("c:\\gto.bmp",TRUE);
>
> > > AliR.
>
> > > "AliR (VC++ MVP)" <A...(a)online.nospam> wrote inmessagenews:454fa8b6$0$2970$a8266bb1(a)reader.corenews.com...
>
>
>
> > > > Is it still returning 0 or is it returning 1 and you can't see the
> image?
>
> > > > AliR.
>
> > > > "Mohammad Omer" <momer...(a)gmail.com> wrote in message
> > > >news:1162636783.133100.277340(a)b28g2000cwb.googlegroups.com...
> > > > > I tried it, but it's not working.
>
> > > > > Regards,
> > > > > -aims
>
> > > > > On Nov 3, 10:18 pm, "AliR \(VC++ MVP\)" <A...(a)online.nospam> wrote:
> > > > > > Did you call AfxOleInit in your apps InitInstance?
>
> > > > > > AliR.
>
> > > > > > "Neo" <momer...(a)gmail.com> wrote in
> > > > messagenews:1162573158.692137.261190(a)b28g2000cwb.googlegroups.com...
>
> > > > > > > I am developing SDI application in vc using vs2k5. my *view*
> class
> > > > > > > (CTestView) inherited from CListView. I want to place background
> > > Image
> > > > > > > in list view. I wrote following code in
> > > > > > > "CTestView::OnInitialUpdate()" function, list view control name
> is
> > > > > > > l_Ctrl(List View Control), and working fine with Tile Style in
> both
> > > > > > > operating system Win2K and WinXP.
>
> > > > > > > if( l_Ctrl.GetBkImage( &bkImage ) && (bkImage.ulFlags ==
> > > > > > > LVBKIF_SOURCE_NONE ) )
> > > > > > > {
> > > > > > > l_Ctrl.SetBkImage( TEXT( "E:\\watermark.bmp" ), TRUE );
> > > > > > > }
>
> > > > > > > I want to show image as Water Mark in view area, following code
> > > (uses
> > > > > > > SetBkImage function by passing LVBKIMAGE structure) which is
> working
> > > > > > > fine (in case of loading image from file) only in Win2K but its
> not
> > > > > > > working in WinXP.
>
> > > > > > > [CASE-I]
>
> > > > > > > LVBKIMAGE
From: Jeff Partch on
"Mohammad Omer" <momer114(a)gmail.com> wrote in message
news:1162970984.649550.269580(a)i42g2000cwa.googlegroups.com...
> Thanks, it works with LVBKIF_SOURCE_URL flag.
>
>> CString sPath;
>> sPath.Format(_T("res://%s/#2/#%ld"),szBuffer,IDB_WATERMARK);
>
> Few of things are not understand in "sPath" value, what is
> representing in it? The "sPath" contains
> "res://e:\vc\TestWaterMark\debug\TestWaterMark.exe/#2/#198". Is
> "res://" mean protocol for loading thing from resources? Is
> "e:\vc\TestWaterMark\debug\TestWaterMark.exe" will be the absolute
> path of exe or dll path or only exe path? What is "#2" that means?
> And "#198" is my resource Id.
>

http://msdn2.microsoft.com/en-us/library/ms528482(VS.80).aspx
http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/editing/usingeditingglyphs.asp

--
Jeff Partch [VC++ MVP]


First  |  Prev  | 
Pages: 1 2
Prev: VC6 online help (MSDN)
Next: CDHTLMDialog troubles