|
'owner-drawn' button is a button which has BS_OWNERDRAW style set. With this style on button, Windows will send WM_DRAWITEM message to the parent of button when it needs to be repainter. Parent gets the device context (and other information) in the DRAWITEMSTRUCT and actually paints the button.
Use this owner-draw stuff when you want to change the default look of the buttons. CodeProject has many articles about owner-drawn buttons, but they use MFC, not plain Win32 API.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
- Thanks pal!
- Your reply clarifies my doubts.
- I still have a question. When you are mentioning "parent", are you referring to parent window?
- Can you help?
- Regards,
Maer
|
|
|
|
|
When you are mentioning "parent", are you referring to parent window?
Yes. This is usually a dialog or property page.
If you're going to implement owner-draw in a MFC app, note that MFC does some magic for you and 'reflects' the WM_DRAWITEM message to the button itself - all you need is to override the CButton::DrawItem.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
- Thanks pal!
- Your reply is the one I am looking for.
- Regards,
Maer
|
|
|
|
|
- Hi, Sowinski pal!
- I still have a question. Can I implement the message handler function in the parent class and not in the CButton class?
- Can you help?
- Regards,
Maer
|
|
|
|
|
Can I implement the message handler function in the parent class and not in the CButton class?
Yes. Just handle WM_DRAWITEM and do not call the base class (CWnd::OnDrawItem does the reflection and delegates drawing to buttons).
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
- Thanks, Sowinski pal!
- Your reply clarifies my doubts.
- Regards,
Maer
|
|
|
|
|
You might want to take a look at some of the controls at CP, there are a few owner-draw buttons available with source. Creating one which acts almost identically to a standard Win9x button is a peice of cake. Just check the button's state and draw accordingly in DrawItem() .
Simon
Hey, it looks like you're writing a letter!
|
|
|
|
|
- Thanks, Simon pal!
- Your reply clarifies my doubts.
- I still have a question, where can I find the "CP" as you mentioned?
- Can you help?
- Regards,
Maer
|
|
|
|
|
I have a Combobox with an edit control.
It's possible to have items in the list that are more wide than the edit control, but in the edit control the user can't enter more characters in the offschreen area so if the edit control is filled, there is no possibility to enter more characters. Any idea how to solve this?
|
|
|
|
|
|
If you enable the "Auto HScroll" option in the combo box (in the resource editor) the edit box will scroll to the right, like a regular edit box.
Regards,
Alvaro
|
|
|
|
|
Thank you this helps. Sorry for bothering you with this DAU question. My mistake was that I took an extended Combobox which hasn't this option.
So now my app works fine. Thanks a lot!
|
|
|
|
|
Hi...
does anyone have a sample code in which insted of using CFileDialog, u create a customized dialog box wherein u have the standard list showing drive /directories / and etc??? I'm having problems with how to create a list showing the subfolders and existing files similar to when you have CFileDialog...
Thanks a million......
|
|
|
|
|
Hi..
i know that CreateDirectory (..) and RemoveDirectory (..) creates and removes directories respectively.. but how do i ensure that if i create a new directory, the contents within the directory and its subfolders (if it was existing) are deleted...
Thanks a LOT...
|
|
|
|
|
How disable the close button in the caption of the Dialog?
Thanks
|
|
|
|
|
What do you mean by "in the caption"
Would
GetDlgItem(ID_CLOSE)->EnableWindow(FALSE);
do?
A vast majority of our imports comes from outside the country.
George W. Bush
|
|
|
|
|
The heading is such bar, at the top of dialog in which the heading of dialog is written and on the right there is a button to close as [x]
What's the ID_CLOSE
|
|
|
|
|
I don't think it's possible unless you draw the caption and its buttons yourself in WM_NCPAINT.
Why do you need this functionality?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
In some cases it is necessary for me to forbid for the user to make a cancellation, and button Close is equivalent to a cancellation!
|
|
|
|
|
Disabling the menu items in system menu disables the buttons on the Caption Bar.
The following code should do:
CMenu *pMenu= GetSystemMenu(FALSE);
pMenu->EnableMenuItem(SC_CLOSE,MF_BYCOMMAND|MF_DISABLED);
pMenu->RemoveMenu(SC_CLOSE,MF_BYCOMMAND);
Deepak Khajuria
|
|
|
|
|
Nice trick!
I've checked this on W2K - it's enough to call EnableMenuItem. Also, if for some reason it's OK to leave disabled item in the system menu, then MF_GRAYED instead of MF_DISABLED will be better - the menu item will actually look disabled.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Great, it's work!
Thanks everybody for help!!!!
Best regards,
Eugene Pustovoyt
|
|
|
|
|
I'm glad you got it working, but you may consider that instead of disabling the Close button, you let the user press it but then show him a message box explaining why it's wrong to do so. Sometimes this is a more user-friendly way to go, since it doesn't leave the user wondering why he can't do something he's normally allowed to do (like closing windows), and then perhaps picking up the phone to ask Tech Support. If you tell him with a message box, he'll know right away.
Regards,
Alvaro
|
|
|
|
|
Very good remark, but I do not know as it is possible to handle the message from the button taking place outside of client parts of dialog!
Therefore I while shall leave as am! If you may prompt me how make that about what you wrote (it is desirable with an example of a code) I shall be very grateful to you.
|
|
|
|