Solved

Three Easy questions, I'm a begginer

Posted on 1998-12-20
7
212 Views
Last Modified: 2010-04-02
Using Visual C++ 6.0
How do I make the backround black on a dialog box?
How do you get the dementions of a bitmap or control?
For example like Bitmap.top and Bitmap.left in Visual Basic
How do you play simple sound waves?
0
Comment
Question by:bradsoblesky
  • 3
  • 2
  • 2
7 Comments
 
LVL 8

Expert Comment

by:Answers2000
ID: 1180689
1. MFC program - background dialog color - stick in InitInstance
SetDialogBkColor( RGB(0,0,0), RGB(255,255,255) ) ; // background to black, text to white (black on black is not to readable :-))

2. Get Dimensions of a bitmap
BITMAP bm ;
GetObject( hBitmap, sizeof bm, bm ) ;
// where hBitmap = HBITMAP of the bitmap
// bm.bmWidth and bm.bmHeight hold the bitmap size

3. Get Dimensions of a control
CRect rect ;
pWnd->GetWindowRect( &rect ) ;
// pWnd = the control, if you're in a dialog try
//GetDlgItem( IDC_EDIT )->GetWindowRect( &rect ) ;

coords go into rect in screen units.  Typically you want them in client coords (relative to the window, you can convert to these using)
ScreenToClient( &rect ) ;

3. Playing sound waves - see next comment
0
 
LVL 8

Accepted Solution

by:
Answers2000 earned 20 total points
ID: 1180690
Playing sound

1. To play a .WAV file

     PlaySound( "file.wav", NULL, SND_FILENAME ) ;
     or
     sndPlaySound( "file.wav", 0 ) ;

     for file name make sure you specify the full path.  If you use \ in string literals, then make sure you escape it
     e.g.
     "C:\\WINDOWS\\file.wav"  in C, means "C:\WINDOWS\file.wav" in DOS


     2. To play from resources

     i. Insert a .wav file into your resources
     - Go to resource tree on workspace
     - Right click
     - Pick "Import..."
     - Browse the WAV file
     - Assign an arbitary id, e.g. "IDC_WAVE"

     ii. Play the wave file with
     PlaySound( MAKEINTRESOURCE(IDC_WAVE),  AfxGetResourceHandle(), SND_RESOURCE ) ;


Make sure you #include <mm.h> (e.g. add this to stdafx.h) and link to winmm.lib (project settings)
0
 
LVL 4

Expert Comment

by:pagladasu
ID: 1180691
Answers2000,
Solution 2 and 3 are OK. I have a few queries about solution number. Won't SetDialogBkColor change the background color of all dialog boxes in the application.
Thanks
pagladasu
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:bradsoblesky
ID: 1180692
Thanks for your help :)
0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1180693
pagla - yes

u r okay with this ?
0
 

Author Comment

by:bradsoblesky
ID: 1180694
I'm not really...I just want the background.But it's better than nothing.
0
 
LVL 4

Expert Comment

by:pagladasu
ID: 1180695
Do you want the background of any particular dialog box of your app to be different?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

911 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now