|
What is it that you want to be hidden: a particular tab, or the whole dialog?
"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'd like to hide the tab control except for the tabs. Or basically, I'd like the same functionality as the auto-hide windows in VS 2005 .NET
|
|
|
|
|
I'm in the process of writing a set of custom controls, things like horizontal and vertical sliders, knobs, switches, etc... These controls have no background but do display a PNG image (with transparencies). For example, a slider is only responsible for painting its thumb, not the background underneath it.
My approach has been to use MFC to create custom controls deriving them from CWnd. I override OnPaint and OnEraseBkgnd so that I'm in control of how painting is done. I'm using GDI+'s Graphics class for drawing the images.
The custom controls are placed on a dialog box. Actually, they are placed on a Picture control displaying the background as a bitmap. When a control needs to repaint itself, it doesn't invalidate itself directly but tells the parent window to invalidate the rectangle it is within. If I have the control invalidate itself directly, then there's nothing to erase the previous image. Since there are transparencies involved, they just keep getting layered on top of each other.
I'm running into problems with flickering, especially in the case of my Knob control. The knob control uses 91 PNG images stitched together. When the knob changes values, it draws a specific knob image offset into the stitched group.
I know there's been a lot written here about flickering while drawing. But I must be dense about this because I can't seem to apply what I'm reading with my situation. I'm not trying to draw with primitives but rather use images that I load. I've looked at the GDI+ API for ways of somehow caching my PNG images so that I can switch between them seamlessly. I'm not coming up with much, so I'm asking for help. Thanks for your time and patience.
|
|
|
|
|
Any time you have to draw a background and then overlay something on top,
there's going to be flicker.
You have two options -
1) do it fast enough so a human can't notice.
2) do it offscreen.
Option 1 is pretty much impossible with current PCs.
For option 2, double buffering is pretty simple.
Before you draw the control the first time, and before redrawing the
control any time it gets moved or resized, get a copy of the background
pixels in a bitmap. Keeping this in a screen-compatible bitmap, selected
into a screen compatible memory dc is best.
A great place to do this is in response to WM_SIZE, where you can (re)create
the bitmap to the appropriate size.
Now, every time you need to draw the control, you can
1) blt the background image to a memory DC (compatible with screen)
2) blt the png overlay to the memory DC
3) blt from the memory DC to the screen
Make sense?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: Make sense?
Yes, makes a lot of sense. I have a much clearer picture of what I need to do. Thank you.
One question: Is there an easy way to grab a chunk of the background being displayed by the parent window? The child controls have access to the background bitmap; they could parse a chunk out of the bitmap themselves, but the question is which part. This could all be meticulously worked out beforehand, but it would be cool if each control could just give the parent its coordinates in a CRect, or whatever, and get back a bitmap image of that size.
[EDIT]
Well, I seemed to have solved my problem. The background bitmap is stored as a resource. Each custom control has access to it. The background image is displayed on a static control beneath the custom controls. So what I have each custom control do is convert its client rectangle into a coordinates relative to its parent. It then has its position relative to the background image.
I then do this with a Graphics object in OnPaint:
graphics.DrawImage(background, 0, 0, rect.left, rect.top, rect.right, rect.bottom, UnitPixel);
graphics.DrawImage(&knobImages, 0, 0, 0, knobPosition * KNOB_HEIGHT, KNOB_WIDTH, KNOB_HEIGHT, UnitPixel);
I draw a chunk of the background image followed by the appropriate knob image.
And I'm using the CBufferDC class from this[^] article. Man, I can turn the knobs now and they are flicker free. This rocks!
Thanks, Mark, for your response. It was just what I needed to get me back on track.
[/EDIT]
[EDIT2]
Heh, turns out it's not so effecient to do a Bitmap::FromResource in every control, especially when that bitmap is large. At least it was taking awhile for all of the controls to display themselves, so I just have the main dialog load the bitmap and pass it along to all of the custom controls. Works much faster now.
[/EDIT2]
-- modified at 1:30 Tuesday 2nd October, 2007
|
|
|
|
|
Leslie Sanford wrote: ...and they are flicker free. This rocks!
Cool! It's always worth the little extra code to make it smoooooth
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
while looking at old C code (1996-ish), I can see that they were using #pragma optimize ("g",off) before some functions.
I was wondering, and I cannot find the answer in msdn, if there is an "off" and there no "on", is the pragma local to the actual file ? or is it affecting all other files that are being compiled after that ?
All examples show to have an "on" after an "off"
Thanks.
|
|
|
|
|
Maximilien wrote: is the pragma local to the actual file ?
yes. well, it's local to the "compilation unit". if the pragma's in a .C/CPP, then that's the one file. if it's in a .H, it will be in effect wherever that file is included.
|
|
|
|
|
|
Hello Everyone,
In c++, when declaring objects using the default constructor why are we not allowed to use the parentheses?
For example:
Date birthday;
vs.
Date birthday(); // WRONG!!
It seems like allowing the parentheses would keep the syntax of the declaration in sync with when we are using a constructor other than the default such as
Date birthday(10, 4, 2000);
Seems like there is a reason for everything in c++ so just wondering.
Thanks.
|
|
|
|
|
yadrif wrote: Date birthday();
That's a declaration for function birthday that takes no parameters and returns a Date .
|
|
|
|
|
Thanks.
I get it now. I should have noticed that.
Thank You.
|
|
|
|
|
using the default constructor to use the parentheses
int i = int();
char c = char();
Data birthday = Data();
|
|
|
|
|
Hi All,
I'm compressing a range of bitmaps using the VCM and the ICCompress function that has been opened on the MP42 codec (Microsoft Mpeg4 V2). The compression of the bitmaps work just fine, but I am battling to set when the next keyframe should be delivered from the compression.
DWORD dwInFlags = 0, dwOutFlags = 0;<br />
<br />
if (various check to set a key frame)<br />
dwInFlags = ICCOMPRESS_KEYFRAME;<br />
<br />
<br />
m_lFrameCount++;<br />
<br />
DWORD dwSuccess = ICCompress(m_hIC, dwInFlags, (LPBITMAPINFOHEADER)m_pVideoOut, m_pFrame, (LPBITMAPINFOHEADER)m_pVideoIn, pFrame, NULL, &dwOutFlags, m_lFrameCount, 0, 0, NULL, NULL);<br />
<br />
if (dwSuccess == ERROR_SUCCESS)<br />
{<br />
if (dwOutFlags & AVIIF_KEYFRAME)<br />
{<br />
m_lFrameCount = 1;<br />
TRACE("\nKEYFRAME %d", m_pVideoOut->bmiHeader.biSizeImage);<br />
}<br />
<br />
Any ideas as to what may be wrong in my code, or is there another way to accomplish that ?
Thanks !
|
|
|
|
|
if i declare a class object to be static, like
static term terms[maxTerms];
what does that mean and what does that actually do?
btw does anybody have any idea how to solve 2 terms involving polynomials..i mean make a program that solves them? i only need a start on this..will think it through myself then..
|
|
|
|
|
|
|
|
Heh. I don't know what to tell you. Try google search on same text.
I usually post links to save myself typing....I can see that failed here...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
already tried google and the msdn library isnt opening
|
|
|
|
|
if you use Visual Studio, go to the Help index and type
"static members" and choose data members.
That's how I found the link.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I'm writing a program that can read out an C-file.
This is done line by line,
firt I open the file, then I read in every line of the file.
All these lines are putted in an Array,
now I have to search this array for functions, like "main", "void" etc.
So my question is,
How kan I search an array?
greetings,
Timo
|
|
|
|
|
That depends a lot of how you defined your array. A snippet of code would be usefull.
To search for a string into a larger string, you can use the strstr function[^]
|
|
|
|
|
Here's a couple of lines out of the code:
while ( fgets ( line, sizeof line, file ) != NULL )<br />
{<br />
rn++;
itoa(rn,regelnummer,10);
strcpy(alles[i], line);
i++;
strcpy(alles[i], regelnummer);
i++;
}<br />
fclose (file); <br />
}
........................................................
first the line out of a file is putted in the array,
after this the line number..
then the next line.. next line number etc..
|
|
|
|
|
So now all you have to do is go back through the alles array and look at all of the "even" lines. Use the strstr() function as has been mentioned.
"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
|
|
|
|
|