|
CBitmapButton myButton;
myButton.Create(NULL, WS_CHILD|WS_VISIBLE|BS_OWNERDRAW,
CRect(10,10,100,100), pParentWnd, 1);
myButton.LoadBitmaps(IDB_UP, IDB_DOWN, IDB_FOCUS, IDB_DISABLE);
You must replace IDB_UP, IDB_DOWN, IDB_FOCUS, IDB_DISABLE with your own bitmap id's that you have imported or added to the project.
Jesus Loves You and Me <marquee direction="up" height="50" scrolldelay="1" step="1" scrollamount="1" style="background-color:'#44ccff'">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
But if I replace the parameter
"pParentWnd" by "this" the button is not showing. To Show that what I have to do?
------------------------------------------------------------------
CBitmapButton myButton;
myButton.Create(NULL, WS_CHILD|WS_VISIBLE|BS_OWNERDRAW, CRect(10,10,100,100), this, 1);
// Load the bitmaps for this button.
myButton.LoadBitmaps(IDB_UPU, IDB_DOWND, IDB_FOCUSF, IDB_DISABLEX);
------------------------------------------------------------------
plz help.
Thank u.
-- modified at 4:10 Thursday 29th December, 2005
|
|
|
|
|
Are you trying this in a dialog.
Do you already have a button. If so then you have to add a member variable for that button with type as CBitmapButton and then use AutoLoad(). And don't forget to set the ownerdrawn property to true.
m_YourBmpButton.AutoLoad(IDC_MYBUTTON, this);
and then set the images.
Perhaps you may not have to call AutoLoad(...) if you are adding a member variable.
Jesus Loves You and Me <marquee direction="up" height="50" scrolldelay="1" step="1" scrollamount="1" style="background-color:'#44ccff'">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
The problem is that since u r creating button in a function, so it will be allocated on stack. and as the function is returned back ,where u are creating a button, all items are pop out of the stack. So ur button will no longer exists. Either u make it(myButton) member of class or Create the CBitmapButton object on Heap.
The code for creating on Heap is:
<br />
CBitmapButton* myButton = new CBitmapButton;<br />
myButton->Create(NULL, WS_CHILD|WS_VISIBLE|BS_OWNERDRAW, CRect(10,10,100,100), this, 1);<br />
myButton->LoadBitmaps(IDB_UPU, IDB_DOWND, IDB_FOCUSF, IDB_DISABLEX)<br />
Plus u must call delete in ur destructor or the entry after the button is not required.
It hope it helps :P
-- modified at 4:33 Thursday 29th December, 2005
|
|
|
|
|
Ok I've got .
Very very Thanks
|
|
|
|
|
Still now I'm not geting the result.
PLz help.
I am using dialog base.
I take a button.
Then create member m_button of the button.
------------------------------------------------------------------
CBitmapButton m_button;//at constractor
-------------------------------------------------------------------
DDX_Control(pDX, IDC_BUTTON1, m_button);(at DoDataExchange)
-------------------------------------------------------------------
I've import bitmaps mamed IDB_UP, IDB_DOWN, IDB_FOCUS, IDB_DISABLE
then using ....
-------------------------------------------------------------------
m_button.LoadBitmaps("IDB_UPU", "IDB_DOWND", "IDB_FOCUSF", "IDB_DISABLEX");
-----------------------------------------------------------------------
Q1> How can i give the property "WS_CHILD|WS_VISIBLE|BS_OWNERDRAW".
Q2> If i use Autoload() then how i can give names of Bitmaps?
Very Very thanks.
|
|
|
|
|
Saday Sarkar wrote: CBitmapButton m_button;//at constractor
What's this.
You declared m_button in the constructor. You must do it in the header file.
using AutoLoad is easy. But I don't think you will need it. But any way here it is.
m_button.AutoLoad(IDC_BUTTON1, this/*parent window*/);
m_button.SetBitmaps(..........)
This should work.
Make sure that the button in the dialog has the ownerdrawn property set to TRUE
Jesus Loves You and Me <marquee direction="up" height="50" scrolldelay="1" step="1" scrollamount="1" style="background-color:'#44ccff'">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
Yes I've got.
I've not do"the button in the dialog has the ownerdrawn property set to TRUE "
Now ok.
Very Very Thanks.
|
|
|
|
|
I think this way is easier:
CButton* pButton = (CButton*)GetDlgItem(IDC_VIEWSCAPS);
ASSERT(pButton);
if(pButton)
{
VERIFY(m_bmpBSBitmap.LoadBitmap(IDB_ADD));
HBITMAP hbmp = (HBITMAP)m_bmpBSBitmap.GetSafeHandle();
pButton->SetBitmap(hbmp);
}
IDB_ADD is replaced with bitmap resource id
IDC_VIEWSCAPS is replaced with button resource id
make sure you set 'bitmap' property for the button to true
My articles
BlackDice
|
|
|
|
|
|
Programming Windows With MFC- by Jeff Prosise
Programming Windows by Charles Petzold
Programming Microsoft Visual C++ by -David Kruglinski ,Scot Wingo ,George Shepherd
hope that helps..
|
|
|
|
|
y did u delete the message?
|
|
|
|
|
may be he thought that since he got his answer he should delete the message :P
-Prakash
|
|
|
|
|
vamshin wrote: y did u delete the message?
he don't want to share this info with other
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Got lost
Jesus Loves You and Me <marquee direction="up" height="50" scrolldelay="1" step="1" scrollamount="1" style="background-color:'#44ccff'">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
Why one WM_CHAR is hooked twice when install a WH_GETMESSAGE hook?
|
|
|
|
|
Could be one for your thread and one for the system.
Hence two.
Jesus Loves You and Me <marquee direction="up" height="50" scrolldelay="1" step="1" scrollamount="1" style="background-color:'#44ccff'">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
I have a question of the *.bmp of the clipboard.
I want to attain the Gray value of the *.bmp in clipboard.but I fail!How to get the Gray value?
help me,please! thank you very much!
greenapplezlp
-- modified at 3:00 Thursday 29th December, 2005
|
|
|
|
|
You can simply use the below formula
Gray = (r*11 + g*16 + b*5)/32.
Get every Pixel and set it colors with the help of this formula.
I hope u get the basic !!!
|
|
|
|
|
Well I am a little confused with naming jargon of casting.
My intended goal was:
CBase* pBase = static_cast<CBase*>(derived);
What is it called upcasting/downcasting ?
The below articles says it is upcasting:
http:
While in MSDN they interpret as downcasting:
http:
Which one is correct ?
-- modified at 2:44 Thursday 29th December, 2005
|
|
|
|
|
Look at the class-hierarchy as an upside-down piramide.
When you cast to a base-class you cast down in the hierarchy -> downcast
When you cast to a derived class you cast up in the hierarchy -> upcast.
Hope this clears it up somewhat for you...
Greetz,
Davy
|
|
|
|
|
GDavy wrote: Look at the class-hierarchy as an upside-down piramide.
I agree with that, but different ppl should not have different way of representing a inheritance.
base
^
|
Derived
Microsoft always follows this notation in their documentation, so upcasting should have been the rite notation to use.
-Prakash
|
|
|
|
|
Mr.Prakash wrote: base
^
|
Derived
Microsoft always follows this notation in their documentation
yeah, you're right about that. I think the people writing those documents had problems with the concept of an upside-down piramide.
But I still have to disagree with your definition of down-cast / up-cast...
Here's another analogy (a better one perhaps?)->look at it as a tree (but only the part from the ground and up, skip the roots);).
the base-class is the trunk and all derived classes are the branches. Like a family tree.
I see an up-cast as an upgrade -> extra functionality, more specific so from base to derived class.
a down-cast is down-grade-> less functionality, more general handling so from derived to base class.
|
|
|
|
|
GDavy wrote: Here's another analogy (a better one perhaps?)->look at it as a tree (but only the part from the ground and up, skip the roots).
the base-class is the trunk and all derived classes are the branches. Like a family tree.
I agree with your analogy, but microsoft should follow the standard notation used for derivation IMHO
-Prakash
|
|
|
|
|
I guess the msdn documentation is wrong.
upcasting - derived to base
downcasting - base to derived
-Prakash
|
|
|
|