How to use LoadBitmap in a dialog box
-
I have to load a bitmap in a dialog box. I have loaded the Image in bitmap resource and then I tried the below code HBITMAP hBitmap=(HBITMAP)LoadBitmap(AfxGetInstanceHandle,"IDB_IMAGE"); but when i execute this statement the hBitmap is 0x0000000. Can anyone give me some suggestions. Is there any way to transparent the background of a button S.Yamini
-
I have to load a bitmap in a dialog box. I have loaded the Image in bitmap resource and then I tried the below code HBITMAP hBitmap=(HBITMAP)LoadBitmap(AfxGetInstanceHandle,"IDB_IMAGE"); but when i execute this statement the hBitmap is 0x0000000. Can anyone give me some suggestions. Is there any way to transparent the background of a button S.Yamini
-
even i had this problem once upon a time. do you want to load it in the image box at run time or is it sufficient at design time?
Thanks for ur reply I have to load it in runtime on a dialog box from bitmap resource.Can u tell how to get a DC of dialog box. I tried the code below in OnIntiDialog but it does not work CDC pDC; pDC=Get(); pDC->TextOut(0,0,"Sample"); The Text "Sample" did not display but when i implemented the code in OnPaint with dc from CPaint it works. Can u suggest me some ways to solve it S.Yamini
-
I have to load a bitmap in a dialog box. I have loaded the Image in bitmap resource and then I tried the below code HBITMAP hBitmap=(HBITMAP)LoadBitmap(AfxGetInstanceHandle,"IDB_IMAGE"); but when i execute this statement the hBitmap is 0x0000000. Can anyone give me some suggestions. Is there any way to transparent the background of a button S.Yamini
you should use LoadBitmap as HBITMAP bitmapHandle = LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_IMAGE));
-
you should use LoadBitmap as HBITMAP bitmapHandle = LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_IMAGE));
Thanks it works can u suggest me some ways for getting the DC. I have added the code before. S.Yamini
-
I have to load a bitmap in a dialog box. I have loaded the Image in bitmap resource and then I tried the below code HBITMAP hBitmap=(HBITMAP)LoadBitmap(AfxGetInstanceHandle,"IDB_IMAGE"); but when i execute this statement the hBitmap is 0x0000000. Can anyone give me some suggestions. Is there any way to transparent the background of a button S.Yamini
You should use CPaintDC dc(this); dc.TextOut(...); if u are intended to use this function in OnPaint() method, otherwise u should use CClientDC dc(this); dc.TextOut(...);
-
Thanks for ur reply I have to load it in runtime on a dialog box from bitmap resource.Can u tell how to get a DC of dialog box. I tried the code below in OnIntiDialog but it does not work CDC pDC; pDC=Get(); pDC->TextOut(0,0,"Sample"); The Text "Sample" did not display but when i implemented the code in OnPaint with dc from CPaint it works. Can u suggest me some ways to solve it S.Yamini
it is a bit easy task to load an image, on a dialog but before i proceed to suggest you the best technique, that suits your application, please answer these questions. 1.is your image constant throughout the application, or it may change based on the context dynamically. 2.have you already created a resource for that image? 3.if you have only one image and want to see it on the screen, then you can link it statically. 4.if you have to load images, based on the context(condition) then you can take that many number of controls and toggle them as per your requirement.
-
You should use CPaintDC dc(this); dc.TextOut(...); if u are intended to use this function in OnPaint() method, otherwise u should use CClientDC dc(this); dc.TextOut(...);
I tried CClientDC but it did not work.Should i have to change any property of the dialog box S.Yamini
-
it is a bit easy task to load an image, on a dialog but before i proceed to suggest you the best technique, that suits your application, please answer these questions. 1.is your image constant throughout the application, or it may change based on the context dynamically. 2.have you already created a resource for that image? 3.if you have only one image and want to see it on the screen, then you can link it statically. 4.if you have to load images, based on the context(condition) then you can take that many number of controls and toggle them as per your requirement.
I have to change the image dynamically according to the move movement on the dialog box S.Yamini
-
I have to load a bitmap in a dialog box. I have loaded the Image in bitmap resource and then I tried the below code HBITMAP hBitmap=(HBITMAP)LoadBitmap(AfxGetInstanceHandle,"IDB_IMAGE"); but when i execute this statement the hBitmap is 0x0000000. Can anyone give me some suggestions. Is there any way to transparent the background of a button S.Yamini
If u want it use it with CDC(though not recommended) u can use it like below, PAINTSTRUCT pStruct; CDC* pDC = BeginPaint(&pStruct); //Use CDC here. pDC->DoWhatEverYouWantToDo(); // !! EndPaint(&pStruct); //Don't forget this o'wise sometime result would be disastrous.!! (For your knowledge, CClientDC and CPaintDC both do BeginPaint in Constructor and EndPaint in Destructor..)
-
If u want it use it with CDC(though not recommended) u can use it like below, PAINTSTRUCT pStruct; CDC* pDC = BeginPaint(&pStruct); //Use CDC here. pDC->DoWhatEverYouWantToDo(); // !! EndPaint(&pStruct); //Don't forget this o'wise sometime result would be disastrous.!! (For your knowledge, CClientDC and CPaintDC both do BeginPaint in Constructor and EndPaint in Destructor..)
I tried it in onintidialog it does not work. Can u suggest some more ways to solve this issue S.Yamini
-
I have to change the image dynamically according to the move movement on the dialog box S.Yamini
-
I tried it in onintidialog it does not work. Can u suggest some more ways to solve this issue S.Yamini
after onInitdialog completes, whole dialog being repainted so your graphics erased. one solution is to override OnEraseBkgnd and return TRUE from it so System will never erase background. but be careful, system never erase Background !!
-
I have two images.I has to toggle according to the mouse movement. I nned to know how to get the dc of the dialog control.Please S.Yamini
-
after onInitdialog completes, whole dialog being repainted so your graphics erased. one solution is to override OnEraseBkgnd and return TRUE from it so System will never erase background. but be careful, system never erase Background !!
I cannot use erasebk bcoz i have to toggle the images. S.Yamini
-
I cannot use erasebk bcoz i have to toggle the images. S.Yamini
so whats problem will be in toggling images after overriding eraseBk ??? whatever painting done by you will be there, only system won't paint its default bkground ...
-
are you using the bitmap control you have in your tool bar, or is it ok for you if i give my active X control which can take any bitmap image any time. what all you have to do is, you have to specify the file path. for example, ctrl.SetImage("C:\\image1.bmp"); then after some time, ctrl.SetImage("C:\\image2.bmp"); is it ok for u.
-
I have two images.I has to toggle according to the mouse movement. I nned to know how to get the dc of the dialog control.Please S.Yamini
-
so whats problem will be in toggling images after overriding eraseBk ??? whatever painting done by you will be there, only system won't paint its default bkground ...
Yes it will work. Can u suggest me for transparenting the background for the button control S.Yamini
-
Yes it will work. Can u suggest me for transparenting the background for the button control S.Yamini
again, You can override OnEraceBk,, and return TRUE from there for that button, it won't paint buton background...