Solved

Custom frame window in Win32 using Visual C++

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

758 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