?
Solved

Custom frame window in Win32 using Visual C++

Posted on 2002-07-10
4
Medium Priority
?
1,548 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 600 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

719 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