Solved

Custom frame window in Win32 using Visual C++

Posted on 2002-07-10
4
1,493 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

685 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