Solved

Custom frame window in Win32 using Visual C++

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

Technology Partners: 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

Title # Comments Views Activity
C Language combined operators 28 137
Grammars for C C++ and java 1 145
thread-safe code in c++ 2 128
C++ :Change value from  DisableCMD registry 4 80
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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 user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

738 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