Solved

How to make custom UI with VC++ 5?

Posted on 1998-06-30
7
301 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
7 Comments
 
LVL 23

Expert Comment

by:chensu
Comment Utility
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
Comment Utility
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
Comment Utility
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Expert Comment

by:bfwizard
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive Gives IT Their Time Back

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

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 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

10 Experts available now in Live!

Get 1:1 Help Now