|
Russell
|
|
|
|
|
Hi,
In my applications images are displayed (and for example rotated) with the help of GDI+. I store the image (there is only 1 displayed ) like this:
Gdiplus::Image * m_image;
I draw it on the screen with this line:
graphics.DrawImage(m_image, x, y, size_x, size_y);
Now i wanted to zoom in and out of the picture with the help of a Slider Control. From 100% to 1600% (1x - 16x). I tried it in different ways but none had worked. Sometimes I don't see any change of the image on the screen at all and sometimes the application crashes.
Isn't that the correct way?:
Graphics * graphics = Graphics::FromImage(m_image);
graphics->ScaleTransform(3.0f, 1.0f);
Any ideas?
Thx, Shi
|
|
|
|
|
TheShihan wrote: Graphics::FromImage(m_image);
the above function might have returned 0. thats why the graphics->ScaleTransform() is giving exception.
|
|
|
|
|
How can I check the returnvalue from this function? I mean I cannot do this:
int = Graphics * graphics = Graphics::FromImage(m_image);
or do you mean NULL? I tryed to check it this way:
if(graphics != NULL) <br />
{<br />
MessageBox("OK")<br />
}<br />
else <br />
{<br />
MessageBox("Not OK")<br />
}
Gave me also errors... sorry I'm really a beginner.
Shi
|
|
|
|
|
TheShihan wrote: or do you mean NULL?
null and 0 are all the same
TheShihan wrote: if(graphics != NULL)
{
MessageBox("OK")
}
else
{
MessageBox("Not OK")
}
So which message box u got?
|
|
|
|
|
TheShihan wrote: or do you mean NULL?
Note - some developers get hung up on the fact that NULL , NUL and zero all have the same value, completely ignoring that the meanings may be different depending on context.
For an extreme example of this mistake, see the "NUL is not NULL...! " post on my profile's page.
So yes, as far as you are concerned, the poster meant NULL .
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Hi All,
I have created an application in which i can change the font attributes of a text. I am using CFontDialog to select font size, font family etc
Before calling CFontDialog (while debugging)
m_TextFont.m_cf.iPointSize is 140. (Font Size is 14).
But when Font dialog is popped it is showing Font Size as 17.
What may be the problem?
|
|
|
|
|
Care to share a code snippet with us?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I would hazard a guess to say that it is to do with how Windows maps fonts. In the LOGFONT structure, for example, it needs a *negative* value to get the full character height - a positive value gives a slightly different size as it doesn't check against the full character cell height.
Now, this doesn't necessarily mean it's true in your case.
I think we are going to need to see some sample code and / or an explanation of what you do as a user with the font dialogue in between examining those values - for example, do you simply cancel it, or do you choose something?
|
|
|
|
|
CFontDialog* m_TextFont = new CFontDialog(&lfFontAttr, CF_BOTH | CF_TTONLY | CF_INITTOLOGFONTSTRUCT);
lfFontAttr is LOGFONT structure.
m_TextFont->GetCurrentFont(&lfFontAttr);
Here m_TextFont->m_cf.iPointSize is 140 (i got the value while debugging)
if (m_TextFont->DoModal() == IDOK)
{
m_TextFont->GetCurrentFont(&lfFontAttr);
-------
}
Font size 17 is shown in dialog.
|
|
|
|
|
My hunch was strangely accurate. If you look at the constructor for CFontDialog in MSDN, it has a sample (reproduced below) that sets a negative value (the pixel height) into lfHeight, not 1/10ths of a point as you have:
// Show the font dialog with 12 point "Times New Roman" as the
// selected font.
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
CClientDC dc(this);
lf.lfHeight = -MulDiv(12, dc.GetDeviceCaps(LOGPIXELSY), 72);
strcpy(lf.lfFaceName, "Times New Roman");
CFontDialog dlg(&lf);
dlg.DoModal();
I believe this to be the source of the problem.
|
|
|
|
|
Hello to everyone interested!
I am willing to write an application for my Pocket PC which should use the (built in) Bluetooth to 'upload' a .txt or .xml file. If it's possible, I'd like to do that with minimal user intervention on the PC.
Just turn on Bluetooth ports on both devices, select 'upload file' on PPC and the PC to accept it.
If you have any idea about this, any article related to my problem or something to start with, I'd be deeply thankful!
Best wishes!
if someone would like to contact me, here is my email: shpid3r@yahoo.com
|
|
|
|
|
This[^] must help you.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->ßRÅhmmÃ<-·´¯`·.
|
|
|
|
|
Hi, I am reading in a line from a .dat file using fgets. The line is an unknown number of variables written in scientific notation (4.20000e+00 1.00000e-01 1.177000e+00 0.000000e+00 ...). The first two are an x and y location and will always be there. Due to the number of these lines to read in, minimum is 500000, I don't want to use char/string as each number will take about double the memory of a float. Using sscanf with a large amount of %f I can find the number of variables (there may be up to 30).
int number = sscanf(data_in,"%f%f%f%f%f%f%f%f%f%f%f...",&temp[0],&temp[1],...,&temp[n]);
With number I can create a string with the correct number of '%f' and set the array to the correct length.
At the moment I use a full array of 30 with the correct number of %f. Knowing how many variables there are I can pull only the valid elements from the array.
I am stuck on how to set the number of references '&temp[n]', to match the number of %f in the format string.
Any ideas on how to set everything equal lengths would be greatly appreciated.
Jim
this thing looks like it was written by an epileptic ferret
Dave Kreskowiak
|
|
|
|
|
jimwawar wrote: I am stuck on how to set the number of references '&temp[n]', to match the number of %f in the format string.
How about
std::vector<double> numbers;
std::stringstream str;
str <<< data_in;
for ( unsigned i = 0; i < number_count; ++i) {
double d;
str >> d;
numbers.push_back( d);
}
You will end up with number_count doubles in the vector numbers .
You will need to improve the error checking, and you might want to use iterators here, if you feel fit.
Also, boost::lexical_cast[^] could be used to make this more programmer-friendly.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
Thanks for the help.
Jim
this thing looks like it was written by an epileptic ferret
Dave Kreskowiak
|
|
|
|
|
What about using a loop?
int max = 30;
for( int n = 0; n < max; n++ )
{
sscanf( data_in, "%f", &temp[n] );
}
- NS -
|
|
|
|
|
Thanks for the help.
Jim
this thing looks like it was written by an epileptic ferret
Dave Kreskowiak
|
|
|
|
|
Welcome...
- NS -
|
|
|
|
|
CFile::GetStatus(filePath, fStatus) works fine with local files, but does NOT work with remote shared files when accessed by UNC.
Any ideas on how to access/read/write remote files from MFC C++ apps would be greatly appreciated?
Thanks in advance.
|
|
|
|
|
insignia wrote: CFile::GetStatus(filePath, fStatus) works fine with local files, but does NOT work with remote shared files when accessed by UNC.
Unless I misunderstood your question, this works fine for me:
CFileStatus stat;
CFile::GetStatus(_T("\\\\machine\\share\\boot.ini"), stat);
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello All,
i am preparing a application in which i am using multiple group box which having multiple radio buttons and check boxes.
i want to use a group box of multiple radio button as a single control so i
please share your knowledge.
thanks
|
|
|
|
|
Put the tab order in the sequence.( to see the tab order take the dialog in the resource and press ctrl + D ).
|
|
|
|
|
...and start every group of button with the group property.
Tip: in resource view use Ctrl+T and Ctrl+D and look and click (to sort) :->
Greetings from Germany
|
|
|
|
|
As long as you put them in the proper z-order and use the WS_GROUP style correctly, this is how they are supposed to behave.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|