mfc >> Looking for sample code

by Kevin D. Quitt » Fri, 16 Sep 2005 04:53:25 GMT

I need to write an app that will (magically) create a bitmap, and display it in a window
of specific width, but (possible) scrollable in height. Is there something out there that
gets close? TIA.


--
#include <standard.disclaimer>
_
Kevin D Quitt USA 91387-4454 96.37% of all statistics are made up

mfc >> Looking for sample code

by Joseph M. Newcomer » Fri, 16 Sep 2005 05:45:19 GMT


Not sure about magically creating the bitmap. This is usually left as an Exercise for the
Programmer.

Check on www.codeproject.com for lots of bitmap-related examples. You will have to set the
window width. How hard it is to scroll depends on whether or not you just need a generic
control that scrolls or you can use a CScrollView.
joe



Joseph M. Newcomer [MVP]
email: XXXX@XXXXX.COM
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

mfc >> RE: Looking for sample code

by v-garych » Fri, 16 Sep 2005 14:08:08 GMT

Hi Kevin,

MVP Joseph pointed out a good start for you: www.codeproject.com, there are
many valuable samples code there.

For example, if you want to create a bitmap with yourself, you can refer to
the following article for the details of GDI drawing:

Bitmap Basics - A GDI tutorial
http://www.codeproject.com/bitmap/gditutorial.asp


If you already have a bitmap and want to show it in a window scrollable, I
suggest you take a look on the related codeproject's sample project:

Displaying Bitmap with Scrolling
http://www.codeproject.com/bitmap/bmpscroll.asp


Wish it helps!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.

mfc >> Looking for sample code

by Tom Serface » Sat, 17 Sep 2005 00:12:26 GMT

This article may help you out:

http://msdn.microsoft.com/msdnmag/issues/01/10/c/

Tom

mfc >> Looking for sample code

by Kevin D. Quitt » Tue, 20 Sep 2005 02:49:54 GMT

My thanks to all who replied. I was kinda of hoping not to have to actually learn
anything in the process, but...


--
#include <standard.disclaimer>
_
Kevin D Quitt USA 91387-4454 96.37% of all statistics are made up

mfc >> Looking for sample code

by Kevin D. Quitt » Tue, 20 Sep 2005 06:59:22 GMT


Somewhat less than useful, unfortunately. Without project information, they're hard to
build, although I managed that. Also, the tutorial itself looks like one of those things
that are obvious to anybody who already knows how to do it, but otherwise fairly opaque.

I'v never dealt with displaying any in VC++, but I have a lot of experience in image
synthesis. I would prefer not to have to create a file, then load the file, but that
looks like the only easy path.

--
#include <standard.disclaimer>
_
Kevin D Quitt USA 91387-4454 96.37% of all statistics are made up

mfc >> Looking for sample code

by v-garych » Tue, 20 Sep 2005 13:00:16 GMT

> I would prefer not to have to create a file, then load the file,

That's OK, Kevin, good luck!


Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.

mfc >> Looking for sample code

by Joseph M. Newcomer » Wed, 21 Sep 2005 01:35:54 GMT

Well, you said "magically" create a bitmap. Since you didn't say anything about what you
intend to do, it is hard to tell you the exact incantation required. For example, do you
want a bitmap that shows rendered text? Do you want a drawing of geometric objects? Do
you want to deal with a digital photograph? Do you need texturing? Tell us a bit more
about the outcome and we can suggest how to get there, but with the "magically create"
requirement, we can only say "wave your hands in the appropriate fashion".

You seemed to suggest that the more serious issues were the scrolling issues. In that,
you need to state if you are making this the entire content of a view (in which case you
would derive from CScrollView and most of what you need is built-in) or you would have to
create a custom control, probably from a CWnd, in which case you need to do a bit more to
make it all work. Note that none of this is overly challenging, just lots of fairly simple
pieces put together, but *which* simple pieces can be the actual challenge. And overall,
the integration of several interacting pieces may also produce a set of problems you have
to address. Once you can explain your problem, we can help more with some answers.
joe




Joseph M. Newcomer [MVP]
email: XXXX@XXXXX.COM
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

mfc >> Looking for sample code

by Joseph M. Newcomer » Wed, 21 Sep 2005 01:38:29 GMT

Whoops, in that case you're in the wrong profession...

(According to an eWeek letter-to-the-editor, one IT manager was explaining the difficulty
of recruiting new people, who were dismayed that they would 'have to spend the rest of
their lives learning new technology', and were opting for professions like medice, law,
and accounting. Which led me to write a letter (which wasn't published) asking if these
same people would want to go to a doctor who had learned nothing new since medical school,
a lawyer unfamiliar with recent case law, or an accountant whose last review of tax law
was in college...)

We can help, but we need a problem statement first...
joe



Joseph M. Newcomer [MVP]
email: XXXX@XXXXX.COM
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

mfc >> Looking for sample code

by Kevin D. Quitt » Wed, 21 Sep 2005 02:54:38 GMT


Fair enough. I want the user to be able to select a file, and my function will create an
image in a buffer, one byte per pixel, with a corresponding palette (only two values will
be used). The buffer will always be 320 pixels wide and at least 240 pixels tall, but
might be taller, based on the content of the file.

Coming from an image synthesis background, ny natural method is to create the image with
the top at the beginning of the buffer, but I can just as easily make it upside-down, ala
BMP format. I'm not unfamiliar with VC++, but I've never written VC++ programs that
display anything or interact with the user. My initial thought was to make it a
command-line program that creates a PNG file, but an interactive version would be much
more useful; the ability to scroll down is part of that. I also thought about using a VB
front end and doing my image generation in an OCX, but I would like to have a program that
doesn't require an installer.

It would also be nice if the user could specify what colors to use for the two colors (via
hex code or whatever).


--
#include <standard.disclaimer>
_
Kevin D Quitt USA 91387-4454 96.37% of all statistics are made up

mfc >> Looking for sample code

by Kevin D. Quitt » Wed, 21 Sep 2005 02:55:28 GMT


Nah - I was just trying to avoid having to become an expert in yet another area. Pure
laziness, is all.


--
#include <standard.disclaimer>
_
Kevin D Quitt USA 91387-4454 96.37% of all statistics are made up

mfc >> Looking for sample code

by Joseph M. Newcomer » Thu, 22 Sep 2005 00:16:34 GMT

OK, I'm presuming the file contains an image. Is it a BMP file or is it some other
format?

Create an array of bits big enough to hold your image. Each byte will represent 8 bits.
You must round up to the next WORD boundary, e.g., if you have a 33-bit-wide bitmap, you
will need 3 WORD values to hold it, or 6 bytes, for each horizontal line.

Set the bits based on reading your file.

Then call SetBitmapBits to set these to a CBitmap object, which has been created with the
appropriate dimensions.

I've not done monochrome bitmaps, but I recall there is a way to set the colors.
joe




Joseph M. Newcomer [MVP]
email: XXXX@XXXXX.COM
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

mfc >> Looking for sample code

by Joseph M. Newcomer » Thu, 22 Sep 2005 00:17:11 GMT

Yeah, I know. I'm in the same fix with respect to Unicode character display formatting
this week...
joe




Joseph M. Newcomer [MVP]
email: XXXX@XXXXX.COM
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

Similar Threads

1. Looking for sample code to send email with exchange

2. Delphi 7, Excel - have problem - looking for sample code

Hi all, 

I had an app that worked just fine in D5; no longer under D7 (as I've read 
from others as well). 

Have heard of sample code floating around but cannot find it. Can anyone 
point me in the right direction please.

I need to 

    	- create workbook with shhets
    	- insert data into cells
    	- set come cell properties (bold fint etc.)
    
TIA !!!!

3. Looking for some sample codes in C# - CSharp/C#

4. looking for code sample for non-blocking TCP sockets

Hi,

I need a code sample for doing this:

-  support for multiple agents that know each other and can talk each other
   over a non-blocking TCP socket.
   each agent can send and recieve data to/from each other.
-  handling agent down events (i don't know how to do it in an elegant way 
when using the socket select method).

I prefer to use the Socket.Select method.
All the socket operations must be in a non-blocking mode.

Thanks.

5. Looking for WinSNMP sample code

6. looking for custom control sample code

7. Creating a Database using the STL: Newbie looking for code samples

8. Code review of cross platform code sample