?
Solved

Create a Button using CreateWindow

Posted on 2003-03-22
5
Medium Priority
?
813 Views
Last Modified: 2013-12-03
Hi,

I am trying to create a button on a window using the CreateWindow function and the class "Button". However, the button being created is different in looks than buttons I create using Dialog Boxes resources. It has a different font and perhaps other different details that I can't make for sure. Am I missing some style flag? I found no help on that issue in the SDK Documentation. I wish to make the button I create on the window to look like my dialog boxes buttons.
Here is the CreateWindow code:

m_hPlayButton = CreateWindow("Button", "&Play", WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, 5, 5, 100, 100, m_hPlayWindow, NULL, (HINSTANCE)GetWindowLong(m_hPlayWindow, GWL_HINSTANCE), NULL);

Thanks,
Idan.
0
Comment
Question by:IdanM
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 6

Expert Comment

by:PlanetCpp
ID: 8187831
did you specify a different font when you used dialogs? i don't use dialogs but i think they should look exactlly the same.
you can look at the source on my site www.PlanetCpp.com.
most source has a button on it for you to look at and one has the ability to change fonts.
0
 

Author Comment

by:IdanM
ID: 8187944
I just used the resource editor to edit a Dialog Boxes. Some of your buttons in your site look the same as mine, with a different font.
0
 
LVL 3

Accepted Solution

by:
TascoDLX earned 150 total points
ID: 8189247
To change the font, send the WM_SETFONT message to the button.  Such as:

   PostMessage(m_hPlayButton, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE,0));

You can pass a handle to any font you wish.  Such as:

   HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);

Enjoy!
0
 
LVL 6

Expert Comment

by:PlanetCpp
ID: 8189405
the buttons on my site look the same as the ones you're having a problem with? thats the way buttons look, unless you specify to make them checkbox style. what is the difference that used to be in the dialog buttons, they should be the same
0
 

Author Comment

by:IdanM
ID: 8190118
Thanks, that did the trick :)
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question