|
Flicker Free Drawing In MFC[^]
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Check out
http://www.codeproject.com/bitmap/bitmapdc.asp?target=cbitmapdc&df=100&forumid=160&select=49439#xx49439xx
It works great for a the applications I've been working on.
|
|
|
|
|
Is there any function which returns number of decimals in the integer,
or can sombody help me with fast algorithm to do this. thanks
|
|
|
|
|
int digits = log10(integer) + 1; Only works with positive numbers.
HTH
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
pepevejlupek wrote:
Is there any function which returns number of decimals in the integer
Trick questions should probably be directed to the lounge.
The number of decimals in an integer is always zero.
|
|
|
|
|
Subtle, dude .
Software Zen: delete this;
|
|
|
|
|
int CountDigits(int value)
{
int digit_count = 0;
do {
digit_count++;
value /= 10;
} while (value != 0) {
return digit_count;
}
or, even faster:
int CountDigitsFaster(int value)
{
int digit_count = 1;
if (value < 0) value = -value;
if (value > 9) digit_count++;
if (value > 99) digit_count++;
if (value > 999) digit_count++;
if (value > 9999) digit_count++;
if (value > 99999) digit_count++;
if (value > 999999) digit_count++;
if (value > 9999999) digit_count++;
if (value > 99999999) digit_count++;
if (value > 999999999) digit_count++;
return digit_count;
}
Note that CountDigitsFaster assumes that int 's are 32-bit signed values. Both functions assume that the minus sign in negative values is not considered a 'digit'. If you're actually trying to compute the number of characters required to display the value, then you would have to take that into account as well. CountDigitsFaster looks like dumb code, but is significantly faster than any alternative I can think of. It requires 10 compares, 10 jumps, possibly a negation, and up to 9 increments. My original CountDigits , while it may exit with an early out for small values, requires an increment and a division per iteration, for up to 9 iterations.
Software Zen: delete this;
|
|
|
|
|
I would like to see examples in VC6 about performance counter ( creating new performance counter)
Thanks
Luis Ricardo
|
|
|
|
|
|
|
The link u hv provided is not working. Do u know any other links?
|
|
|
|
|
MFC Print Preview - help urgently
Helpp!!! I printed a few pages using CView::OnDraw override, hence, did not take into consideration the current page being printed. So the problem is that I do not print taking into consideration the current page being printed. As a result, the output gets slower when the data to be printed increases and even overlapped. Please Help!!!!
|
|
|
|
|
Hello,
how can I open another FormView in a MDI-Appl. from a FormView ? Not from the Main-Menu !
Example:
There is a Button in CFormView1. With this Button, I
want to open/create the CFormView2. How can I do that ?
Is there a axample application/source?
Thanks, jr
|
|
|
|
|
// Get the correct document template
CDocTemplate* pDocTemplate;
POSITION pos = pApp->GetFirstDocTemplatePosition();
pDocTemplate = pApp->GetNextDocTemplate(pos);
ASSERT(pDocTemplate);
// Create the new frame
CFrameWnd* pNewFrame = pDocTemplate->CreateNewFrame(GetDocument(),
(CFrameWnd*)AfxGetMainWnd());
ASSERT(pNewFrame);
// Activate the frame and set its active view
pDocTemplate->InitialUpdateFrame(pNewFrame, NULL);
|
|
|
|
|
How can I open the CFormView2 , which have no Doc-Class ?
Thanks, jr
|
|
|
|
|
I'm making a program where i need the hWnd of the control that is currently under the cursor, but i'm in doubt of which API's i should use. I've tried checking around but i can't seem to find the answer.
Thanks in advance
|
|
|
|
|
WindowFromPoint() or possibly ChildWindowFromPoint()
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
You might want search MSDN there is an old sample program on using DIBs. What the program does is allow you to move the cursor over a window a capture it to a DIB. If you search for a screen/windows capture program here or on the web you should be able to find additional examples.
Trust in the code Luke. Yea right!
|
|
|
|
|
Why does the colour black get displayed transparently in a CListCtrl given an associated imagelist.
How do I preserve the black colour .. ?
Thanks in advance.
|
|
|
|
|
Depending upon how you create the image list, the color black can be used as a mask value. Pixels in the bitmaps that are the mask color are displayed as transparent.
The easiest way to handle transparency with an image list is to use icons, rather than ordinary bitmaps.
Software Zen: delete this;
|
|
|
|
|
Thanks Gary for the reply.
So, how do I specify a different mask colour other than black so that the black can be preserved.
The imagelist that I am using works just fine with the rest of the application and yes it is constructed from a bitmap.
Thanks.
|
|
|
|
|
What I do is color the "Transparent" part of the bitmap to a purple/pinkish color and set the mask to that color.. like this..
CImageList imageList;
CBitmap bitmap;
bitmap.LoadBitmap(IDB_TOOLBAR);
imageList.Create(26, 26, ILC_COLORDDB|ILC_MASK, 0, 0);
imageList.Add(&bitmap, RGB(255,0,255)); // PURPLE COLOR
Rob..
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Thanks for the reply.
Thanks for the suggestion, but my problem does not involve transparent areas of the source bitmap but the default drawing of any black pixels transparently.
I already have an Imagelist defined for use in the application and I use a temporary DC to draw to prior to using the TransparentBlt function for transparent rendering.
My question is how do I honour the black pixels in the bitmaps when providing an ImageList for a CListCtrl using the .SetImageList function. When the images are displayed in the list, the black pixels are rendered transparently.
How do I prevent or circumvent this ?
Thanks in advance.
|
|
|
|
|
If you choose another color as the mask color (purple = RGB(255,0,255) in the example earlier in the thread), then that color is treated as transparent, and black is just another color in the bitmap. This is the standard behavior regarding the list control and imagelists.
You mentioned using TransparentBlt . From the MSDN:
BOOL TransparentBlt(
HDC hdcDest,
int nXOriginDest,
int nYOriginDest,
int nWidthDest,
int hHeightDest,
HDC hdcSrc,
int nXOriginSrc,
int nYOriginSrc,
int nWidthSrc,
int nHeightSrc,
UINT crTransparent
);
<listing>Parameters
...
crTransparent
[in] The RGB color in the source bitmap to treat as transparent.</listing>
In this case, you would need to pass cdTransparent as whatever color you were using as the transparency color (again, RGB(255,0,255) from the example).
Software Zen: delete this;
|
|
|
|
|
Thats great, now I understand.
Thanks very much for the help.
Cheers.
|
|
|
|