Solved

How to make custom UI with VC++ 5?

Posted on 1998-06-30
7
316 Views
Last Modified: 2013-11-20
Hi,
   Is there a way (an easy one) to create custom User Interface for our application? For example, instead of using the standard Windows 95 application UI, I would like to create a fancy UI (kinda like WinAMP, or other Win32 MP3 players) with my own BMP file with the layout.
 
  I think I can achieve that by modifiying the .rc file, but I don't know where or how to begin.  Can anyone help me out?
0
Comment
Question by:eklee
[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
7 Comments
 
LVL 23

Expert Comment

by:chensu
ID: 1318569
Create a frame window without a menu, title, border or whatever you want. Here is a very simple template.

#include <afxwin.h>

//-----------------------------------------------------------------------------
class CMyApp : public CWinApp
{
    public:
        virtual BOOL InitInstance();
};
//-----------------------------------------------------------------------------


//-----------------------------------------------------------------------------
class CMyWnd : public CFrameWnd
{
    public:
        CMyWnd();
        inline BOOL CreateWnd();
   
    protected:
        afx_msg void OnPaint();
        afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
       
        DECLARE_MESSAGE_MAP()
};
//-----------------------------------------------------------------------------


//-----------------------------------------------------------------------------
inline BOOL CMyWnd::CreateWnd()
{
    RECT rcWnd;
    rcWnd.top = rcWnd.left = 0;
    rcWnd.right = 100;
    rcWnd.bottom = 100;
   
    return this->Create(NULL,      // use default class name
                        _T("My Window"),
                        WS_POPUP,
                        rcWnd);
}
//-----------------------------------------------------------------------------


CMyApp theApp;


//-----------------------------------------------------------------------------
BOOL CMyApp::InitInstance()
{
    // Create an instance of our own frame window class
    CMyWnd *pWnd = new CMyWnd;
    if (!pWnd->CreateWnd())
        return FALSE;
    pWnd->ShowWindow(SW_SHOW);
   
    m_pMainWnd = pWnd;
   
    return TRUE;
}
//-----------------------------------------------------------------------------


//-----------------------------------------------------------------------------
BEGIN_MESSAGE_MAP(CMyWnd, CFrameWnd)
    ON_WM_PAINT()
    ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()
//-----------------------------------------------------------------------------
afx_msg void CMyWnd::OnPaint()
{
    CPaintDC dc(this);    // device context for painting

    // draw your window here    
}
//-----------------------------------------------------------------------------
afx_msg void CMyWnd::OnLButtonDown(UINT nFlags, CPoint point)
{
    // action here
}
//-----------------------------------------------------------------------------

0
 

Author Comment

by:eklee
ID: 1318570
Yes, but how could I associate the "Close Window", "Maximize Window", "Minimize Window" buttons to what they should do?  For example, let's say my application has a circle shape, all the "Close/Max/Min Windows" buttons are at distributed in the bottom of the circle.  Let's say I have already drawn up the layout of this circle in a bmp file.

Now, how could I make my application to use my bmp file as its 'skin'? In addition to that, how can i tell my program that the "Close/Max/Min Windows" button are located at some other places, instead of at the top right (standard) position?
0
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1318571
You can always catch the mouse messages yourself and respond to them as needed. For example, if the user clicks on your X bitmap and you want to interpret that as a close message, then all need is to PostMessage(WM_CLOSE). To minimize, you would use ShowWindow(SW_MINIMIZE), and ShowWindow(SW_MAXIMIZE) to maximize the window.
0
Industry Leaders: 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!

 

Expert Comment

by:bfwizard
ID: 1318572
Your question is a not a hard question but is a long one and deals with many issues based on your design desions...like say if you make a custom button that say Maximizes a window....In all these cases you need to overide these messages and in some cases override them completely and deal with them yourself. You have to handle all button interactions including states of your buttons..drawing them yourself and produce messages when they are pressed.  But to answer your question one would need a clear idea of what you want to do.
0
 

Author Comment

by:eklee
ID: 1318573
bfwizard,
    I guess what I want to know is how could we use a custom BMP image as the appearance of our application.  For example, if we create a custom Dialog-based application, it will still be the traditional rectangle-shaped application.  Instead of this, I would like to make the application looks like whatever BMP image we use.  
    As another example, let's say I want to write a CD-jukebox application.  It is ugly if we use standard/traditional Windows' rectangle-shaped layout.  I want to make my application looks like a jukebox (I will draw it in a BMP file) and let the user interact with it (custom buttons).  How can I do this thru VC++? I know I can do this quite easily thru Delphi 3, but I don't have it, and I prefer to work with VC++ for now.
0
 
LVL 1

Expert Comment

by:sudhirbrat
ID: 1318574
It is very easy with ActiveX controls.

In the ActiveX Control Wizard(App Wizard), check the box Window less activation and you can build your control in customized shape.
0
 
LVL 4

Accepted Solution

by:
chabaud earned 100 total points
ID: 1318575
You can intercept the WM_NCHITTEST message for your window and return HTCLOSE / HTMAXBUTTON / HTMINBUTTON or  DefWindowProc() result, depending on xPos and yPos parameters.
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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

726 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