C Board  

Go Back   C Board > Platform Specific Boards > Windows Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 09-09-2002, 06:05 AM   #1
mustang benny
 
bennyandthejets's Avatar
 
Join Date: Jul 2002
Posts: 1,401
BN_CLICKED, change button style

using win32 API, in my WndProc, i have the following code:

Code:
case BN_CLICKED:
    SendMessage((HWND) lParam, BM_SETSTYLE, 
    (WPARAM) LOWORD(BS_TOP), 
    MAKELPARAM(TRUE, 0));
break;
i know the BN_CLICKED message is being received right, but when i send this message to change the button style, nothing happens. what is the problem?
__________________
benforbes@optusnet.com.au
Microsoft Visual Studio .NET 2003 Enterprise Architect
Windows XP Pro

Code Tags
Programming FAQ
Tutorials
bennyandthejets is offline   Reply With Quote
Old 09-09-2002, 05:54 PM   #2
Registered User
 
sean345's Avatar
 
Join Date: Mar 2002
Posts: 346
I have not used that message before, but here is the documentation I have on it:
Quote:
The BN_CLICKED notification message is sent when the user clicks a button. The parent window of the button receives this notification message through the WM_COMMAND message. Unlike the other button notification messages, this message is intended for applications written for any version of Windows.

BN_CLICKED
idButton = (int) LOWORD(wParam); // identifier of button
hwndButton = (HWND) lParam; // handle of button


Remarks

A disabled button does not send a BN_CLICKED notification message to its parent window.

See Also

WM_COMMAND
Here is some documentation on BM_SETSTYLE
Quote:
An application sends a BM_SETSTYLE message to change the style of a button.

BM_SETSTYLE
wParam = (WPARAM) LOWORD(dwStyle); // style
lParam = MAKELPARAM(fRedraw, 0); // redraw flag


Parameters

dwStyle

Value of wParam. Specifies the button style. For an explanation of button styles, see the following Remarks section.

fRedraw

Value of the low-order word of lParam. Specifies whether the button is to be redrawn. A value of TRUE redraws the button; a value of FALSE does not redraw the button.

Return Values

This message always returns zero.

Remarks

Following are the available button styles:

Style Meaning
BS_3STATE Creates a button that is the same as a check box, except that the box can be grayed as well as checked or unchecked. Use the grayed state to show that the state of the check box is not determined.
BS_AUTO3STATE Creates a button that is the same as a three-state check box, except that the box changes its state when the user selects it. The state cycles through checked, grayed, and unchecked.
BS_AUTOCHECKBOX Creates a button that is the same as a check box, except that the check state automatically toggles between checked and unchecked each time the user selects the check box.
BS_AUTORADIOBUTTON Creates a button that is the same as a radio button, except that when the user selects it, Windows automatically sets the button’s check state to checked and automatically sets the check state for all other buttons in the same group to unchecked.
BS_CHECKBOX Creates a small, empty check box with text. By default, the text is displayed to the right of the check box. To display the text to the left of the check box, combine this flag with the BS_LEFTTEXT style (or with the equivalent BS_RIGHTBUTTON style).
BS_DEFPUSHBUTTON Creates a push button that behaves like a BS_PUSHBUTTON style button, but also has a heavy black border. If the button is in a dialog box, the user can select the button by pressing the ENTER key, even when the button does not have the input focus. This style is useful for enabling the user to quickly select the most likely (default) option.
BS_GROUPBOX Creates a rectangle in which other controls can be grouped. Any text associated with this style is displayed in the rectangle’s upper left corner.
BS_LEFTTEXT Places text on the left side of the radio button or check box when combined with a radio button or check box style. Same as the BS_RIGHTBUTTON style.
BS_OWNERDRAW Creates an owner-drawn button. The owner window receives a WM_MEASUREITEM message when the button is created and a WM_DRAWITEM message when a visual aspect of the button has changed. Do not combine the BS_OWNERDRAW style with any other button styles.
BS_PUSHBUTTON Creates a push button that posts a WM_COMMAND message to the owner window when the user selects the button.
BS_RADIOBUTTON Creates a small circle with text. By default, the text is displayed to the right of the circle. To display the text to the left of the circle, combine this flag with the BS_LEFTTEXT style (or with the equivalent BS_RIGHTBUTTON style). Use radio buttons for groups of related, but mutually exclusive choices.
BS_USERBUTTON Obsolete, but provided for compatibility with 16-bit versions of Windows. Win32-based applications should use BS_OWNERDRAW instead.
BS_BITMAP Specifies that the button displays a bitmap.
BS_BOTTOM Places text at the bottom of the button rectangle.
BS_CENTER Centers text horizontally in the button rectangle.
BS_ICON Specifies that the button displays an icon.
BS_LEFT Left-justifies the text in the button rectangle. However, if the button is a check box or radio button that does not have the BS_RIGHTBUTTON style, the text is left justified on the right side of the check box or radio button.
BS_MULTILINE Wraps the button text to multiple lines if the text string is too long to fit on a single line in the button rectangle.
BS_NOTIFY Enables a button to send BN_DBLCLK, BN_KILLFOCUS, and BN_SETFOCUS notification messages to its parent window. Note that buttons send the BN_CLICKED notification message regardless of whether it has this style.
BS_PUSHLIKE Makes a button (such as a check box, three-state check box, or radio button) look and act like a push button. The button looks raised when it isn’t pushed or checked, and sunken when it is pushed or checked.
BS_RIGHT Right-justifies text in the button rectangle. However, if the button is a check box or radio button that does not have the BS_RIGHTBUTTON style, the text is right justified on the right side of the check box or radio button.
BS_RIGHTBUTTON Positions a radio button’s circle or a check box’s square on the right side of the button rectangle. Same as the BS_LEFTTEXT style.
BS_TEXT Specifies that the button displays text.
BS_TOP Places text at the top of the button rectangle.
BS_VCENTER Places text in the middle (vertically) of the button rectangle.
Hope that helps.

- Sean
__________________
If cities were built like software is built, the first woodpecker to come along would level civilization.
Black Frog Studios
sean345 is offline   Reply With Quote
Old 09-10-2002, 02:33 AM   #3
mustang benny
 
bennyandthejets's Avatar
 
Join Date: Jul 2002
Posts: 1,401
i think i have that some documentation, so that doesn't really help at all. according to the doco, everything im doing is right. so whats wrong?
__________________
benforbes@optusnet.com.au
Microsoft Visual Studio .NET 2003 Enterprise Architect
Windows XP Pro

Code Tags
Programming FAQ
Tutorials
bennyandthejets is offline   Reply With Quote
Old 09-10-2002, 02:37 AM   #4
Refugee
 
face_master's Avatar
 
Join Date: Aug 2001
Posts: 2,052
another useless post...

>>so whats wrong?

You!
__________________
Please direct all complaints regarding this post to the nearest brick wall Have a nice day.
face_master is offline   Reply With Quote
Old 09-10-2002, 02:56 AM   #5
mustang benny
 
bennyandthejets's Avatar
 
Join Date: Jul 2002
Posts: 1,401
what r u trying to say face master?
__________________
benforbes@optusnet.com.au
Microsoft Visual Studio .NET 2003 Enterprise Architect
Windows XP Pro

Code Tags
Programming FAQ
Tutorials
bennyandthejets is offline   Reply With Quote
Old 09-10-2002, 03:07 AM   #6
train spotter
 
Join Date: Aug 2001
Location: near a computer
Posts: 3,450
Check the HWND you are using. Also the LPARAM is just TRUE (or non zero).

Try
Code:
 
SendMessage(GetDlgItem(hWnd,ID_BUTTON)
           ,BM_SETSTYLE
           ,(WPARAM)BS_TOP
           ,(LPARAM)1);//true redraws button
I also use the BN_CLICKED differently

Code:
case WM_COMMAND:
{   
   idControl	= GET_WM_COMMAND_ID(wParam, lParam) ;
   switch(idControl)
   case ID_BUTTON:
   if (BN_CLICKED == HIWORD(wParam))
   {//button clicked code
__________________
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche

"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best

"If you are going through hell....keep going."
Winston Churchill
novacain is offline   Reply With Quote
Old 09-10-2002, 06:24 AM   #7
mustang benny
 
bennyandthejets's Avatar
 
Join Date: Jul 2002
Posts: 1,401
it still doesn't work. i know the code is being reached, so the problem must lie with the SendMessage() function.
Code:
SendMessage(GetDlgItem(hwnd,ID_OK)
	,BM_SETSTYLE
	,(WPARAM)BS_TOP
	,(LPARAM)1);//true redraws button
that code is just not doing anything. help!
__________________
benforbes@optusnet.com.au
Microsoft Visual Studio .NET 2003 Enterprise Architect
Windows XP Pro

Code Tags
Programming FAQ
Tutorials
bennyandthejets is offline   Reply With Quote
Old 09-10-2002, 06:33 PM   #8
Registered User
 
sean345's Avatar
 
Join Date: Mar 2002
Posts: 346
Maybe there is little to no visual change between the two styles.

- Sean
__________________
If cities were built like software is built, the first woodpecker to come along would level civilization.
Black Frog Studios
sean345 is offline   Reply With Quote
Old 09-10-2002, 11:27 PM   #9
train spotter
 
Join Date: Aug 2001
Location: near a computer
Posts: 3,450
Try getting the buttons style and adding the BS_TOP. (which only draws the text near the top of the button)

try BS_FLAT to see if it changes.

Call UpdateWindow() with the hWnd of the Buttons Dialog.
__________________
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche

"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best

"If you are going through hell....keep going."
Winston Churchill
novacain is offline   Reply With Quote
Old 09-11-2002, 03:59 AM   #10
mustang benny
 
bennyandthejets's Avatar
 
Join Date: Jul 2002
Posts: 1,401
how do i get the style of the button? my documentation only has BM_SETSTYLE, no BM_GETSTYLE. however, i dont think that would work, because when my buttons are created, they are created with the WS_CHILD and WS_VISIBLE styles. therefore, if i sent a change style message not including those 2 styles, things would be majorly messed up. so obviously it is not just a matter of adding BS_TOP or whatever to the existing styles.
__________________
benforbes@optusnet.com.au
Microsoft Visual Studio .NET 2003 Enterprise Architect
Windows XP Pro

Code Tags
Programming FAQ
Tutorials
bennyandthejets is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
MFC: Change the color of static text with button press? BrianK Windows Programming 2 06-16-2004 11:03 PM
Tab Controls - API -KEN- Windows Programming 7 06-02-2002 09:44 AM
disabling button in another prog timmygax Windows Programming 11 10-29-2001 03:40 PM
How To Change Caption's On A Button When It Is Click ? SonicWave Windows Programming 1 09-19-2001 02:14 PM
trying to make change from the price of the item and the amount given. please help!!! tobyman C++ Programming 2 09-04-2001 02:12 PM


All times are GMT -6. The time now is 01:52 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22