|
Braulio Díez wrote:
I have a bitmap in the resources, and I would like to print it, how can I do that ? ( there are a lot of problems when I try to do that, because the bitmap is DDB).
What kind of problems are you experiencing?
Actually, device independant bitmaps (DIB) are the types of bitmaps that are stored in a resource file. Device dependant bitmaps (ddb) is the type of bitmap that is selected into a device context.
Let me know what you problem is and maybe we can solve it.
|
|
|
|
|
Hi,
The problem that I have is that I want to print a bitmap ( from the resources), to do that, I have to convert to DIB, to allow print it in the printer, and then use StretchBlt to scale it, but Now I cannot manage with the coordinates to print it ( it doesn´t print anything at all).
CDC memDC;
CBitmap BmpLogo.LoadBitmap(IDB_BERTHILDA_BASELINE);
memDC.CreateCompatibleDC(NULL);
CBitmap* pOldBitmap = memDC.SelectObject(&BmpLogo);
StretchBlt(
pDC->GetSafeHdc(),
0,
0,
20000,
20000,
memDC.GetSafeHdc(),
0,
0,
35000,
38000,
SRCCOPY
);
I´m just playing with the coord numbers to see if it paints at least something...
Thanks in advance, Bye!
Braulio
|
|
|
|
|
Braulio Díez wrote:
StretchBlt( pDC->GetSafeHdc(), // handle to destination DC 0, // x-coord of destination upper-left corner 0, // y-coord of destination upper-left corner 20000, // width of destination rectangle 20000, // height of destination rectangle memDC.GetSafeHdc(), // handle to source DC 0, // x-coordinate of source upper-left corner 0, // y-coordinate of source upper-left corner 35000, // width of source rectangle 38000, // height of source rectangle SRCCOPY // raster operation code );
is 35000 and 38000 the value of the bitmap in pixels, or have you changed the mapping mode of the image. Because as far as I know, there is a limit of how large an image StretchBlt can handle. I can't remember the limit but it is closer to 2500 x 2500 pixels.
I would suggest breaking the large image into smaller squares. You will have to create a for loop, and just walk your way across the bitmap painting a small grid of squares one after another.
To test if this is what the problem is, try loading a smaller bitmap that is only 100x100 pixels or something and painting that.
|
|
|
|
|
Hi,
That numbers was just a test ( I was trying with some numbers then some others then... whatever... ).
Finally I decided instead of using directly the DC of the printer just use a metafile and that worked fine, If I have some time will write one little article telling how to print a resource bitmap, I thought I was going crazy with that little stuff !
Anyway thanks for your help, Bye !
Braulio
|
|
|
|
|
I've been a little bit worried for the last couple of months. I've heard many of my friends that says that they have bought a C# book and the author recomends to start learn C# in almost every book!
But I don't want to start a new language because I have been doing with C++ in two years now and it hasn't give me any kind of problems during my learning!
So I ask you gurus out there, DO I HAVE TO START LEARN C# IF I PLAN TO BE A WINDOWS PROGRAMMER IN THE FUTURE (I'm 17 years old)?
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
You don't have to worry about C++ dying. Continue to learn and gain experience in C++.
However I would also recommend learning as many other languages as you can because C++ is not always the best tool. There may be a time when C# will be a better tool for you to develop a certain project in.
|
|
|
|
|
Rickard Andersson wrote:
I've heard many of my friends that says that they have bought a C# book and the author recomends to start learn C# in almost every book!
Well, what do you expect people who write C# books to say ?
The main reason I am so cynical of C# is that I feel I'm providing balance for anyone stupid enough to thing C++ is anywhere near dead. I'm certain M$ will push us towards C#, but I'm willing to bet the following:
1/ C# will prove to be a worthwhile tool for a limited subset of programming problems.
2/ For anything that seeks to get maximum performance ( games, graphics, etc. ), C++ will remain the best choice for some time to come
3/ Regardless of the hold C# takes, some people will continue to develop C++ apps on Windows, even if C# becomes a viable choice for all apps. There are still places writing non-legacy code and not using MFC.
4/ No matter what happens you will be better off for knowing C++, and from what I have seen, C# is not terribly difficult for people who know C++. It misses out on all the things that people can find confusing in C++, like templates and pointers.
I'd suggest you'd probably be wise to learn yourself some C#, but stupid to abandon C++.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
Picture a world without war, without hate. And I can picture us attacking that world, because they would never expect it.
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
You are at an age in which you should try to learn as many languages as you can --including C# as well as C++, Java and more esoteric ones. A time will come when you'll find it harder or have less time to learn new stuff.
As for C++ being out of vogue for Windows programming when you start working (say in 5+ years), I don't think anyone will be able to give you a reliable prediction. Maybe some other language will go first place at GUI stuff, but when it comes to doing the hard job, my opinion is that C++ will be the best choice for a number of years to come.
So do not worry about dedicating yout time to learning C++, because it will be no wasted time, but keep an eye on every other language/technology around.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Rickard Andersson wrote:
a C# book and the author recomends to start learn C# in almost every book!
I'd be surprised to find a C# book where the author says, "C# sucks!"
You are only 17. You have so much time buddy. Learn C++/MFC/COM/C#/Managed C++....Learn them all.
When you finally get a job, these languages might have become extinct, but you will be fully ready for whatever the future has in hold for you
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
There will always be a need for C++ programmers. There are so many legacy projects out there that will exist for years and not be converted to C#. If C++ was going to die, Microsoft wouldn't have bothered with managed C++ extensions for .NET.
If you want to be a Windows programmer then C++ is the perfect place to start, if you want to be a web programmer then maybe C# is the way forward. Learn as many languages as you can and specialize in the one you like most.
Michael
|
|
|
|
|
Hi Rickard!
As a friend of the original writer and one of those guys who are spending a buck to buy a C# book, I felt a need to be a part of the discussion. The reason for me to buy my C# book and to start learn this new language was based on 2 factors.
1) MS have devoted 80 % of their development to the .NET(according to some book) and when microsoft spends that much cash into a new technology I thought it would be wize to listen. C# is the core language in visual studio 7.0 and I know C++ since before(but i suck on MFC unfortunatly).
2) Famous MFC authors like Jeff Prosise have said many good words about C# as the core language in the .Net framework sdk. I respect those guys alot. Even though you dont have to do or take their opinions to your heart, I did. Not just C# authors speak good of C# that is. And ofcourse, as in any other languages there is and will allways be ins and outs.
These are all but my humble opinions friends. I wish there was only one uni-programming language. A programming language suitable for any kind of programming. Easy to learn & easy to develop in. Yes I wish. But I also wish for world peace and for santa claus to really exist. Therefor, I guess you need a bunch of programming languages these days. C++ helped me understand other languages, and made it easy to learn PHP(which btw is an excellent alternative to Asp and therefor not microsoft dependant), and I will continue to learn C++. But I will study other languages too.
With regards !
Johan ranestal
|
|
|
|
|
i need to read numbers from a Textfile and store them in a linked list
so how do i read in from a file ?
please
|
|
|
|
|
You can use CStdioFile
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Not a personal comment, but why do people always recommend MFC classes to do things that can be done using standard components ? I think it's better to learn stuff that is there no matter what you're doing in C++ ( and I mean ATL/MFC.Win32 more so than differing platforms ).
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
Picture a world without war, without hate. And I can picture us attacking that world, because they would never expect it.
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
CG
My thinking is that when someone asks a question on how to read a text file, he must be looking for the easiest solution, otherwise he would not ask a question about reading a text file, which would be something covered in every C++ book ever written. And the MFC classes are the easiest way to read a file unless you want to use VB or Delphi.
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Nish [BusterBoy] wrote:
otherwise he would not ask a question about reading a text file, which would be something covered in every C++ book ever written.
This does not follow - how many 'in every book and easy to find in MSDN' questions do we answer here ?
Personally I find the IOStreams method I posted as easy and elegant as it gets, but I'm a one eyed fan of anything that's standard.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
Picture a world without war, without hate. And I can picture us attacking that world, because they would never expect it.
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Christian Graus wrote:
Personally I find the IOStreams method I posted as easy and elegant as it gets, but I'm a one eyed fan of anything that's standard.
To be honest, all that STL scared me. I couldnt make head or tail of the code you posted to the poor fella who only wanted to open a text file and read in a few numbers.
Am the only one here who does not understand or use STL?
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Nish [BusterBoy] wrote:
To be honest, all that STL scared me
I admit I felt the same when I started using it. But then, I felt that way about MFC as well....
Nish [BusterBoy] wrote:
Am the only one here who does not understand or use STL?
Sadly, I'd say you're in the majority. STL is SO much nicer than MFC container classes, but people are put off by the unfamiliar syntax and seem just to avoid learning it.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
Picture a world without war, without hate. And I can picture us attacking that world, because they would never expect it.
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Let me walk you through how easy it is:
string currentLine;
The above line is irrelevant, it's left over from a line by line method I played with.
ifstream str("c:\\winzip.log");
if (!str.is_open())
{
cout << "It's stuffed\n";
return -1;
}
The above just opens a file and checks if it's OK.
vector<string> file_contents;
This defines a vector ( an array ) of strings.
copy(istream_iterator<string>(str),istream_iterator<string>(), back_inserter(file_contents));
This is the magic - the first argument means to iterate through the file a string at a time ( i.e. it does not expect only numbers, but any valid characters ), the second tells it to keep looking until the end of the file ( the return of the default constructor is the eof, back_inserter tells it to add the result to the end of the container specified, and the container to be copied into is our array.
// Now print out the results
copy(file_contents.begin(), file_contents.end(), ostream_iterator<string>(cout, "\n"));
This simply copies the entire array to the ouput stream. Pretty sweet, don't you think ? How else could you print an entire array, or read an entire file into an array, with one line of code ?
It's the algorithms that plug into the STL containers that make it light years ahead of MFC containers.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
Picture a world without war, without hate. And I can picture us attacking that world, because they would never expect it.
<Center><A href = "http://www.sonork.com" target = "_Blank">Sonork</A> ID 100.10002:MeanManOz</Center><Center>I live in <U><B>Bob's HungOut</B></U> now</center>
|
|
|
|
|
Now that you have explained it, it sounds good.
I mean you can do so much with so little code.
Hmmmm. Maybe if I ever survive my COM learning attempts I might try out some simple STL too
Thanks CG
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Nish [BusterBoy] wrote:
I might try out some simple STL too
Join us... don't be afraid....
Seriously, it's not hard once you get into it, I spent a lot more time trying to fathom out COM than I did STL. And obviously I'll be here to help if you get stuck..
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
Picture a world without war, without hate. And I can picture us attacking that world, because they would never expect it.
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Christian Graus wrote:
Join us... don't be afraid....
LOL
That sounds like right out of a thriller movie.
You are a revolutionary leader. I am the cool hero confused as to whether I should continue being a handsome playboy screwing french women or whether I should join the revolution. Finally I give in and we take over the solar system. You are made king and I become a count [you give me one of the jovian moons] and marry a beautiful princess born and brought up in Mars and live happily ever after
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Nish [BusterBoy] wrote:
Christian Graus wrote:
Join us... don't be afraid....
LOL
That sounds like right out of a thriller movie.
Actually I'm quoting Dilbert, the pointy haired boss to be exact. But yours sounds like more fun....
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
Picture a world without war, without hate. And I can picture us attacking that world, because they would never expect it.
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
First of all, please only ask the one question once.
Secondly, the following code should work, assuming the numbers are properly delimited. It currently reads in strings, but you can use atoi, or convert it to read int's, I am sure.
This program is my playground for using IOStreams, so I sure there are #include and using std:: statements in there that are not needed.
<pre>
#include "stdafx.h"
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <iostream>
#include <sstream>
using std::copy;
using std::vector;
using std::string;
using std::ifstream;
using std::ostream_iterator;
using std::cout;
using std::back_inserter;
using std::getline;
using std::ostringstream;
using std::istream_iterator;
int main(int argc, char* argv[])
{
string currentLine;
ifstream str("c:\\winzip.log");
if (!str.is_open())
{
cout << "It's stuffed\n";
return -1;
}
vector<string> file_contents;
copy(istream_iterator<string>(str),istream_iterator<string>(), back_inserter(file_contents));
// Now print out the results
copy(file_contents.begin(), file_contents.end(), ostream_iterator<string>(cout, "\n"));
return 0;
}
</pre>
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
Picture a world without war, without hate. And I can picture us attacking that world, because they would never expect it.
<Center><A href = "http://www.sonork.com" target = "_Blank">Sonork</A> ID 100.10002:MeanManOz</Center><Center>I live in <U><B>Bob's HungOut</B></U> now</center>
|
|
|
|
|
Nice. By the simplicity of the original post (he didn't ask how to find 4000-digit primes in constant time), I would have guessed they were asking for the simple fopen(), fgets(), etc.
But this is a nice solution. Prolly waaaaay over the poster's head.
J
|
|
|
|
|