Solved

add open file dialog to win32 app

Posted on 2002-07-14
3
410 Views
Last Modified: 2008-03-06
I have a simple win32 application that i wrote that loads a .bmp(hard coded filename) and displays it. Right now it has a menu at the top that only has File -> Exit command.

I would like to add a menu item that opens a dialog to browse and open any .bmp that i want.

thanks
0
Comment
Question by:pesst
3 Comments
 

Expert Comment

by:TheFriend
ID: 7152275
See MSDN.
0
 
LVL 2

Author Comment

by:pesst
ID: 7152664
See the question and come up with an answer before you propose one.
0
 
LVL 8

Accepted Solution

by:
fl0yd earned 100 total points
ID: 7152791
You will have to use the win-api-function GetOpenFileName and pass it an OPENFILENAME-structure. You can find further information on all those parameters and combinations possible here:
http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/userinput/commondialogboxlibrary/commondialogboxreference/commondialogboxfunctions/getopenfilename.asp
and here:
http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/userinput/commondialogboxlibrary/commondialogboxreference/commondialogboxstructures/openfilename.asp

For the menu question: Add an 'Open'-option to your File-menu and give a unique ID, let's call it ID_FILE_OPEN. Add a WM_COMMAND-message handler and check whether LOWORD( wParam ) == ID_FILE_OPEN.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

762 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

19 Experts available now in Live!

Get 1:1 Help Now