|
Greets all,
I have an app that loads a monochrome bitmap and displays it in a Static Control where I later allow the user to resize the bitmap by dragging the edges of a rectangular selection box around the bitmap.
Now what I want to do is to save this newly sized bitmap to file. I have tried and so far when I write the bitmap to file and later view it all I am seeing is a blank image (i.e. all white).
I think the problem lies in my call to the GetDIBits() function. in the MSDN docs, it says that I have to make sure the bitmap is not currently selected into a device context.
So my question is, how do I unselect the Bitmap from a Device Context??
.:. Keno .:.
|
|
|
|
|
Re-select the default one.
old bitmap = dc.SelectObject(new bitmap)
dc.DoSomeStuff()
dc.SelectObject(old bitmap)
--
Dad, how strange it is that the pig can speak. *thoughtful pause* It must have lost its "oink". (my 3-year old daughter Moa, while watching Babe)
Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. (Douglas Adams)
|
|
|
|
|
Hello,
I've encountered a strange behaviour of a toolbar (using CToolBar). I add programatically buttons to it from a modal dialog. The strange part is, that when I call RecalcLayout, the toolbar resizes (adds the buttons) but does not display correctly the associated bitmaps and does not manage their state immediatelly. If i manually flow or dock the toolbar, I get the command handling (i.e. the bitmaps appear correctly, and the buttons are clickable and not disabled). If I don't manually dock or flow the toolbar, I get only a resized toolbar without any bitmaps and with disabled buttons. My question here is, what am I missing, and what am I doing wrong.
Greetings,
Deian
|
|
|
|
|
i'm a bit of c++ newbie... using VS .NET compiler
for this little prgram i'm working on, has to find the area and perimeter of a circle, triangle, or a square depending on user's choice.The choices are included in a menu. This menu should also include a way of exiting the program. The input will depend on the choice selected and i have to make sure that users will not enter a choice that is not listed in the menu. Also, make sure no negative or zero values are entered
i'm not done with all the aspects of this program, but below is what i have. program is it runs with no errors, but any time i enter a number for radius, base, height, or side value, it passes the value as 13 and does all the calculations using 13.
Can any one give me a clue where i'm messin up at???
<br />
#include "stdafx.h"<br />
#using <mscorlib.dll><br />
#include <conio.h><br />
using namespace System;<br />
<br />
void calcCircle(double);<br />
void calcTriangle(double, double, double);<br />
void calcSquare(double);<br />
<br />
int main()<br />
{<br />
double circle_radius = 0.0;<br />
double tri_base = 0.0;<br />
double tri_height = 0.0;<br />
double tri_side = 0.0;<br />
double square_base = 0.0;<br />
int figures = 0;<br />
<br />
Console::Write("Choose a geometric figure: \n");<br />
Console::Write("1. Circle\n");<br />
Console::Write("2. Triangle\n");<br />
Console::Write("3. Square\n");<br />
Console::WriteLine("4. Exit");<br />
figures = Console::Read();<br />
<br />
switch (figures)<br />
{<br />
case '1': Console::WriteLine("Enter Radius: ");<br />
circle_radius = Console::Read();<br />
getch();<br />
calcCircle(circle_radius);<br />
break;<br />
case '2': Console::WriteLine("Enter Base: ");<br />
tri_base = Convert::ToDouble(Console::Read());<br />
if (tri_base > 0)<br />
Console::WriteLine(tri_base);<br />
else<br />
Console::WriteLine("Wrong Value");<br />
Console::Write("Enter Height: ");<br />
tri_height = Convert::ToDouble(Console::Read());<br />
Console::Write("Enter A Non-base side: ");<br />
tri_side = Convert::ToDouble(Console::Read());<br />
getch();<br />
calcTriangle(tri_base, tri_height, tri_side);<br />
break;<br />
case '3': Console::Write("Enter A Side: ");<br />
square_base = Convert::ToDouble(Console::Read());<br />
getch();<br />
calcSquare(square_base);<br />
break;<br />
case '4':;<br />
break;<br />
default: Console::WriteLine("Wrong Choice. Please Select A Right One");<br />
}<br />
getch();<br />
return 0;<br />
}<br />
<br />
void calcCircle(double radius)<br />
{<br />
double circle_area = 0.0;<br />
double circle_peri = 0.0;<br />
circle_area = 3.14159265 * Math::Pow(radius,2);<br />
circle_peri = 2.0 * 3.14159265 * radius;<br />
Console::WriteLine("Radius: {0}", Convert::ToString(radius));<br />
Console::WriteLine("Area: {0}", Convert::ToString(circle_area));<br />
Console::WriteLine("Perimeter: {0}", Convert::ToString(circle_peri));<br />
getch();<br />
}<br />
<br />
void calcTriangle(double base, double height, double side)<br />
{<br />
double tri_area = 0.0;<br />
double tri_peri = 0.0;<br />
tri_area = base * height / 2.0;<br />
tri_peri = base + side + side;<br />
Console::WriteLine("Area: {0}", Convert::ToString(tri_area));<br />
Console::WriteLine("Perimeter: {0}", Convert::ToString(tri_peri));<br />
getch();<br />
}<br />
<br />
void calcSquare(double sq_base)<br />
{<br />
double square_area = 0.0;<br />
double square_peri = 0.0;<br />
square_area = Math::Pow(sq_base,2);<br />
square_peri = 4.0 * sq_base;<br />
Console::WriteLine("Area: {0}", Convert::ToString(square_area));<br />
Console::WriteLine("Perimeter: {0}", Convert::ToString(square_peri));<br />
getch();<br />
}<br />
|
|
|
|
|
[rant]
This is what comes from using NON-STANDARD code.
Don't post homework
RTFM - Console::Read returns the next character from the input stream
[/rant]
#include <iostream>
#include <string>
using namespace std;
const double PI = 3.14159265;
void calcCircle(double r)
{
cout << "Radius: " << r << endl;
cout << "Area: " << PI * r * r << endl;
cout << "Perim: " << 2 * PI * r << endl;
}
void calcTriangle(double b, double h, double s)
{
cout << "Area: " << 0.5 * b * h << endl;
cout << "Perim: " << b * 2 * s << endl;
}
void calcSquare(double x)
{
cout << "Area: " << x*x << endl;
cout << "Perim: " << 4*x << endl;
}
int main()
{
cout << "1 triangle" << endl;
cout << "2 square" << endl;
cout << "3 circle" << endl;
int menuSelection;
cin >> menuSelection;
switch(menuSelection)
{
case 1:
{
double b,h,s;
cout << "Enter Base: ";
cin >> b;
cout << "Enter Height: ";
cin >> h;
cout << "Enter Side: ";
cin >> s;
calcTriangle(b,h,s);
break;
}
case 2:
{
double r;
cout << "Enter Radius: ";
cin >> r;
calcCircle(r);
break;
}
case 3:
{
double x;
cout << "Enter Side: ";
cin >> x;
calcSquare(x);
break;
}
default:
cout << "Invalid" << endl;
}
return 0;
}
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
(This may be a General Discussion question, but I know this forums gets more traffic. Sorry.)
Has anyone experienced corruption of .ico files when uploading them to a CVS server? I added them to the tree as binary files, but when I get the updated icons on a different machine, I get a modified file back that causes a RC2176[^] error when compiling. Any ideas?
|
|
|
|
|
Line ending translation? It's possible that your icon has some bytes with decimal 10 which are having decimal 13 added before it (i.e. converting LF to CR-LF) or vice versa.
If your source control tool has options to convert line endings, set it to None for this file.
|
|
|
|
|
Thanks, Mike, I'll give it a shot.
|
|
|
|
|
Heloo,
does anyone know what to put in the next instruction to stay the picture fixed in the text?
oShapes.AddPicture("c:\\FOTO.jpg", vtFalse, vtTrue, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional);
Thanks.
Sebas
|
|
|
|
|
Hiya can someone tell me where I can get a free copy of Unix OS to mess around with my c++ programs??
Thanks.
|
|
|
|
|
|
Linux has been mentioned. Somewhat different but if you want to work in Windows, Microsoft now gives Services for Unix away free. It is a unix-like subsystem that runs under Windows.
|
|
|
|
|
|
Ok confused now. Is Linux a part of Unix or separate product?? I really wanted to learn Unix not Linux, and be able to run my c++ programs on unix.
This is basically the story. I want to learn Unix and its commands. When I say learn, I want a basic understanding of it and its commands.
How can I do this on my XP OS pc?? If I do a dual-boot system, does the other OS have to be on a completely separate drive??
What is the simpliest way to do this??
|
|
|
|
|
I have a problem. I have a project that include three form. I added an external header file (for example ****.h) in my project. When I add a picture box on one of the forms and select a picture for picture box, the compiler gives me an error "GetObjectA is not a member of System::ResourceManager::Resources" ( I think the error number is C2039 but I am not certain). I can't control this.
Please help me at least time.
turkish
|
|
|
|
|
Managed C++, #using and Windows header macros don't mix too well. The file you've included has redefined GetObject to GetObjectA, so when you try to use Resources::GetObject , the preprocessor rewrites GetObject to GetObjectA, which doesn't exist.
The preprocessor is basically dumb.
The culprit appears to be WinGDI.h, which is included from Windows.h. It may seem odd to have two different entry points for GetObject, since it doesn't take any string parameters, but this controls whether calling GetObject on a font object handle returns a LOGFONTA or a LOGFONTW (and hence whether the lfFaceName string is ANSI or Unicode).
About all you can do is find the call to Resources::GetObject, and either ensure that it occurs before WinGDI.h is included (not practical) or use #undef to undefine GetObject.
|
|
|
|
|
I am writing an MFC application. When I try to make a value variable and a control variable for the same edit box, they conflict with each other and neither one of them works. Is there a way around this such that I can have the two variables for the same edit box? Any help is appreciated.
-Dev578
|
|
|
|
|
|
Possible or not but i guess two member variables for one control doesnt sound good, you can even do away with the control member variable by using GetDlgItem(..)
"When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)
|
|
|
|
|
Mr.Prakash wrote:
you can even do away with the control member variable by using GetDlgItem(..)
In fact, the control variables were introduced to hide the ugly and error prone GetDlgItem with its Long and capitalized resource name.
Repent, and return to the true path of usiing control variables
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
jhwurmbach wrote:
, the control variables were introduced to hide the ugly and error prone GetDlgItem
humm, never had any problem with it, but i agreee that GetDlgItem can not be always.
But i will certainly disagree to 2 member variables for a control.
"When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)
|
|
|
|
|
Mr.Prakash wrote:
But i will certainly disagree to 2 member variables for a control.
I often use one menber of type CString and one of type CEdit for one control. As the CString gets filled by the utterly crappy DDX-mechanism of MFC, I tend not to rely on it.
For every more complicated dialog behaviour, you need to code by hand using the control variables anyway.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
Dev578 wrote:
Is there a way around this such that I can have the two variables for the same edit box?
Yes. The two variables must either be of a different category (i.e., value control), or you have to bypass ClassWizard and add the second one manually.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Hi!
I just need to get the size of a file. The file is given by path (i.e: 'c:\thefile.txt'). I've been dealing with this for days, but I always bump into troubles.
May I ask someone to write me a very simple function, which queries the size of a file. That would show me how to get the size, and then I'd know what am I doing wrong. @win32/vc++ 6.0
Thx in forward.
|
|
|
|
|
The first arguments should be:
const char *path - the routine shouldn't be modifying the text.
const CString &path - Same thing again but also avoids an extra copy constructor.
const std::string &path - Same thing as with const CString &path.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|