|
ever heard of a firewall!?
Don't try it, just do it!
|
|
|
|
|
i wish to know how to draw pixel by pixel onto a view, i am not loading any bitmap but want to create one during coding and view it in SDI. Can anyone help?
|
|
|
|
|
You wouldn't want to try drawing each pixel one-by-one onto the screen. Instead, try creating a DibSection and editing its bits, then BitBlt'ing it onto the view.
See the CreateDibSection[^] function.
"It is appallingly obvious that our technology exceeds our humanity." - Albert Einstein
FLUID UI Toolkit
|
|
|
|
|
If you truly want to set an individual pixel's color, you can use CDC's SetPixel method:
<big>CDC::SetPixel </big>
COLORREF SetPixel( int x, int y, COLORREF crColor );
COLORREF SetPixel( POINT point, COLORREF crColor );
Return Value
An RGB value for the color that the point is actually painted. This value can be different
from that specified by crColor if an approximation of that color is used. If the function
fails (if the point is outside the clipping region), the return value is -1.
Parameters
x
Specifies the logical x-coordinate of the point to be set.
y
Specifies the logical y-coordinate of the point to be set.
crColor
Specifies the color used to paint the point.
point
Specifies the logical x- and y-coordinates of the point to be set. You can pass either a
POINT structure or a CPoint object for this parameter.
Remarks
Sets the pixel at the point specified to the closest approximation of the color specified by
crColor. The point must be in the clipping region. If the point is not in the clipping region,
the function does nothing.
Not all devices support the SetPixel function. To determine whether a device supports SetPixel,
call the GetDeviceCaps member function with the RASTERCAPS index and check the return value
for the RC_BITBLT flag.
|
|
|
|
|
Hello, everyone!
How to use C (not C++) to check whether a character buffer (char*) contains a double or float number? I want to know how to check it with standard C (not C++) method and not VC++ specific method.
For example,
----------
char buf1 [5] = "123.4";
char buf2 [5] = "123.m";
----------
What the result I want to get is, when I input buf1, I can get TRUE and when I input buf2, I can get FALSE.
I find the function atof is not working properly.
Thanks in advance,
Geo
|
|
|
|
|
TCHAR * end = NULL;
double x = strtod(buf, &end);
// end points to the character that stopped the scan - this should be the 0 term
if (*end != '\0' || !_finite(x))
{
// not a valid number
}
"Vierteile den, der sie Hure schimpft mit einem türkischen Säbel."
sighist | Agile Programming | doxygen
|
|
|
|
|
#include <stdio.h>
#include <stdlib.h>
Thanks, peterchen buddy!
I found your code is not working properly, Here is a piece of sample code, which should return 0, but it returns 1 instead.
Source Code:
--------
int main (int argc, char** argv)
{
char* end = NULL;
char buf [5] = "123.4";
double x = strtod (buf, &end);
if ((*end != '\0') || (!finite (x)))
{
// not valid
return 1;
}
//valid
return 0;
}
--------
Is there something wrong?
regards,
Geo
|
|
|
|
|
Try replacing char buf [5] = "123.4"; by
char *buf = "123.4";
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
char* and char[] are the same according to Bjarne Stroustrup.
Thank You
Bo Hunter
|
|
|
|
|
Thanks, Bo buddy!
But I find his method is really working, when change char[] to char*. But I do not understand the reason. Can you tell me why?
regards,
Geo
|
|
|
|
|
Bo Hunter wrote:
char* and char[] are the same according to Bjarne Stroustrup.
Thats correct! But char[5] is something different!
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
Thanks, Dominik buddy!
Now I have understood the problem.
Geo
|
|
|
|
|
Thanks, Dominik buddy!
I find your method is working. But I do not understand the reason, can you tell me why?
regards,
Geo
|
|
|
|
|
char[5]="..." simply isn't correct C. You can either use char[] or char*.
Even if it would be correct C, char[5]="123.4" would possibly result in a memory read violation because you allocate 5 characters and put 5 characters in it, but where do you put the ending NULL character? So, this causes a read violation, because the strtod function cannot find the NULL character.
I wonder why your compiler accepted char[5]="...". My compiler doesn't compile this.
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
Thanks, Dominik buddy!
How silly I am.
Geo
|
|
|
|
|
What's the difference between C's printf and C++'s cout?
I have heard that C does not support String, so is it
much difficult to output data in C than in C++?
|
|
|
|
|
printf is not typesafe or extensible, whereas cout is. This means that C++ output is easier to get right (once you get over the odd syntax), and the output of complex objects can be deferred into those objects, thus improving encapsulation. However, printf can be handy for quick apps, and most programmers seem to prefer "format string" based IO (such as printf) to "stream oriented" IO (such as cout). Hence why everyone uses sprintf to construct strings, even though stringstream objects are safer
--
Ian Darling
"The moral of the story is that with a contrived example, you can prove anything." - Joel Spolsky
|
|
|
|
|
Added to that, positional format strings, as supported by Windows' FormatMessage (and .NET's String.Format ) are easier to translate for localized versions of the software.
cout doesn't have an answer to this.
I'll admit that since I mostly write C++ software for Pocket PCs, I don't often have the chance to use the C++ runtime library, because most of it's missing.
|
|
|
|
|
|
Ian Darling wrote:
Hence why everyone uses sprintf to construct strings, even though stringstream objects are safer
sprintf is convenient but we really ought to shun it for the reason you say. In the past I've run into nasty memory bugs in maintenance because of developers' fondness for sprintf.
Kevin
|
|
|
|
|
Guys,
I have noticed - CHtmlView sometimes does not process correctly if form does not have submit button, Enter key does not submit.
This form will work perfectly - submit on Enter key:
<br />
<form name="myform" onSubmit="return cmd();" ><br />
<input type="text" class="form-say" name="say"><br />
<input type="submit" class="form-say" name="say" ><br />
</form>
And this one will just ignore Enter key (but in IE works fine):
<br />
<form name="myform" onSubmit="return cmd();" ><br />
<input type="text" class="form-say" name="say" ><br />
</form>
Do you know the way to work around it?
Thanks
PS - I'm using MFC with good old VC++ 6.0 . Maybe is it fixed in newer versions ?
|
|
|
|
|
Maybe some JavaScript that does the Submit, or a hidden Submit button, assuming that is possible.
PS. I don't thing this is a CHtmlView issue.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Neville Franks wrote:
Maybe some JavaScript that does the Submit, or a hidden Submit button, assuming that is possible.
PS. I don't thing this is a CHtmlView issue.
The problem is - I'm writing multy-window browser, so I have to process pages "as is", and this particular example - part of IRC:CGI, so I have to work with "submit-less" forms correctly.
I believe it is CHtmlView issue (not mine), because I've created simple Document/View CHtmlView-based project by wizard, and opened test "submit-less" page without any code modification - same result - it does not sumbit.
|
|
|
|
|
trof wrote:
I believe it is CHtmlView issue (not mine), because I've created simple Document/View CHtmlView-based project by wizard, and opened test "submit-less" page without any code modification - same result - it does not sumbit.
This doesn't surprise me. Why not modify the HTML after it is loaded. ie. in xxx::OnDocumentComplete().
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Hi to all. I'm trying to programm Macromedia's Flash ocx under Visual C++. It is known that this control cannot support transparent background. But there are in the market third party programms that enable transparency in the control. Can give me a help how to make transparent the background of the control?
Thank's bros.
|
|
|
|