Solved

Custom frame window in Win32 using Visual C++

Posted on 2002-07-10
4
1,459 Views
Last Modified: 2012-08-13
I've developed a small Win32 app which draws a customized titlebar from a tiling bitmap. It houses all the functions, minimize & maximize buttons, system menu etc.

I have used the WM_NVPAINT message to do my titlebar and frame drawing. This all works perfectly, but when I move another window around in front of mine, it flickers tremendously. Even when the window is maximized and the taskbar pops up and lowers again to its hidden state, the flickering occurs.

How can I fix this. I've removed the _VREDRAW and _HREDRAW parameters from my window style. I created a normal WS_OVERLAPPED window and overrid the WM_NCPAINT message for drawing my frame and titlebar.

Another question, if I want to make this form have rounded edges or any other shape with for example, how do I go about doing this? Forms are all regtangular, but how do I define some places to be transparent?

Thanx guys!
0
Comment
Question by:josamoto
4 Comments
 
LVL 6

Expert Comment

by:DrDelphi
ID: 7144241
I'll answer the second of your questions: SetWindowRgn. Example:

#include <winuser.h>    //Is user for SetWindowRgn()
#include <wingdi.h>     //Is user for CreatePolygonRgn()

void __fastcall FormName::FormCreate(TObject *Sender)
{
    HRGN Region;
    POINT Points[4];

    //Define the points accross down
    Points[0] = Point(100 , 30 );
    Points[1] = Point(200 , 200 );
    Points[2] = Point(0 , 200 );
    Points[3] = Point(105 , 30 );

    //Define the region
    Region = CreatePolygonRgn(Points, 4, ALTERNATE);

    //Set the window to have the above defined region
    SetWindowRgn(Handle, Region , True);
}

Good luck!!
0
 
LVL 30

Expert Comment

by:Axter
ID: 7144654
Sounds like you need to add code to check if redrawing is neccessary.
Often, redrawing is not neccessary, and over use of redrawning is the common cause of flickering.
0
 
LVL 22

Expert Comment

by:ambience
ID: 7145392
filckers are generaly more evident when you have code that erases something and then draws i.e. WM_ERASEBACKGROUND clears the window and WM_PAINT paints it,

so if you are always going to paint the whole window yourself its better to handle WM_ERASEXXX and dont do anything there.

Maybe code for your NC drawing needs to speed up things a bit and be aware of what to draw and what not.
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 200 total points
ID: 7148417
This article talks about excatly that problem:
    http://www.microsoft.com/msj/0197/c++/c++0197.htm
There are a few tricks involved, but a REAL PROGRAMMER will go to the extr efforts involved to avoid flickering.

-- Dan
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now